Nikasa, home Request an invite
DocsSecurity reference

Security reference

The detail behind Security and your data, for a security review. What a run sets up in your services, every file a run folder holds, and every file a saved baseline holds.

On this page

For the short version, see Security and your data.

What a run sets up #

A run sets up four things in your sandbox: certificates, test tokens, database settings and a signing library.

Certificates #

When a compare answers outside calls from a recording, services trust a certificate authority made for that run.

Run What services trust
With a pack's cassettes That authority and no other.
A compare's later runs That authority beside the public roots, since hosts that stay live must still verify.

A root your image added for a private host is not in that bundle, and --live-outside avoids that. The authority's private key stays in the run folder with mode 600.

Test tokens #

When a pack sends tokens it did not get inside the sandbox, each run makes its own signing key, kept in the run folder. It signs fresh tokens for that run's services.

A run like this lets nothing out of the sandbox, so those tokens do not go out over its network.

Databases #

Nikasa runs your databases without waiting for the disk, the same for both builds:

  • Postgres with fsync and full_page_writes off;
  • MySQL and MariaDB flushing their log once a second.

A setting your compose file already chooses is kept. The data is thrown away after every run either way.

The signing library #

Nikasa signs test tokens with an RSA library that has a published advisory, RUSTSEC-2023-0071, about timing leaks in private-key operations measured over a network.

nk itself does the signing, before the run's containers start, with a key made for that one run and kept in its run folder until you delete the folder.

What a run folder holds #

A compare's output folder holds the reports and one run folder for each run, old-1, new-1 and so on.

File Holds Sensitive
capture.pcapng.zst, and the segment, record and datagram files read from it The traffic on the sandbox network Yes: your test traffic as sent
keys.log The TLS session keys of that traffic Yes: decrypts the capture
services.log, driver.log Your services' and the driver's output As sensitive as your logs
observation.json.zst What Nikasa read, values masked, secrets replaced Low, as for the reports
report.txt, .json, .md, information.jsonl, in the output folder The changes, and what was compared; report.json adds full paths on this machine Low, once you have read your first report: they quote values from your test traffic, and not everything is masked
driver-override.json With a driver preset or x-nk: tests: what the driver runs and its environment, the values under env as they are Yes, when those values are secrets
keys.txt, ebpf.txt, mounted.json, run.json Small notes about the run Low
cassettes-tls/ With cassettes: the run's certificate authority and the cassette server's keystore Yes: signs certificates the run's services trust
cassette-misses.json, cassette-unmatched.json Outside calls no cassette answered As sensitive as your test traffic
outside/, in the output folder The recording of outside calls, credentials left out of the stubs As sensitive as your test traffic
identity/key.pem, identity/known.json, identity.json When tokens are made fresh: the run's signing key, the tokens and what was substituted Yes: they are valid for the run's services until they expire
inputs/, wiremock/ When tokens are made fresh: the run's copy of the pack's inputs and cassettes As sensitive as the pack
seed.dump, pack.archive, pack/ A seed dump or pack fetched from a link or S3 As sensitive as the dump or pack

Packed files #

The big files are packed with zstd once the run is observed, each named with .zst after its old name. Wireshark 3.6 and later, when built with zstd, opens capture.pcapng.zst as it is. Otherwise unpack it first:

shell
zstd -d capture.pcapng.zst

When the disk runs short #

A compare removes the captures, and the two files of TCP and TLS read from them, for runs it has made. It keeps results.json beside them. When a compare stops early says more.

A saved starting database #

It outlives the run. The volume nk-golden-<hash> stays on the Docker host until you remove it, so it is as sensitive as the seed.

What a saved baseline holds #

nk compare --baseline <dir> keeps the old build's runs for later compares. The GitHub Action keeps that folder in the repository's Actions cache or your own storage.

It holds a fixed list of each old run's files, and nothing else:

File Holds Sensitive
observation.json.zst What Nikasa read, values masked, secrets replaced by markers Low, as for the reports
results.json The driver's outcome, the outside hosts reached, masked; and every call the run made outside the sandbox, bodies exactly as they came, encrypted The outside calls: as sensitive as your test traffic, and unreadable without the secret key. The rest: low
meta.json The baseline key and its parts' hashes, when the runs were made and last checked, Nikasa's, Docker's and the kernel's versions Low
Small notes, the API description and .proto files What later steps read, as in a run folder As in a run folder

Never saved #

  • the capture and the files read from it;
  • keys.log, services.log and driver.log;
  • cassettes-tls/;
  • identity/ with its signing key and tokens;
  • seed dumps and packs.

The secret key is never saved #

The baseline key holds only an HMAC of a fixed string keyed by the secret key, which cannot be turned back into it.

Outside calls #

They are one encrypted blob, XChaCha20-Poly1305 under a key derived from the secret key, never the secret key itself.

A run whose calls do not decrypt counts as no saved baseline. The old runs are made again, and the report says which run and why.

Written for nk 0.3.14. Something wrong or unclear? Write to hello@nikasa.dev.