diff options
Diffstat (limited to 'docs/design.md')
| -rw-r--r-- | docs/design.md | 105 |
1 files changed, 98 insertions, 7 deletions
diff --git a/docs/design.md b/docs/design.md index 0e364fc..2f0db85 100644 --- a/docs/design.md +++ b/docs/design.md @@ -400,8 +400,8 @@ run commands, but on the provider's side, before there is a submission.) - The current snapshot of each channel is kept on disk, so it survives a reboot, together with the schema it was accepted under (section 6 needs - it). Secrets there are root's, as `/var/src/secrets` is today; later - they can be encrypted to the host's key. + it). Secrets there are root's, as `/var/src/secrets` is today, plain + unless sealed to the TPM; section 8 says what protects them. - Submissions may wait in an incoming directory for the next switch (section 6); those the switch refuses are moved aside, with when and why, so the next switch doesn't trip over them again. One the check @@ -513,7 +513,9 @@ turn out to be needed. ## 8. Trust (all of it, eventually) -Three stages, each usable on its own: +State is decoupled from Nix, so it never has to travel through Nix's +paths: builders, caches, CI. It goes from its sources, through a +provider, to the host. Three stages, each usable on its own: 1. **As today.** The host's ssh host key is the first key. It gets to the host as it does now (rsync over ssh), the authorized keys that allow @@ -522,9 +524,95 @@ Three stages, each usable on its own: 2. **Signed submissions.** The schema names the keys a channel accepts signatures from. Then the fleet channel can be fetched from somewhere untrusted, like a federation, by an agent without privileges. -3. **Encrypted items.** Secrets encrypted to the host's key, for transport - and at rest. The host key itself stays the exception that stage 1 - provides, until that evolves. +3. **Encryption**, of two kinds, for two different things (8.2, 8.3); 8.1 + says against what each protects, and when to use which. + +### 8.1 What protects against what + +Encryption protects only where its key isn't: a key on the same disk as +what it encrypts protects nothing against whoever can read that disk. + +| threat | protection | +|---|---| +| root on the running host | none: the host must be able to read its state; least privilege for what reads it, and the sandbox for programs (5.2) | +| someone with the disk, the host powered off (theft, a discarded disk, a copy of it) | full-disk encryption of the host, or at least of the state directory (8.4); or entries sealed to the host's TPM (8.3) | +| copies of the running system (backups of the state directory, file system snapshots sent elsewhere, snapshots of a running VM's disk) | full-disk encryption doesn't follow a copy: entries sealed to the TPM (8.3), or leaving the state directory out of copies | +| what reads more than it should, but isn't root (a service's bug, a backup agent) | entries sealed to the TPM (8.3): their views are sealed too, plain text is in no file | +| the way to the host, when it isn't ssh (a registry, an image preseeded with state) | entries encrypted to the host's key (8.2) | +| an image preseeded with state | sealed to the TPM of the host it is for (8.3); encrypting to a host key that is in the same image protects nothing | + +When to use which: + +- A host with full-disk encryption, its state delivered over ssh (hrm's + case): nothing more. The state directory is root's (0700), on an + encrypted disk. +- A host without full-disk encryption: encrypt the state directory's file + system (8.4), or seal secret entries to the TPM (8.3). +- State taking another way than ssh: encrypted submissions (8.2). +- An image preseeded with state: seal to the TPM (8.3). + +Sealing to the TPM on top of full-disk encryption isn't needed by default, +but adds protection where full-disk encryption ends, once the disk is +unlocked: copies of the running system that leave the host, processes +that read more than they should, and binding secrets to this machine and +a measured boot. It's worth it for the secrets that matter, where copies +of the running system leave the host. Losing a sealed entry (a new TPM, +a new mainboard) is recovered from by a fresh submission: the source is +elsewhere. + +### 8.2 Encrypted submissions + +Entries of a submission encrypted to the host's ssh host key (age takes +ssh-ed25519 recipients), so that a submission can take ways that aren't +ssh, and wait in the incoming directory, without showing its secrets. The +provider encrypts (`--pack`, given the host's public key); the receptor +decrypts with the host's private key when it plans. What it stores, it +stores as it would have the entry in plain text: this protects the way, not +the state at rest. + +### 8.3 Entries sealed to the TPM + +Postponed (2026-12-01): designed, but not to be built for now. + +A secret slot may say that its entry is kept sealed to the host's TPM, by +systemd's credentials (`systemd-creds encrypt --with-key=tpm2`, maybe bound +to a measured boot by PCRs). The entry is then useless off this machine, +and plain text is in no file at all: the slot's view is the sealed +credential, which a service loads with `LoadCredentialEncrypted=`, and +systemd opens when the service starts. + +- The receptor receives the entry in plain text (or encrypted to the host + key, 8.2), runs the validators on it, and seals it before it stores it. +- Or the provider seals it already (to the TPM's public key, which + `systemd-creds` can encrypt to off the host), and the receptor only + stores and delivers it. Then the entry is opaque: validators see only + the sealed credential, and whether it changed is a matter of its bytes, + so sealing the same secret again (with a new salt) counts as a change. +- Sealed entries can't be combined: a view of a sealed slot is the slot's + own view; a renderer can't be given one (the schema refuses it), and + converters and steps can't read one (renames carry it as it is). + +On a host without a TPM, systemd falls back to a key on the disk +(`/var/lib/systemd/credential.secret`), which protects as much as 8.1 says +of keys on the same disk; the schema should say whether that is +acceptable, and by default it isn't. + +Binding to PCRs needs care with updates: bound to PCRs that change with a +firmware or kernel update, entries can't be opened after the update until +they are sealed again. Binding to the Secure Boot state (PCR 7), or by +systemd's signed PCR policies, avoids that; otherwise the receptor would +seal entries again after such an update, or they would be submitted +again. + +### 8.4 Plain entries, and full-disk encryption + +Without 8.3, entries are plain files, root's, in the state directory +(0700), and views of secret slots plain files in memory (`/run`, root's). +That is as much as the host itself protects them: against users that +aren't root, but not against root, and not against whoever has the disk, +unless the disk, or the file system of the state directory, is encrypted. +On a host with full-disk encryption that is enough for most uses; on one +without, the state directory deserves a file system of its own that is. ## 9. How the state objects fit in @@ -687,7 +775,10 @@ What it would replace in hrm: postponed; there is room for it next to `channels/` (5.2). 5. **At boot** with a slot that can't be filled: is "no views, consumers fail" good enough until there are more policies? -6. **Names** (section 3). +6. **Sealed entries** (8.3): how a slot says it, whether systemd's fallback + to a key on the disk is ever acceptable, and how a provider gets a TPM's + public key to seal to. +7. **Names** (section 3). ## 13. A first version |
