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
17 changes: 17 additions & 0 deletions docs/measurement_allowlists.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,21 @@ gateway), Tinfoil and Chutes.
| `476a2997c62bccc7...` | 2.0.08 | Granite Rapids | shared list |
| `685f891ea5c20e8f...` | 2.0.02 | Granite Rapids | shared list |
| `2d2de102461684f1...` | 2.0.18 | Granite Rapids / Clearwater Forest | shared list |
| `eddfa0c1750b39ba...` | 2.0.20 | Granite Rapids / Clearwater Forest | shared list (see below) |
| `5b38e33a6487958b...` | 1.5.06 | Sapphire/Emerald Rapids | Chutes only |
| `346bc77a1846cac2...` | 1.5.28 | Sapphire/Emerald Rapids | Chutes only |
| `ab62561a173acbd1...` | 1.5.34 | Sapphire/Emerald Rapids | Chutes only |

For 2.0.20, Intel's hash table and the release notes of `TDX_MODULE_2.0.20`
give `57a1a66f3704887a...`. The SHA-384 of the signed binary
`separate_files/2.0/2.0.20/tdx_module_2.0.20.bin` in
`intel/confidential-computing.tdx.tdx-module.binaries` (commit `73b2a66e`),
and the MRSEAM in its sigstruct at offset 900, are `eddfa0c1750b39ba...`.
The same two methods give the table's value for 2.0.08. Phala Cloud's
`deepseek/deepseek-v4.1-flash-1017` model CVM reported `eddfa0c1...` on
2026-11-19. The shared list has the value of the binary. Intel's table is
the source for the other rows.

A reasonable policy is to allow the set of non-deprecated module versions for
your target platform family. This does not require provider cooperation.

Expand Down Expand Up @@ -245,6 +256,12 @@ dstack-mr measure
| `b24d3b24e9e3c160...` | dstack-nvidia-0.5.4.1 |
| `f06dfda6dce1cf90...` | dstack-nvidia-0.5.5 |
| `df4d77c857de652b...` | dstack-nvidia-0.5.11 and 0.5.12 |
| `83baf004a06c83f6...` | dstack-0.6.3, 0.6.4 and 0.6.5 |

The dstack 0.6 value is the TDX `MRTD` that dstack publishes for each
image: `image-hashes.txt` of the `mkosi-os-v0.6.3` and `mkosi-os-v0.6.4`
releases, and the release notes of `mkosi-os-v0.6.5`, at
`github.com/Dstack-TEE/dstack/releases`.

For dstack-nvidia-0.5.12, RTMR1 and RTMR2 are not allowed until they are
computed with `mk-image-mr` from meta-dstack on the release files: no
Expand Down
16 changes: 13 additions & 3 deletions docs/providers/phalacloud/phalacloud_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,17 @@ one is not pinned:
5. The GPU evidence, verified locally with the session nonce, without NRAS:
the certificate chain and SPDM signature of every GPU must verify, as for
`nvidia_signature`.
6. For the Phala model CVM, the compose binding (MRConfigID) and the
event-log replay of RTMR0-3.
6. For the Phala model CVM, the event-log replay of RTMR0-3 and the
compose binding. An MRConfigID of version 1 (dstack 0.5) is 0x01 and
sha256(app_compose). One of version 3 (dstack 0.6) is 0x03 and the hash
of a launch document that the quote does not carry. teep builds the
document that the dstack VMM builds: compose_hash, key_provider,
key_provider_id and the init script hashes from app_compose; app_id,
instance_id and gpu_policy_hash from the RTMR3 events of the replayed
log (`attestation.VerifyComposeBindingV3`). app_compose must name
`key_provider` and give `manifest_version` as a string. dstack also
reads a compose without `key_provider` (from `kms_enabled`) or with a
numeric version; teep refuses those.

The parts of a session's evidence must have exactly the members that teep
reads. For a Chutes bundle these include the newer members of the Chutes
Expand Down Expand Up @@ -501,7 +510,8 @@ stream failed.
[session tests](../../../internal/provider/aci/session_test.go), and
`TestPinSessions` and `TestPinSessionsRefuses` in
[pin tests](../../../internal/provider/aci/pin_test.go).
- `TestSessionAuditPhalaModelCVM`, `TestSessionAuditChutes` and
- `TestSessionAuditPhalaModelCVM`, `TestSessionAuditPhalaModelCVMDstack063`,
`TestComposeBindingV3Refuses`, `TestSessionAuditChutes` and
`TestSessionAuditRefuses` in
[session audit tests](../../../internal/provider/phalacloud/session_audit_test.go);
`TestFetchSessionsSelectsBoundedBundles` and `TestSelectBundles` in
Expand Down
108 changes: 108 additions & 0 deletions internal/attestation/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"crypto/sha256"
"crypto/subtle"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"log/slog"
"maps"
"regexp"
"strconv"
"strings"

"github.com/13rac1/teep/internal/jsonstrict"
Expand Down Expand Up @@ -40,6 +42,12 @@ func VerifyComposeBinding(appCompose string, mrConfigID []byte) error {
hex.EncodeToString(mrConfigID),
)
}
return checkAppComposeObject(appCompose)
}

// checkAppComposeObject requires appCompose, whose hash the quote binds, to
// be read the same way by teep and dstack.
func checkAppComposeObject(appCompose string) error {
// The quote binds these bytes, but teep reads the images from the
// docker_compose_file member. An app_compose object that teep and
// dstack read differently (a duplicate member, or a member that
Expand Down Expand Up @@ -259,3 +267,103 @@ func MergeComposeDigests(model, gateway ComposeDigests) (allDigests []string, di
}
return allDigests, digestToRepo
}

// mrConfigV3 is the launch document that a dstack 0.6 VMM binds into a TDX
// MR_CONFIG_ID of version 3 (MrConfigV3 in dstack-types mr_config.rs). The
// members are in sorted order and every value is ASCII, so json.Marshal
// writes the RFC 8785 form that dstack hashes.
type mrConfigV3 struct {
AppID string `json:"app_id"`
ComposeHash string `json:"compose_hash"`
GPUPolicyHash string `json:"gpu_policy_hash,omitempty"`
InitScriptHashes *[]string `json:"init_script_hashes,omitempty"`
InstanceID string `json:"instance_id,omitempty"`
KeyProvider string `json:"key_provider"`
KeyProviderID string `json:"key_provider_id,omitempty"`
Version int `json:"version"`
}

// appComposeV3 holds the app_compose members that the VMM copies into the
// MrConfigV3 document.
type appComposeV3 struct {
KeyProvider string `json:"key_provider"`
KeyProviderID string `json:"key_provider_id,omitempty"`
ManifestVersion string `json:"manifest_version"`
InitScript []string `json:"init_script,omitempty"`
}

// VerifyComposeBindingV3 checks a TDX MRConfigID of version 3: 0x03, then
// sha256("dstack-mr-config-v3:" || 0x00 || document), then 15 zero bytes.
// The quote carries no document, so teep builds the one that the dstack
// VMM builds (prepare_mr_config_v3 in dstack vmm/src/app/mr_config.rs):
// compose_hash is sha256(appCompose); key_provider, key_provider_id and,
// from manifest version 3, the sha256 of each init script come from
// appCompose; app_id, instance_id and, for a launch with GPUs,
// gpu_policy_hash come from the RTMR3 events. The caller must have checked
// that events reproduce the RTMRs of the quote.
func VerifyComposeBindingV3(appCompose string, events []EventLogEntry, gpu bool, mrConfigID []byte) error {
var ac appComposeV3
_, missing, err := jsonstrict.Unmarshal([]byte(appCompose), &ac)
if err != nil {
return fmt.Errorf("app_compose: %w", err)
}
if len(missing) > 0 {
return fmt.Errorf("app_compose: missing members %q", missing)
}
manifest, err := strconv.Atoi(ac.ManifestVersion)
if err != nil {
return fmt.Errorf("app_compose manifest_version: %w", err)
}
composeHash := sha256.Sum256([]byte(appCompose))
doc := mrConfigV3{ComposeHash: hex.EncodeToString(composeHash[:]), KeyProvider: ac.KeyProvider, KeyProviderID: ac.KeyProviderID, Version: 3}
if manifest >= 3 {
hashes := make([]string, len(ac.InitScript))
for i, script := range ac.InitScript {
sum := sha256.Sum256([]byte(script))
hashes[i] = hex.EncodeToString(sum[:])
}
doc.InitScriptHashes = &hashes
}
if doc.AppID, err = runtimeEventPayload(events, "app-id"); err != nil {
return err
}
if doc.InstanceID, err = runtimeEventPayload(events, "instance-id"); err != nil {
return err
}
if gpu {
if doc.GPUPolicyHash, err = runtimeEventPayload(events, "gpu-policy-hash"); err != nil {
return err
}
}
document, err := json.Marshal(doc)
if err != nil {
return fmt.Errorf("MrConfigV3 document: %w", err)
}
digest := sha256.Sum256(append([]byte("dstack-mr-config-v3:\x00"), document...))
expected := make([]byte, 48)
expected[0] = 3
copy(expected[1:], digest[:])
if subtle.ConstantTimeCompare(mrConfigID, expected) != 1 {
return fmt.Errorf("MRConfigID %s does not bind the MrConfigV3 document %s", hex.EncodeToString(mrConfigID), document)
}
return checkAppComposeObject(appCompose)
}

// runtimeEventPayload returns the payload of the one RTMR3 dstack runtime
// event with this name, as lowercase hex.
func runtimeEventPayload(events []EventLogEntry, name string) (string, error) {
var found [][]byte
for _, e := range events {
if e.IMR == 3 && e.EventType == DstackRuntimeEventType && e.Event == name {
payload, err := hex.DecodeString(e.EventPayload)
if err != nil {
return "", fmt.Errorf("%s event payload: %w", name, err)
}
found = append(found, payload)
}
}
if len(found) != 1 {
return "", fmt.Errorf("event log has %d %s events, want 1", len(found), name)
}
return hex.EncodeToString(found[0]), nil
}
10 changes: 9 additions & 1 deletion internal/attestation/dstack_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,25 @@ var dstackMRSEAMAllow = map[string]struct{}{
"489e585f1c54bc5a02066c8c6ec21619ff0334ec6f21e07e2a35202c59183789c8057e7d97dd591bb08314b185819e72": {},
// TDX module 2.0.18 — Granite Rapids / Clearwater Forest (Intel, TDX Module Releases and Hashes)
"2d2de102461684f14c8d0984a09d895e3e9e15944ce020a03b977e1f114d5e1ed32ef666a47fd19a5851b3800eda3afa": {},
// TDX module 2.0.20 — Granite Rapids / Clearwater Forest: sha384 of the
// signed binary and the hash in its sigstruct (Intel, tdx-module.binaries
// 73b2a66e). Intel's hash table lists 57a1a66f... for 2.0.20.
"eddfa0c1750b39ba6c9b039c579a5039baea307f8290fc5e3636d70e6001749dc95a368b9d8a9c50c84d1c22b5642d3c": {},
}

// dstackMRTDAllow contains the TD virtual firmware measurement hashes for
// known dstack-nvidia image versions.
// known dstack and dstack-nvidia image versions.
var dstackMRTDAllow = map[string]struct{}{
// dstack-nvidia-0.5.4.1 (os_image_hash 9b69bb...)
"b24d3b24e9e3c16012376b52362ca09856c4adecb709d5fac33addf1c47e193da075b125b6c364115771390a5461e217": {},
// dstack-nvidia-0.5.5 (os_image_hash da9a3d...)
"f06dfda6dce1cf904d4e2bab1dc370634cf95cefa2ceb2de2eee127c9382698090d7a4a13e14c536ec6c9c3c8fa87077": {},
// dstack-nvidia-0.5.11 (os_image_hash a6eafc...); 0.5.12 has the same MRTD
"df4d77c857de652bd0fafa343a2026b51071ee03773d076d283abf1a7d36ff91ffa279ee4a617ac664f7e2a2c8d5891b": {},
// dstack-0.6.3, 0.6.4 and 0.6.5 (os_image_hash 38a6f9..., feff36...,
// 4771a2...): the TDX MRTD that the mkosi-os-v0.6.3, v0.6.4 and v0.6.5
// releases publish
"83baf004a06c83f6371d4d9e19c8bb1ead734ba7696e56d6b52271011394a6f24efecc27af3b5c1da41594dbfa706e97": {},
}

// DstackBaseMeasurementPolicy returns a MeasurementPolicy with the shared
Expand Down
8 changes: 4 additions & 4 deletions internal/attestation/dstack_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
)

func TestDstackMRSEAMAllow(t *testing.T) {
if len(dstackMRSEAMAllow) != 7 {
t.Errorf("dstackMRSEAMAllow has %d entries, want 7", len(dstackMRSEAMAllow))
if len(dstackMRSEAMAllow) != 8 {
t.Errorf("dstackMRSEAMAllow has %d entries, want 8", len(dstackMRSEAMAllow))
}
// TDX modules 1.5.24 and 2.0.18, from Intel's table of module hashes.
for _, tc := range []struct{ name, value string }{
Expand All @@ -32,8 +32,8 @@ func TestDstackMRSEAMAllow(t *testing.T) {
}

func TestDstackMRTDAllow(t *testing.T) {
if len(dstackMRTDAllow) != 3 {
t.Errorf("dstackMRTDAllow has %d entries, want 3", len(dstackMRTDAllow))
if len(dstackMRTDAllow) != 4 {
t.Errorf("dstackMRTDAllow has %d entries, want 4", len(dstackMRTDAllow))
}
for h := range dstackMRTDAllow {
b, err := hex.DecodeString(h)
Expand Down
19 changes: 12 additions & 7 deletions internal/integration/phalacloud_canonical_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// TestVerifyRun_PhalaCloudCanonical_Fixture replays a live Phala Cloud
// capture of 2026-11-01 of the canonical ACI/1 report (/v1/aci/attestation),
// capture of 2026-11-19 of the canonical ACI/1 report (/v1/aci/attestation),
// the attested sessions of the model, and the pinned E2EE test exchange
// through verify.Run with the production policy. The gateway evidence, the
// ACI/1 §3.2 statement binding of the client nonce, the key custody, the TLS
Expand Down Expand Up @@ -84,13 +84,18 @@ func TestVerifyRun_PhalaCloudCanonical_Fixture(t *testing.T) {
assertPinnedSessions(t, &env, report)
}

// The capture's pinned sessions: one Phala model CVM session and the three
// Chutes sessions of the one Chutes bundle that the evidence limit allowed.
// The capture's pinned sessions: one Phala model CVM session and the Chutes
// sessions of the two Chutes bundles that the evidence limit allowed.
var fixtureSessionIDs = []string{
"f82e2a6b603a3d0b1abe395f979440f0da44a425b238cfcb5354f20906f43cc7",
"18aa6d5d8b108534e293deb250cb7b2f99b5790b10a500d4d5066647bee1dcf4",
"429596d33189b26631b7c88daaac1dae4ed05c3eff005662b21573cdd86b3551",
"68642a9de9504d777299fee0b759f5cc01a2080cce6a00d8fb63e8542f27031b",
"2fe1110a3a65d1ead7e616b6d151dbfc1f7fa1253492531f9cbaee543d2055d7",
"086ad731d8a859de4965ca53f1b42c27ef8d7096fd989e14975f2f6f1b6c8d49",
"0b9879c744ca37a40964498f569fefe3f03ca449c4d97fa83c72080ad7040681",
"c1384c8d7b821b5ed5e56b0d688f90f0dc06a7a09e727be534054998a03bdd22",
"cb8794ee3b8e08841968204de592df3813fe8b3d12f48737e1192070cc2d2663",
"f4365c6fa1f03f4b1e7451f86322a7497245c8cb7c0630f0b86318d4a6c56438",
"fd56d483c1666606840210a6645d4505c919d212c0a42be028b2ac22de65b0c2",
"902014e173e2806715b4e11102ccd5d3fcaec31035d0b6a8198b3d068afe42cc",
"c1288e4dbc46d4739b5934d9ee281754747485367b884b85a0951f800cfa672c",
}

// assertPinnedSessions requires the audit to pin exactly the sessions of the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"provider": "phalacloud",
"model": "qwen/qwen3.8-27b",
"nonce_hex": "557795a30c4cb185cdea0585d1a45fdfe4a56c95c239d572a91988a97b26a3eb",
"captured_at": "2026-11-13T07:32:54.774755556Z",
"duration_ms": 14563,
"nonce_hex": "263ebcc8becde5acb63514e1d571453a7d901e2124675623c670831a7c3921a7",
"captured_at": "2026-11-19T20:08:56.587116387Z",
"duration_ms": 13996,
"e2ee": {
"attempted": true,
"detail": "E2EE v2 secp256k1: 8 encrypted fields decrypted across 11 chunks",
"detail": "E2EE v2 secp256k1: 14 encrypted fields decrypted across 17 chunks",
"key_type": "ecdsa",
"receipt": {
"detail": "receipt verified, including the request hash"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Tier 2: Binding & Crypto
- nvidia_nonce_client_bound no NVIDIA payload; nonce not checked [ALLOWED]
- nvidia_nras_verified no EAT payload; NRAS not applicable [ALLOWED]
✓ e2ee_capable enclave public key is valid secp256k1 uncompressed point; E2EE key exchange possible [ALLOWED]
✓ e2ee_usable E2EE v2 secp256k1: 8 encrypted fields decrypted across 11 chunks [ALLOWED]
✓ e2ee_usable E2EE v2 secp256k1: 14 encrypted fields decrypted across 17 chunks [ALLOWED]
✓ aci_key_custody keyset digest matches; signing key is a keyset e2ee key; e2ee key custody chain verified to accepted KMS root (02a335aea3df11d4...) for app 89c51ab856bee41e... [ENFORCED]
✗ aci_backend_named the attestation binds no backend for the requested model [ALLOWED]
✓ aci_session_verified 4 attested sessions pinned: genuine TDX and GPU with allowed MRTD/MRSEAM, workload policy not checked (14 refused; first: not fetched: the session evidence limit of one verification is reached) [ENFORCED]
✓ aci_session_verified 9 attested sessions pinned: genuine TDX and GPU with allowed MRTD/MRSEAM, workload policy not checked (7 refused; first: not fetched: the session evidence limit of one verification is reached) [ENFORCED]
✓ aci_receipt_verified receipt verified, including the request hash [ENFORCED]

Tier 3: Supply Chain & Channel Integrity
Expand Down Expand Up @@ -58,9 +58,9 @@ Tier 4: Gateway Attestation
✗ gateway_tee_measurement gateway MRTD not in policy allowlist: 7fe60787222bd394... [ALLOWED]
- gateway_tee_hardware_config no gateway RTMR0 measurement policy configured [ALLOWED]
- gateway_tee_boot_config no gateway RTMR1/RTMR2 measurement policy configured [ALLOWED]
✓ gateway_tee_reportdata_binding REPORTDATA binds the keyset digest sha256:338c049d02ba7545... and the client nonce (ACI/1 §3.2) [ENFORCED]
✓ gateway_tee_reportdata_binding REPORTDATA binds the keyset digest sha256:31bfd7f9a90aba90... and the client nonce (ACI/1 §3.2) [ENFORCED]
✓ gateway_compose_binding gateway sha256(app_compose) matches MRConfigID [ENFORCED]
- gateway_cpu_id_registry gateway Proof of Cloud query failed: stage 1 POST to https://trust-server.scrtlabs.com: Post "https://trust-server.scrtlabs.com/get_jwt": tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2026-11-13T07:32:46Z is after 2026-09-07T23:59:59Z [ALLOWED]
- gateway_cpu_id_registry gateway Proof of Cloud query failed: stage 1 POST to https://trust-server.scrtlabs.com: Post "https://trust-server.scrtlabs.com/get_jwt": tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2026-11-19T14:08:49-06:00 is after 2026-09-07T23:59:59Z [ALLOWED]
✓ gateway_event_log_integrity gateway event log replayed (30 entries), all 4 RTMRs match quote [ENFORCED]
— gateway_tee_tcb_current TCB minimums for a TDX gateway are checked by the Intel PCS collateral
— gateway_tee_tcb_not_revoked TDX revocation is checked by the Intel PCS collateral
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"method": "GET",
"url": "https://tee.redpill.ai/v1/aci/attestation?nonce=557795a30c4cb185cdea0585d1a45fdfe4a56c95c239d572a91988a97b26a3eb",
"url": "https://tee.redpill.ai/v1/aci/attestation?nonce=263ebcc8becde5acb63514e1d571453a7d901e2124675623c670831a7c3921a7",
"status": 200,
"proto": "HTTP/1.1",
"tls_version": "TLS 1.3",
"tls_cipher": "TLS_CHACHA20_POLY1305_SHA256",
"tls_cipher": "TLS_AES_128_GCM_SHA256",
"peer_spki_der_base64": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEdpt9LKMRVNJvB6g19TP5TKoxWef5Vt0+I4eTNJwgILGxrAGrypOHUQxXVy1cRhpKsFNwS3qGehd0tdpQOw3tVw==",
"headers": {
"Access-Control-Allow-Origin": [
Expand All @@ -20,17 +20,17 @@
"application/json"
],
"Date": [
"Fri, 13 Nov 2026 07:32:40 GMT"
"Thu, 19 Nov 2026 20:08:42 GMT"
],
"Vary": [
"origin, access-control-request-method, access-control-request-headers"
],
"X-Aci-Keyset-Digest": [
"sha256:338c049d02ba75455b770174735d81cfdca26b045509a3563eeffae302405b98"
"sha256:31bfd7f9a90aba90795f4c83aba9a245f3b20c97a23e21829b48273dc738a1b0"
],
"X-Aci-Version": [
"aci/1"
]
},
"duration_ms": 162
"duration_ms": 468
}
Loading