Repository navigation
feat: measure the app key epoch in RTMR3, MrConfigV3 and KMS certificates - #1694
Conversation
aacc8c3 to
668f85b
Compare
f7a25ba to
2ec1527
Compare
|
Reviewed at 2ec1527. I found no security bypass. The epoch Findings, most important first: Should fix before merge
Tests
Behaviour change worth a CHANGELOG line
Minor
|
…ates A verifier could not tell which app epoch a CVM's keys or certificates came from. The root epoch needs no measurement: the KMS root key in `key-provider`, or the issuing root CA, already identifies it. - The guest emits an `app-epoch` runtime event after `key-provider` for KMS keys, with the app epoch as a big-endian u32. - MrConfigV3 gains an optional `app_epoch` pin. The guest honors it only when TDX MR_CONFIG_ID or SEV-SNP HOST_DATA binds the document, requests that app epoch from the KMS, and refuses to boot when the served epoch differs. SEV-SNP has no runtime register, so there the VMM always binds the app epoch for KMS keys, asking the KMS for the current one when no pin is set, on images whose metadata.json sets `app_epoch_pin`, and the guest refuses to boot without it. - The VMM takes the pin as `VmConfiguration.app_epoch` and `UpdateVmRequest.update_app_epoch`, and refuses it at deployment unless the key provider is KMS and the launch binds MrConfigV3. `ListImages` reports `app_epoch_pin`, and vmm-cli (`deploy --app-epoch`, `update --app-epoch/--no-app-epoch`) and the web UI (an App Epoch field) offer the pin only for an image it marks, so an older VMM is never sent a pin it would drop. The VMM writes launch inputs only when it launches a guest, not when it adopts a running one. - `GetSealedEnvPubKey` takes `SealedEnvPubKeyRequest` with an optional `app_epoch` up to the current one, so vmm-cli and the web UI seal the env of a pinned VM at its epoch, never at one only the host reports. The key of an older epoch is signed under `dstack-sealed-env-pubkey-historical-v1`, so verifiers expecting the current key reject it. - `SignCert` signs under the app epoch the attestation records (`Attestation::decode_app_epoch`: the boot-time `app-epoch` event where a register replays it, the MrConfigV3 pin on SEV-SNP), falling back to the current one where nothing records it. It stamps that epoch into the `PHALA_RATLS_APP_EPOCH` certificate extension (OID 1.3.6.1.4.1.62397.1.10), read by `CertExt::get_app_epoch`. - dstack-verifier reports the measured app epoch as `app_epoch`, in `/verify` and in the certificate mode. - The Lean boot trace, MrConfig and KMS signature models follow these changes. Signed-off-by: Kevin Wang <wy721@qq.com>
2ec1527 to
050dc7a
Compare
|
Thanks for the thorough review. All addressed in 050dc7a:
|
Leechael
left a comment
There was a problem hiding this comment.
Re-reviewed 050dc7a: all 11 points are addressed. Adopting a running guest no longer rewrites its launch inputs, which is safe since the guest copies host-shared at boot and unmounts it. The ListImages capability gate is a cleaner fix than the readback. LGTM.
Problem
A verifier cannot tell which app epoch a CVM's keys or certificates come from. Neither the quote nor KMS-issued certificates record it, and a certificate signed before an app epoch rotation stays valid until it expires. The root epoch needs no measurement of its own: the KMS root key in
key-provider, or the issuing root CA, already identifies it.Changes
app-epochruntime event right afterkey-provider. The payload is the app epoch as a 4-byte big-endian integer.app_epoch, pins the app epoch.MR_CONFIG_IDor SEV-SNPHOST_DATAbinds the document. It requests that epoch and refuses to boot if the KMS serves another.metadata.jsonsetsapp_epoch_pin, so older images launch as before.VmConfiguration.app_epochand fromUpdateVmRequest.update_app_epoch/app_epoch. At deployment it refuses the pin unless the key provider is KMS and the launch binds MrConfigV3.deploy --app-epoch,update --app-epochandupdate --no-app-epoch. The web UI adds an App Epoch field to its deploy and update dialogs, and keeps the pin when cloning.ListImagesreportsapp_epoch_pin, and both offer the pin only for an image it marks, so an older VMM is never sent a pin it would silently drop.GetSealedEnvPubKeynow takesSealedEnvPubKeyRequest, which is wire-compatible withAppIdand adds an optionalapp_epoch. The KMS serves the key of any app epoch up to the current one. vmm-cli and the web UI pass the pin, so the env of a pinned VM is sealed at its epoch.SignCertsigns under the app epoch the attestation records, through the newAttestation::decode_app_epoch: the boot-timeapp-epochevent on TDX, GCP TDX and AWS NitroTPM, or the MrConfigV3 pin on SEV-SNP. The requester cannot choose it, and the request format is unchanged. Where nothing records it (older guests, Nitro Enclave) the current epoch is used as before. A running CVM therefore renews certificates under its boot epoch's policy row; once that row is revoked, renewal is denied until it restarts. The KMS writes the epoch into a newPHALA_RATLS_APP_EPOCHextension (OID1.3.6.1.4.1.62397.1.10), whichCertExt::get_app_epochreads. This replaces feat(kms): stamp key epochs in issued certificates #1645.app_epoch, in/verifyand in--verify-certmode.Verification
cargo test -p dstack-types -p ra-tls -p cert-client -p dstack-vmm -p dstack-util -p dstack-kms --all-featurescargo clippyon the changed crates, andcargo check --workspace --all-features --testspytest dstack/vmm/src/tests/test_vmm_cli.py,npm testindstack/vmm/ui, andpreklake buildinformal/