Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ matches the PCR values sent, and then the values:
| 13 (initrd stage) | zero or the os-separator alone | nothing extended the initrd: an extension image added on the ESP fails the quote that releases user-data |
| 13 (ready stage) | computed from `policy.json` `sysexts` for the VM's Kubernetes and CNI versions, the os-separator alone for a VM without Kubernetes; never golden | the exact Kubernetes and CNI sysexts, or none |
| 15 (ready stage; required when `policy.json` has `"pcr15": "layer-certificates"`, which every image of this repository sets) | replay of `userspace_log`, every record bound to its word (sha256 of a `machine-id:`, `file-system:` or `layer-certificate:` word, anything else rejected); its `layer-certificate:<sha256>` words against the VM's `layer_certificates`, in order | the installation layer certificates the initrd enrolled, exactly those served |
| 1, 5 | recorded, not compared | SMBIOS tables with per-VM credentials, the boot entry, the GPT with per-install UUIDs |
| 1 | replay of `event_log`: the ACPI and SMBIOS tables QEMU builds from vm-manager's arguments and the SMBIOS structures systemd-boot and systemd-stub measure, which the guest cannot write, replayed; `BootOrder` and the `Boot####` options, each bound to its data, against the VM's first verified boot (`get_vm` `bootConfig`) | the firmware's boot configuration in the VM's variable store: an option root changes fails the next boot |
| 5 | replay of `event_log`: the GPT, bound to its event, holds the partitions of the image's installed disk and nothing else (the ESP, slots A and B of root, verity and verity signature, var: their types, labels, attributes and counts); systemd-boot's `loader.conf` against the VM's first verified boot; the separator and `ExitBootServices` | the partition table and the boot loader's configuration: a partition added, retyped, relabelled or given another attribute, or an edited `loader.conf`, fails the next boot |

Every attestation key is certified against the VM's own endorsement key (EK), the first
quote of the VM's first boot included. vm-manager reads the EK from the VM's vTPM itself
Expand All @@ -272,10 +273,12 @@ the same boot (a boot that skipped the agent: a masked unit, a command line that
off), and a boot without one by `--boot-timeout`. A rejected initrd quote ends the boot
before user-data is released. `start_vm` boots the VM again and judges that boot anew.

