Skip to content

fix(kms): hash the SEV-SNP chip_id into device_id on the key-release path - #1247

Merged
kvinwang merged 2 commits into
nextfrom
fix/kms-authorization-parity
Sep 24, 2026
Merged

kvinwang merged 2 commits into
nextfrom
fix/kms-authorization-parity

Conversation

@kvinwang

@kvinwang kvinwang commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Rescoped to a single change; the other three are split out into #1343, #1344 and #1345.

The SEV-SNP key-release path was the only site in the tree emitting a raw chip_id as device_id:

site value width
kms/src/main_service/amd_attest.rs (key release) verified_chip_id.to_vec() 64
kms/src/onboard_service.rs (GetAttestationInfo) Sha256::digest(&raw_device_id) 32
dstack-attest/src/attestation.rs (SNP verifier) sha256(parsed.chip_id) 32
dstack-attest/src/attestation.rs (TDX) sha256(get_devide_id()) 32
verifier/src/types.rs app_info.device_id 32

So the id an operator registers can never equal the id GetAppKey presents. auth-eth-bun's boundedHex(32, 'device ID') and auth-eth's hex(32, …) reject a 128-hex-char value with HTTP 400 before it reaches the chain; auth-simple's unbounded z.string() accepts it and silently never matches. Device-restricted SEV-SNP key release could not succeed.

The repo's own tests already asserted both answers for the same chip_id = [0xab; 64] fixture — onboard_service.rs expected the sha256, main_service.rs expected the raw 64 bytes. GetAttestationInfo now reports boot_info.device_id directly instead of re-hashing the raw id, so the registered and presented ids share one derivation by construction.

No derived key changes. device_id is authorization-only and never a KDF input — the only KDF contexts are app_id and instance_id. The three tests that pinned 64 bytes pinned the bug and are updated. Blast radius is bounded by sev_snp_key_release = false being opt-in.

One compat note: auth-simple is the only backend that ever accepted the raw form, so a config that allowlisted the 128-hex-char chip id has to be re-registered with the 32-byte hash. Such a config could not have matched anything before this change either.

cargo test -p dstack-kms --all-features: 55 passed. cargo clippy -p dstack-kms -- -D warnings --allow unused_variables: clean.

@kvinwang
kvinwang force-pushed the fix/kms-authorization-parity branch from f5727fc to eb78259 Compare September 24, 2026 03:38
@kvinwang kvinwang changed the title fix(kms): SEV-SNP key release presents a device id nothing can match, and an empty device allowlist allows everything fix(kms): hash the SEV-SNP chip_id into device_id on the key-release path Sep 24, 2026
Reuse boot_info.device_id instead of re-hashing the raw device id, so the
id operators register and the id key release presents come from a single
derivation. This makes the dedicated parity test redundant.
@kvinwang
kvinwang merged commit 0a52e8d into next Sep 24, 2026
11 checks passed
@kvinwang
kvinwang deleted the fix/kms-authorization-parity branch September 24, 2026 04:32
kvinwang added a commit that referenced this pull request Sep 25, 2026
…ed cases

#1247 hashes the SNP chip_id into device_id, #1343 requires a 20-byte SNP
app_id, #1302 derives the Nitro Enclave device_id from PCR4, and #1303 gates
Nitro Enclave key release. Record the expected results in the capability-
blocked platform cases, and note in tc-kms-keys-certs-003 that public
handover stays on by default (#1307).

Signed-off-by: Kevin Wang <wy721@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant