Repository navigation
fix(sdk): resync SDKs with the guest agent and each other - #1508
Merged
Merged
Conversation
Leechael
force-pushed
the
fix/sdk-sync-0.6.0
branch
from
November 19, 2026 22:02
cf68365 to
13f4592
Compare
- omit hash_algorithm in TappdClient.tdx_quote() when unset so the server default (sha512) applies instead of sending raw unpadded - fail fast with a clear error for inherited v0 methods that have no route on tappd.sock, pointing to DstackClient on dstack.sock - reword TappdClient deprecation warnings to point to DstackClient - fix TypeError on requirements/docker_config null in get_compose_hash - make dict and AppCompose input paths produce the same compose hash - tolerate null mrtd/rtmr fields in TcbInfo for non-TDX backends - add cross-language compose hash fixture consumed by all SDKs Signed-off-by: Leechael Yim <yanleech@gmail.com>
- EventLog: add optional version and preimage - add get_key_with_algorithm for ed25519, keep get_key signature - TlsKeyConfig: add not_before, not_after and with_app_info - InfoResponse: add cloud_vendor and cloud_product - TcbInfo: add mr_aggregated, tolerate null mrtd/rtmr fields - fix stale api_v1 comment: the Rust SDK does not link ra-tls Signed-off-by: Leechael Yim <yanleech@gmail.com>
- route TappdClient info()/version() through /prpc/Tappd.* and fail fast on inherited v0 methods that have no route on tappd.sock - reword TappdClient deprecation warnings to point to DstackClient - widen swap_size and init_script type annotations to match the server - reject malformed and odd-length hex in hexToUint8Array - reject promptly on response error/aborted in send-rpc-request - add a timeoutMs constructor option to the JS clients - qualify the canonical compose hash allowlist claim in README - drop broken test-outputs.js; assert the cross-language compose hash fixture Signed-off-by: Leechael Yim <yanleech@gmail.com>
- route TappdClient Info/Version/IsReachable through /prpc/Tappd.* and fail fast on inherited v0 methods that have no route on tappd.sock - reword TappdClient deprecation warnings to point to DstackClient - accept integer swap_size and single-string init_script, preserving the input form in the hash - preserve field presence in compose hashing instead of dropping empty values, and pass through unknown nested fields via Extra - emit an empty env list for EncryptEnvVars(nil) - extend the compose hash parity test and assert the cross-language fixture Signed-off-by: Leechael Yim <yanleech@gmail.com>
- read OID 62397.1.8 VersionedAttestation (legacy SCALE and V1 msgpack), falling back to legacy .1.1/.1.2 extensions - replay V2 runtime-event digests (JCS of name/type/payload) - add WithVerify(func(*VerifyResult) error) so callers can enforce app/OS/compose policy; document that TLSConfig alone is not app authentication - add offline tests with committed v0/v1 fixture certificates Signed-off-by: Leechael Yim <yanleech@gmail.com>
- raise ValueError instead of KeyError when runner is missing - convert dict docker_config to DockerConfig so typed and dict inputs hash identically - keep explicit nulls on fields Rust serializes as null (docker_compose_file, key_provider, storage_fs, DockerConfig fields), still omitting fields Rust skips - extend the cross-language compose hash fixture to 12 cases covering null and explicit-false semantics, pinned by Rust dstack-types serde attributes Breaking: Python TcbInfo mrtd/rtmr0-3 are Optional[str] since the previous commit on this branch Signed-off-by: Leechael Yim <yanleech@gmail.com>
- restore dropping false health_check and ephemeral_data_disk, with the
original comments: the guest's Rust types skip a false value, so an
app that opts out must hash as if the field were absent
- settle explicit-null semantics per field against the Rust
dstack-types round trip: keep null where serde has no
skip_serializing_if, omit where it does
- fix a null captured in Extra overriding a typed field set later
- replace interface{} with named InitScripts and SwapSize types that
remember the input form; zero values still omit the fields
- document the presence-tracking limitation on PortAttrs/VerityVolume
- assert all 12 cross-language fixture cases
Breaking: AppCompose.InitScript and AppCompose.SwapSize are now
*InitScripts and *SwapSize instead of []string and string
Signed-off-by: Leechael Yim <yanleech@gmail.com>
- drop health_check:false and ephemeral_data_disk:false, matching the guest's Rust types which skip a false value - keep explicit null on fields Rust serializes as null, omit null on fields with skip_serializing_if, per dstack-types serde attributes - assert all 12 cross-language fixture cases Signed-off-by: Leechael Yim <yanleech@gmail.com>
- add BootEvent lookup limited to events before system-ready; document that app-controlled events after system-ready are untrusted for identity policy - make quote verification injectable and test the real VerifyCert offline: SPKI/report_data binding, TCB checks, tamper rejection, and hook ordering (policy runs only after successful verification) - reject WithVerify(nil) instead of silently disabling policy - reject dstack-pod evidence (its report_data_payload binding is not checked); document TDX-only support - document in README and VerifyCert that TLSConfig alone is not app authentication Signed-off-by: Leechael Yim <yanleech@gmail.com>
- omit requirements.gpu_policy.rego when null, matching the Rust skip_serializing_if and the Go/JS SDKs - pass through explicit null on non-Option fields and unknown extras instead of dropping it: Rust rejects such input at parse time, so there is no serialize truth to match; the SDK hashes what it is given - document numeric edge cases and that the SDK compose hash is not a Rust round-trip - extend the cross-language fixture to 21 cases with a per-case normalize flag Signed-off-by: Leechael Yim <yanleech@gmail.com>
- preprocessAppCompose now removes empty and null pre_launch_script carried in Extra, matching Python and JS normalize behavior - document zero-value InitScripts/SwapSize marshaling ([] and 0) and the numeric edge cases and non-Rust-round-trip contract - assert all 21 cross-language fixture cases including the per-case normalize flag Signed-off-by: Leechael Yim <yanleech@gmail.com>
Mirrors Rust find_event_payloads: returns every matching event before system-ready, excluding app-controlled events emitted after it. Signed-off-by: Leechael Yim <yanleech@gmail.com>
Rust maps a null init_script to an empty list and skips it; Go and Python omit it. Also document numeric edge cases and that the SDK compose hash is not a Rust round-trip. Assert all 21 fixture cases including the normalize flag. Signed-off-by: Leechael Yim <yanleech@gmail.com>
docker_config is not a Rust AppCompose field, so it is an unknown extra, and a null unknown extra passes through like in Go and JS. Update the test that pinned the dropping behavior and add the docker_config_null cross-language fixture case (22 cases total). Signed-off-by: Leechael Yim <yanleech@gmail.com>
…gelog Breaking (recorded): Rust TcbInfo mrtd/rtmr0-3 String -> Option<String> and new public fields on TlsKeyConfig/EventLog/InfoResponse; Python TcbInfo Optional[str]; Go AppCompose.InitScript/SwapSize named types Signed-off-by: Leechael Yim <yanleech@gmail.com>
… section Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Signed-off-by: Leechael Yim <yanleech@gmail.com>
kvinwang
force-pushed
the
fix/sdk-sync-0.6.0
branch
from
November 20, 2026 13:29
36be9e6 to
4df4a3b
Compare
Ed25519 keys are available through the v1 client; keep the frozen v0 client's key derivation to get_key and get_key_at_epochs. Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The four SDKs had drifted from the guest agent and from each other. This PR fixes the broken calls and the cross-language compose-hash differences, updates the Go
ratlshelper to accept the certificates current dstack issues, and brings the KMS-epochGetKeyand SealedEnv code added in #1533 to the same behaviour in every SDK.Problem
Tappd clients call routes that don't exist.
tappd.sockmounts only the Tappd service (DeriveKey,DeriveK256Key,TdxQuote,RawQuote,Info,Version). Seeguest-agent/src/server.rsandrpc_service.rs(TappdServer).TappdClientinherit every v0 method fromDstackClientV0, so calls toget_key,get_quote,attest,sign,verify,emit_eventandget_tls_keyon a Tappd client return 404.infoandversionto/Infoand/Versioninstead of/prpc/Tappd.*.get_keyon that same Tappd client, which can't work.Python
TappdClient.tdx_quote(data)returns HTTP 400 with default arguments. It senthash_algorithm: "raw", but only padded the data to 64 bytes when the caller passed"raw"explicitly. Raw mode requires exactly 64 bytes.The compose-hash helpers disagree with each other on the same JSON:
omitemptydropped"key_provider_id":"","allowed_envs":[]and other empty values that vmm-cli and the VMM UI always emit.swap_sizeand a single-stringinit_script, both of which the server accepts and dstack tooling emits.TypeErroronrequirements: nullordocker_config: null. It also gave different hashes for the same requirements depending on whether they came in as a dict or throughAppCompose(...).falseandnulldifferently from one another.KeyProviderKindhad no constants fortpmorsev-snp, whichdstack-typesaccepts and JS/Python already list (feat: add native SEV-SNP hardware key provider #1526).Go
ratls.VerifyCertrejects every current certificate. It read only the legacy OIDs62397.1.1and.1.2, whilera-tls/src/cert.rsnow writes the versioned attestation at.1.8. Even with the OID fixed, its RTMR3 replay supported only V1 event digests.ratls.TLSConfigalso had no way to reject a peer by policy:WithOnVerifiedreturns nothing. The only identity data available wasRuntimeEvents, which includes events the app emits aftersystem-ready. A policy check that looked upcompose-hashby name could therefore be fooled by an app-emitted duplicate.GetKeyepochs are decoded differently across SDKs.root_epochandapp_epochare protouint32. Rust rejects anything else. JS turnednullinto0and accepted any number. Python coerced"1",trueand1.0to integers and accepted out-of-range values. Go decodednullas0. A non-uint32 epoch could therefore satisfy the "returned different epochs than requested" guard when the caller asked for epoch 0.Smaller issues:
EncryptEnvVars(nil)produced{"env":null}, which the guest rejects after decrypting.Infowhen the agent returns null measurement registers, which happens on a non-TDX backend.sdk/fixtures/sealed-env/were produced by JS and Python, but only those two SDKs opened them.Server-side raw-byte compose hashing is intentional (#550) and is unchanged. The SDK helpers predict the hash only when the deployed bytes are exactly the ones they serialize. The JS README overstated this, and is corrected here.
Fix
Tappd routing (Python, JS, Go)
infoandversiongo to/prpc/Tappd.*.DstackClient.tdx_quote. Python keepsrawas its default and now left-pads it, so short inputs no longer fail and 64-byte inputs keep their raw report data.Compose hash. One rule across Python, JS and Go, taken field by field from the
dstack-typesserde attributes:Optionfield with noskip_serializing_ifkeeps an explicit null.Optionfield with a skip omits it:snapshotter,requirements,init_script,requirements.*andgpu_policy.rego.health_check: falseandephemeral_data_disk: falseare dropped (is_false).InitScriptsandSwapSize.KeyProviderTPMandKeyProviderSevSnp.sdk/tests/compose-hash-fixture.jsonhas 22 cases, including normalize-mode cases, and Python, JS and Go each assert all of them.Go
ratls.1.8, both the SCALE V0 and msgpack V1 encodings, and falls back to.1.1/.1.2. This mirrorsra-tls/src/attestation.rs.WithVerify(func(*VerifyResult) error)rejects the handshake. It runs only after quote, TCB, report_data and RTMR3 checks pass.WithVerify(nil)is rejected rather than treated as "no policy".BootEventandBootEventslook up identity events only up tosystem-ready, matching Rust'sfind_eventandfind_event_payloads.dstack-podevidence is rejected.TLSConfigalone does not authenticate the app.GetKeyepochs and SealedEnvroot_epochorapp_epochthat is not a uint32, including an explicitnull, as Rust already does. Python v0 does too. An omitted field still decodes as the proto default0, but not when the caller selected that epoch: an agent older than the epoch fields ignores the selectors and omits them, so all four v1 clients reject the omission, as the v0 clients do.getKeyepoch selectors and theapp_epochargument ofsealEnvandverifySealedEnvPublicKey.Other fixes
EncryptEnvVars(nil)now emits[].error/abortedhandling, and atimeoutMsclient option. The server's GPU attest budget is 300 s, against the previous fixed 30 s. Every v1 call, including the epoch-awaregetKey, goes through it.TlsKeyConfignot_before,not_afterandwith_app_infoEventLogversionandpreimageInfoResponsecloud_vendorandcloud_productTcbInfomr_aggregatedTcbInfotolerate null.sdk/js/test-outputs.jsis removed. It required a nonexistentdist/node/index.jsand called the removedreplayRtmrs.ra-tls/src/api_v1.rsis fixed. It is the only change underdstack/.REUSE.tomlcovers the new ratls certificate fixtures and the compose-hash fixture.Breaking (recorded in
CHANGELOG.mdunder Unreleased):TcbInfo.mrtdandrtmr0–rtmr3are now optional.TlsKeyConfig,EventLogandInfoResponsebreak struct-literal construction.AppCompose.InitScriptandAppCompose.SwapSizeare now*InitScriptsand*SwapSize.get_keytake aGetKeyConfigbuilder, which also carries the optional epochs;get_key_at_epochsis gone. Neither signature was in a published crate (crates.iodstack-sdkis at 0.1.3), except v0get_key(path, purpose), whoseDstackClientpath 0.6 already renames toDstackClientV0.Verification
The SDK suites ran at the branch head against the Linux simulator.
tsc --noEmitcleandstack,tappdgo vet,gofmtcleanratlsRATLS_TEST_ENDPOINT)go vet,gofmt,go mod verifycleanno_stdpassclippy -D warnings,cargo fmt --checkcleanreuse lintpasses.Tests fail without the fixes. Each bug-fix test was run with only its commit's source reverted and was shown to fail. That includes the Go, JS and Python epoch tests, for example the Go null-epoch cases. For ratls, mutating each check caught every one of these: removing the system-ready cut-off, nil policy, accepting dstack-pod, running policy before verification, removing the report_data binding, removing the TCB check, removing RTMR3 replay.
Parity sweep. 478 JSON inputs plus 33 hand-built Go structs, each hashed with normalize on and off. Go, Python and JS agree on every input except two documented numeric edge cases:
swap_sizeabove 2^53 loses precision in Go and JS, and2.0is printed as2.0in Python.ratls fixtures. The offline tests use v0 and v1 certificates captured from a real Intel TDX boot, the same ones as
dstack/verifier/fixtures/tdx-lite-v1.README.md.VerifyCertruns end to end with a stubbed collateral step. Tampered SPKI, report_data and RTMR3 all fail, and the policy hook never runs when verification fails.Not verified offline: the live dcap collateral path, and V2 event logs from real hardware. V2 is covered by Rust's own test vector.