Skip to content

fix(attest): derive Nitro Enclave device_id from the EC2 instance id - #1302

Merged
kvinwang merged 1 commit into
nextfrom
fix/nitro-enclave-device-id
Sep 22, 2026
Merged

kvinwang merged 1 commit into
nextfrom
fix/nitro-enclave-device-id

Conversation

@kvinwang

@kvinwang kvinwang commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

GetDeviceId for DstackVerifiedReport splits an NSM module ID on the first hyphen:

report.module_id.split_once('-').map(|(id, _)| id.as_bytes().to_vec())

For the currently observed Nitro Enclave module ID shape, the extracted value is the literal string "i" for every enclave. AppInfo::device_id is sha256(get_devide_id()), so every Nitro Enclave reports the same device ID. Consequently, DstackApp.isAppAllowed cannot use allowedDeviceIds to distinguish parent EC2 instances.

The committed real capture dstack-attest/tests/nitro_attestation.bin demonstrates the bug through the full COSE-verified path.

Fix

Use attested PCR4 as the Nitro Enclave device identity. AWS documents PCR4 as the SHA-384 measurement of the parent EC2 instance ID. Unlike parsing module_id, this uses an explicitly defined attestation field and does not depend on the opaque hypervisor module ID current string representation.

NitroPcrs now retains PCR4 from the signature-verified PCR map, and GetDeviceId returns that measurement. The real attestation fixture asserts its expected PCR4 and the serialized report snapshot now includes it.

Verification

  • cargo fmt --all -- --check
  • git diff --check
  • Verified the committed real attestation contains PCR4 7b3574ad9b7e88ec8335e8ce967315fac77218441e97eea9795de704d7f2678d0b298ecda39b544c1689669f48cba5e8, matching SHA384(48 zero bytes || "i-0827e799ec9232d44")

The complete GitHub Actions suite passed on the previous revision; the final parser-path hardening is being revalidated by CI.

Deployment note

This changes device_id for Nitro Enclave deployments. Any DstackApp contract with allowAnyDevice = false must add the new value before its enclaves can boot against an upgraded KMS. The new contract value is sha256(PCR4). Apps with allowAnyDevice = true are unaffected.

Nothing meaningful is invalidated by the change: the old value carried no per-instance information, so no existing allowlist entry was distinguishing devices.

No other platform is affected.

@kvinwang
kvinwang force-pushed the fix/nitro-enclave-device-id branch 2 times, most recently from b372e3a to 91af2bc Compare September 22, 2026 01:20
@kvinwang
kvinwang force-pushed the fix/nitro-enclave-device-id branch from 91af2bc to 5b6e294 Compare September 22, 2026 01:32
@kvinwang
kvinwang merged commit 3abd232 into next Sep 22, 2026
11 checks passed
@kvinwang
kvinwang deleted the fix/nitro-enclave-device-id branch September 22, 2026 04:26
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>
kvinwang added a commit that referenced this pull request Sep 25, 2026
#1302 added a library test and #1279 an SEV-SNP integration test, so the
pinned counts no longer matched. Update them and require the empty-report
test by name.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 8, 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>
kvinwang added a commit that referenced this pull request Nov 8, 2026
#1302 added a library test and #1279 an SEV-SNP integration test, so the
pinned counts no longer matched. Update them and require the empty-report
test by name.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 8, 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>
kvinwang added a commit that referenced this pull request Nov 8, 2026
#1302 added a library test and #1279 an SEV-SNP integration test, so the
pinned counts no longer matched. Update them and require the empty-report
test by name.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 10, 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>
kvinwang added a commit that referenced this pull request Nov 10, 2026
#1302 added a library test and #1279 an SEV-SNP integration test, so the
pinned counts no longer matched. Update them and require the empty-report
test by name.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 11, 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>
kvinwang added a commit that referenced this pull request Nov 11, 2026
#1302 added a library test and #1279 an SEV-SNP integration test, so the
pinned counts no longer matched. Update them and require the empty-report
test by name.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 11, 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>
kvinwang added a commit that referenced this pull request Nov 11, 2026
#1302 added a library test and #1279 an SEV-SNP integration test, so the
pinned counts no longer matched. Update them and require the empty-report
test by name.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 16, 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>
kvinwang added a commit that referenced this pull request Nov 16, 2026
#1302 added a library test and #1279 an SEV-SNP integration test, so the
pinned counts no longer matched. Update them and require the empty-report
test by name.

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