Skip to content
Open
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
14 changes: 9 additions & 5 deletions docs/security/security-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dstack supports NVIDIA H100, H200, and B200 GPUs in confidential compute mode fo

### How It Works

GPUs are passed through via VFIO to the TEE-protected CVM. Before key provisioning, `dstack-util setup` inventories every VGA/3D-controller PCI function, rejects non-NVIDIA display devices, and runs NVIDIA's local `nvattest` verifier over every NVIDIA-driver-visible GPU with a fresh nonce. dstack does not ship or pass a custom relying-party policy to this command; nvattest's built-in appraisal still applies. The complete JSON result (`result_code`, `result_message`, `claims`, and `detached_eat`) is saved at `/run/nvidia-gpu-attestation/attestation.out`.
GPUs are passed through via VFIO to the TEE-protected CVM. Before key provisioning, `dstack-util setup` inventories every VGA/3D-controller PCI function, rejects non-NVIDIA display devices, and runs NVIDIA's local `nvattest` verifier over every NVIDIA-driver-visible GPU with a fresh nonce. On PPCIe it also appraises the NVSwitches. Without a collateral proxy, dstack uses nvattest's built-in appraisal. The complete boot record is saved at `/run/nvidia-gpu-attestation/attestation.out`.

An application may additionally set `requirements.gpu_policy` to an object with the following deny-unknown-fields schema:

Expand Down Expand Up @@ -114,7 +114,9 @@ The policy digest is remotely verifiable on each supported platform, but through
- **AWS NitroTPM:** the same `gpu-policy-hash` event is extended into non-resettable SHA384 PCR14. Replay the PCR14 event chain against the signed NitroTPM Attestation Document, then compare the payload with the expected digest.
- **AMD SEV-SNP:** there is no quote-bound runtime event register in the current stack. The signed SNP report's `HOST_DATA` binds the exact MrConfigV3 document, whose `compose_hash` covers the app-compose file and so the policy in it; the guest stops boot if that file does not match. GPU launches also put the digest in `MrConfigV3.gpu_policy_hash`. Verify the SNP report and `HOST_DATA` binding, then compare the policy, or the field when present, with the expected one.