Caveats. PCR 1 and 5 cannot be pinned across VMs, because EDK2 measures the SMBIOS tables
(which carry vm-manager's per-VM credential strings) and the boot entry with the ESP's
partition GUID into PCR 1, and PCR 5 holds the installed disk's GPT; both stay in every
quote for forensics. The ESP is writable for root on a node, so the verifier judges what
Caveats. PCR 1 and 5 have no golden values, because EDK2 measures the ACPI and SMBIOS
tables (sized for the VM, carrying vm-manager's per-VM credential strings) and the boot
entry with the ESP's partition GUID into PCR 1, and PCR 5 holds the installed disk's GPT;
the verifier replays the firmware event log against them instead. The boot variables and
`loader.conf` are compared with what the VM's first verified boot measured: before it,
only vm-manager's installer wrote them. The ESP is writable for root on a node, so the verifier judges what
the boot took from it: the command line and the archives in PCR 12, an extension image in
PCR 13 at the initrd stage; with Secure Boot on, a loader entry's command line does not take
effect either. The integrity story rests on PCRs 0, 4, 7 (Secure Boot with the image's keys),
Expand Down
38 changes: 23 additions & 15 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,19 +303,26 @@ closed it; open follow-ups are scheduled in [plan.md](plan.md).
deletes every `kubernetes_*.raw` other than the requested version before it refreshes;
exactly one file, one merged extension, one PCR 13 measurement per boot. A changed
`/kubernetes-version` takes effect on the next boot (no live switch of a running node).
- **PCR 1 and 5 are per VM.** Implemented by exclusion (#32, `attest.GoldenIndexes`). The
first golden-path boot showed
them differing between two VMs on the same firmware and image: EDK2 measures the SMBIOS
tables into PCR 1 (`SmbiosMeasurementDxe`, type 11 OEM strings are not filtered), and
vm-manager's type 11 strings are per-VM credentials (hostname, machine ID, SSH key,
notify socket), as is the `Boot####` entry whose device path carries the ESP's
partition GUID; PCR 5 holds the GPT of the installed disk with per-install partition
UUIDs. `attest.GoldenIndexes` is therefore 0, 2-4, 6 and 7 (PCR 13 is computed); PCR 1 and 5 stay in
every quote and in `get_vm_attestation` for forensics. The integrity story rests on 0
(firmware), 4 (boot loader and UKI), 7 (Secure Boot policy), 11 (UKI and phases) and
13 (sysext). A per-VM prediction of 1 and 5 by replaying the firmware event log the
agent already posts (`event_log`) against what vm-manager itself passed as SMBIOS and
what sysinstall wrote as GPT is the follow-up if they are wanted.
- **PCR 1 and 5 are per VM.** Implemented by event-log replay (#316,
`internal/attest/bootconfig.go`, `e2e/boot_config_attestation_test.go`). They differ
between two VMs on the same firmware and image, so `attest.GoldenIndexes` is 0, 2-4, 6 and
7: EDK2 measures the ACPI tables (sized for the VM) and the SMBIOS tables into PCR 1
(`SmbiosMeasurementDxe`, type 11 OEM strings are not filtered, and vm-manager's are per-VM
credentials: hostname, machine ID, SSH key, notify socket), as is the `Boot####` entry
whose device path carries the ESP's partition GUID; PCR 5 holds the GPT of the installed
disk with per-install partition UUIDs. The verifier replays the PCR 1 and 5 events of the
firmware event log (and the initrd's os-separator from the userspace log) to the quoted
values, every event one a boot vm-manager starts has and bound to its data where the log
carries it. What the guest can change is judged: the GPT must hold the partitions of the
image's installed disk and nothing else (`installedDisk`, kept equal to
`repart.sysinstall.d` by a test: types, labels with the image's id and version or
`_empty`, attributes, counts), so a partition added, retyped, relabelled or given another
attribute fails the next boot; `BootOrder`, the `Boot####` options and systemd-boot's
`loader.conf` must be what the VM's first verified boot measured (the record's
`bootConfig`; before that boot only vm-manager's installer wrote them). The ACPI and SMBIOS
tables and the SMBIOS structures systemd-boot and systemd-stub measure come from QEMU and
vm-manager's arguments; the guest cannot write them, they are replayed, not compared, so a
host's QEMU update does not fail its VMs.
- **The ESP and the kernel command line.** Implemented (#293,
`e2e/kernel_cmdline_attestation_test.go`). The installed ESP is writable for root on a
node. With Secure Boot off, systemd-stub used a command line a Type #1 entry's `options`
Expand Down Expand Up @@ -399,8 +406,9 @@ signature over the quote with `ak_pub`, nonce match,
PCR digest matches `pcrs`, PCR 11 equals the value computed with `systemd-measure calculate`
for the image's UKI and the stage's phase path (`enter-initrd` for `initrd`,
`enter-initrd:leave-initrd:sysinit:ready` for `ready`), PCRs 0, 2-4, 6 and 7 equal the
image policy's golden values recorded by `vm-manager image golden` (PCR 1 and 5 are quoted
and recorded, not compared: see the open point below), and at `ready` PCR 13 equals the
image policy's golden values recorded by `vm-manager image golden` (PCR 1 and 5 differ per
VM: the firmware event log is replayed against them, see the point above), and at `ready`
PCR 13 equals the
value computed from the policy's `sysexts` entries of the VM's Kubernetes and CNI
versions (written by `images/scripts/verify-sysext`; the os-separator alone when the VM has
none). The image's
Expand Down
7 changes: 5 additions & 2 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ below are the last full run on the development host.
| `TestAttestation` | servers in turn over a private `policy.json`: without golden values, after `vm-manager image golden` recorded them (also a VM with two `layer_certificates`), on a distribution's Secure Boot build of OVMF in place of vm-manager's | a VM of a policy without golden values killed at its initrd quote (`no golden value`), user-data never released; the recording reproduces the suite's values bit for bit and names `golden_firmware`; verified initrd and ready quotes, user-data applied; both layer certificates and the Giant Swarm one in the sealed `.dm-verity` keyring, both digests in the ready verdict (PCR 15), a further `layer-certificate:` measurement from the root rejected naming the digest and the VM killed; `golden mismatch` on PCR 0 with the other firmware, naming the recorded build, the VM killed before user-data is released | about 3 min |
| `TestAttestationSkipped` | MCP | a boot that skips `vm-agent-attest.service` is killed and the VM failed, never ready: a loader entry with `systemd.imds=no`, a loader entry masking the unit on the kernel command line, a mask in the persistent `/etc` (the initrd quote verifies, the ready quote never comes) | three VMs, each installed and rebooted |
| `TestAttestationKeyCertified` | MCP, a second server on the same state | every attestation key is certified against the VM's own endorsement key: two VMs' records hold the TCG RSA EK vm-manager read from each vTPM before its first QEMU, another per VM, and every verdict of their first boots names the key certified against it; one VM's record given the other's EK, its next boot recovers no challenge's nonce (the agent's `TPM2_ActivateCredential` fails on the console), posts no quote and is refused, never released its user-data | two VMs to ready, one refused boot |
| `TestBootConfigAttestation` | MCP | PCRs 1 and 5: the first installed boot verifies and records the VM's boot configuration (`bootConfig`: `BootOrder`, the `Boot####` options, `loader.conf`), a `reboot_vm` verifies against it; then a VM per change root makes, each refused at its next boot (killed, `failed`, never ready): the description of the boot option bootctl installed changed through efivarfs, rejected naming the option; an empty B slot retyped with `sfdisk`, rejected as a partition the image does not define; an option added to `loader.conf`, rejected naming it | three VMs, install and two boots each |
| `TestKernelCommandLineAttestation` | MCP | The ESP: the first installed boot runs with Secure Boot on (`ignition.firstboot` through the stub's SMBIOS extra) and verifies at both stages, as does a `reboot_vm`. Then a VM per change root makes to the ESP, each refused at its next boot (killed, `failed`, never ready): `options <command line> ipe.enforce=0` appended to the loader entry, which the stub ignores under Secure Boot while systemd-boot measures it, rejected naming PCR 12 and the option with PCR 11 unchanged; a credential added to the entry, rejected on PCR 12; an extension image, its initrd quote rejected on PCR 13 | three VMs, install and two boots each |
| `TestKubernetesCluster` | MCP plus the host's `kubectl` through `forward_port` 6443 | on the IPE image with kernel lockdown at confidentiality: control plane from CAPI 1.14-shaped Ignition (`ExecStart=/bin/bash /etc/kubeadm.sh`, ordered `After=vm-kubernetes.service`), every image from gsoci through a mirror on the host holding copies signed with the build's key, Cilium from cilium-app, a worker joined with a bootstrap token, two Ready nodes with `giantswarm-vm://` providerIDs, cross-node DNS, clean units and unmanaged CNI links; on the worker a pod of an image signed with the Giant Swarm key (running as a user named in the image's `/etc/passwd`) and one signed with the installation's key (`layer_certificates`) run, every `containerd-erofs-*` dm-verity device backs a running container, the IMDS refuses `/user-data`, `/attest/challenge` and `/report` from a pod's network namespace while the node reaches it, an image with a layer outside its signatures fails at pull naming that layer, and a file of the running pod's layer is refused as a kernel module, firmware and kexec image; every route to executable memory around IPE (`e2e/execroutes`: `/proc/self/mem`, `mprotect` adding write or execute, `READ_IMPLIES_EXEC`, `ptrace`) refused in a pod without a `securityContext` and in a transient host service, with the kubelet's `seccompDefault` from the sysext's drop-in | `cp_ready_seconds`, `worker_join_seconds`, `layer_registry_seconds` |

Expand Down Expand Up @@ -119,8 +120,10 @@ level there (`systemd.unit-dropin.*` credentials, systemd-debug-generator(8)).
AK pinning per VM on the first verified initrd quote (restored from the VM's
record after a restart, `Pin`), PCR 11 against the image's `policy.json`
phase paths, PCRs 0, 2-4, 6, 7 (and 13 at ready, `SysextPCR`) against its
golden values, a PCR without one rejected; PCR 1 and 5 are recorded, not
compared. `Recorder` is the reference boot of `vm-manager image golden`:
golden values, a PCR without one rejected; PCR 1 and 5 replayed from the
firmware event log, the GPT against the image's installed disk and the boot
variables and `loader.conf` against the VM's first verified boot
(`bootconfig.go`). `Recorder` is the reference boot of `vm-manager image golden`:
every check but the golden comparison; serve never builds one.
- `internal/host` — the host capability service behind `get_host`: kernel, CPUs,
memory, `/dev/kvm` and `/dev/vhost-vsock` access, qemu / swtpm / systemd
Expand Down
2 changes: 0 additions & 2 deletions docs/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Follow-ups recorded by reviews and agents, not yet scheduled:
- `vm-kubernetes.service` merges with `systemd-sysext refresh` on the first boot instead of
starting `systemd-sysext.service`, so the manager phase does no unmerge there; starting the
unit would make the no-pod shutdown fully synchronous.
- PCRs 1 and 5 (SMBIOS credentials, per-install GPT) are quoted but not compared; event-log
replay, as PCR 12 already does, is the proper fix.
- A swtpm that is alive but unreachable at reattach is treated as gone (VM runs without TPM).
- The caller identity is only logged; VM records carry no `requestedBy` unlike agent-manager.
- Nine sequential e2e tests take ~10 min; parallelise or shard when the suite grows.
Expand Down
Loading
Loading