For every NVML-enumerated GPU, dstack calls `Device::is_cc_enabled()` and `Device::is_cc_dev_mode_enabled()` and requires the NVML device count to match the expected GPU count. CC must always be ON; DevTools must be OFF unless the measured policy explicitly permits it. The typed claim checks always require `measres == "success"`; by default they also require `dbgstat == "disabled"` and `secboot == true`, with the latter two checks controlled by their explicit opt-ins. Only after the default appraisal, typed claim checks, optional Rego policy, and per-device NVML checks succeed does dstack call `Device::set_confidential_compute_state(true)` to set the GPU ready state. The dstack CPU/guest boot chain is verified independently through measured boot; a GPU claim named `secboot` refers to the GPU appraisal, not UEFI Secure Boot in the CVM.
The NVML GPU count must match the guest PCI inventory. The ordinary CC path requires NVML to report CC ON, and every GPU that reports a signed mode must report a CC mode (`spt` or `mpt`). On HGX H200, an 8-GPU, 4-NVSwitch Protected PCIe (PPCIe) launch can instead pass with CC OFF. NVML only selects this path; the decision rests on signed evidence. dstack verifies fresh GPU and NVSwitch claims against the same nonce, requires every GPU's signed mode to be `ppcie` and every NVSwitch's signed lock status to be locked, and checks that the device identities are distinct within each set and that the claims describe the expected fabric topology, following [NVIDIA's PPCIe verification flow](https://docs.nvidia.com/attestation/attestation-client-tools-ppcie-sdk-cpp/latest/ppcie_architecture.html). The image's `nvattest` is patched to expose the two signed fields: `x-nvidia-gpu-mode` from the GPU report's `FEATURE_FLAG`, and `x-dstack-switch-lock-status` from the NVSwitch report's `SWITCH_LOCK_STATUS`. Host-reported NVML and NSCQ state is not evidence.

DevTools must be OFF unless the measured policy explicitly permits it. The typed claim checks always require `measres == "success"`; by default they also require `dbgstat == "disabled"` and `secboot == true` on every appraised device, including switches. The latter two checks have explicit opt-ins. Application Rego receives the GPU claims only, in both modes. dstack sets the GPU ready state only after the boot checks and optional Rego policy succeed. The dstack CPU/guest boot chain is verified independently through measured boot; `secboot` refers to NVIDIA's appraisal, not UEFI Secure Boot in the CVM.

### Dual Attestation

Expand Down Expand Up @@ -156,18 +158,20 @@ mode enabled. `dbgstat` and `secboot` summarize the NVIDIA-signed claims:
if every device reports secure boot. The complete per-device claims remain in
the boot-time evidence committed by `evidence_sha256`.

`/v1/Attest` returns that complete boot-time `nvattest` record when the request sets `include_boottime_gpu_evidence`; it runs no new attestation. `AttestResponse.boottime_gpu_evidence` is a list of `GpuEvidenceBundle`, each carrying `vendor`, `format`, and `evidence`. The boot record is the bundle whose `vendor` is `nvidia` and whose `format` is `nvidia-nvattest-boottime-json-v1`; its `evidence` is hex-encoded bytes that decode to the exact UTF-8 nvattest output as the agent read it from disk. The other format, `nvidia-nvattest-collect-evidence-json-v1`, comes from `/v1/AttestGpu` and is fresh evidence against a caller nonce; the two are deliberately distinct because a verifier for one does not appraise the other. To bind the API result to TDX evidence: verify the quote, replay the event log to the quote's RTMR3, require exactly one pre-`system-ready` `gpu-attestation` event, decode its JSON payload, select the boot-time bundle by `format`, and compare `evidence_sha256` with `SHA-256(hex_decode(bundle.evidence))`. Hash the decoded bytes, not the JSON string as returned and not a re-serialized form: parsing and re-serializing changes the digest and breaks the comparison. Only after this comparison should the verifier inspect the returned claims. This exact-byte comparison includes any whitespace or trailing newline in the decoded record.
`/v1/Attest` returns that complete boot-time `nvattest` record when the request sets `include_boottime_gpu_evidence`; it runs no new attestation. `AttestResponse.boottime_gpu_evidence` is a list of `GpuEvidenceBundle`, each carrying `vendor`, `format`, and `evidence`. The boot record is the bundle whose `vendor` is `nvidia` and whose `format` is `nvidia-nvattest-boottime-json-v1`; its `evidence` is hex-encoded bytes that decode to the exact boot record as the agent read it from disk (the `nvattest` output for ordinary CC). The other format, `nvidia-nvattest-collect-evidence-json-v1`, comes from `/v1/AttestGpu` and is fresh evidence against a caller nonce; the two are deliberately distinct because a verifier for one does not appraise the other. To bind the API result to TDX evidence: verify the quote, replay the event log to the quote's RTMR3, require exactly one pre-`system-ready` `gpu-attestation` event, decode its JSON payload, select the boot-time bundle by `format`, and compare `evidence_sha256` with `SHA-256(hex_decode(bundle.evidence))`. Hash the decoded bytes, not the JSON string as returned and not a re-serialized form: parsing and re-serializing changes the digest and breaks the comparison. Only after this comparison should the verifier inspect the returned claims. This exact-byte comparison includes any whitespace or trailing newline in the decoded record.

For PPCIe, the event has `version: 4` and `cc_mode: "ppcie"`; `devices` still counts GPUs. Its debug and secure-boot summaries cover both GPUs and NVSwitches. The boot evidence uses the same bundle tag. After verifying the digest, select the record layout using the measured event version and `cc_mode`, not by inspecting unverified evidence. For PPCIe the decoded record is a JSON object with `gpu_output` and `nvswitch_output` containing hex-encoded exact stdout from the two local `nvattest` runs. Ordinary CC launches keep the version 3 event and raw `nvattest` output.

A verifier must replay the measured event log, require exactly one `gpu-policy-hash` event immediately after `compose-hash`, and compare its 32-byte payload with the expected policy digest (`SHA-256(JCS({}))` for the omitted/default policy). When MrConfigV3 includes `gpu_policy_hash`, it must match the same digest. When GPU protection is required, the verifier must also require exactly one pre-`system-ready` `gpu-attestation` event with `devices > 0` and, when applicable, the expected deployment count. The raw `attestation.out` file is not trusted by itself; if it is supplied for inspection, its digest must match the `gpu-attestation` event.

### GPU Threat Model and Lifetime

The GPU gate assumes a malicious host/VMM and untrusted host-provided PCI topology, while trusting the CPU TEE, the measured dstack guest/kernel, NVIDIA hardware/firmware roots, and the cryptography used by both attestation chains. Availability is out of scope.

The events make the following **boot-time** statement: immediately before key provisioning, all attached VGA/3D PCI functions were NVIDIA devices, their count matched the NVML inventory, nvattest returned one fresh successfully appraised claim for each device, the measured application policy accepted those claims and GPU state when present, every enumerated GPU passed the CC/DevTools NVML checks, and setting the GPU ready state succeeded. This closes these cases:
The events make the following **boot-time** statement: immediately before key provisioning, all attached VGA/3D PCI functions were NVIDIA devices, their count matched the NVML inventory, nvattest returned one fresh successfully appraised claim for each device, the measured application policy accepted those claims and GPU state when present, the NVML protection-mode and DevTools checks passed (and on PPCIe, the four NVSwitches also passed the switch-state, evidence, and fabric checks), and setting the GPU ready state succeeded. This closes these cases:

- A GPU-less launch cannot be presented as a GPU-verified launch because it has no `gpu-attestation` event.
- A mixed launch cannot attest only its TEE-capable subset. Non-NVIDIA display GPUs are rejected, and the sysfs, NVML, and nvattest claim counts must all agree. A non-CC NVIDIA GPU either prevents evidence collection/appraisal or causes the default appraisal, application policy, or CC-state check to fail.
- A mixed launch cannot attest only its TEE-capable subset. Non-NVIDIA display GPUs are rejected, and the sysfs, NVML, and nvattest claim counts must all agree. A CC-off NVIDIA GPU outside an appraised PPCIe fabric cannot pass the gate.
- Copying another CVM's result into a file or `report_data` does not work. Only measured pre-application code can place the event before `system-ready`, and event-log replay binds it to the quoted RTMR/PCR value.

This is **not a lifetime or physical co-location guarantee**. After `system-ready`, an application with sufficient guest privileges can unload the NVIDIA driver, and a malicious host may attempt PCI hot-remove/replacement or proxy GPU traffic. The boot event remains a true historical statement but does not prove that the same device is still attached. dstack also cannot rule out a live relay/cuckoo attack to a genuine remote GPU: current Hopper/Blackwell deployments do not provide a CPU-TEE-verifiable TEE-I/O/TDISP device binding. Applications that mutate the driver or PCI topology are outside this guarantee; higher-assurance deployments must prevent that behavior and re-attest before using a newly initialized GPU; the guest-agent `/v1/AttestGpu` API does that re-check against a caller-chosen nonce, returning bundles tagged `nvidia-nvattest-collect-evidence-json-v1` rather than the boot-time format. Being an NVIDIA report, its result is subject to the same relay caveat as any attestation-time GPU sample: it establishes that a genuine CC-enabled GPU is reachable and responsive now, not that the device is bound to this TD, so it must not be forwarded to a remote relying party as proof of GPU possession.
Expand Down
Loading
Loading