How it works · Explanation
The enclave
Shipped Agents is built to run every agent inside one confidential virtual machine on Phala Cloud. Each agent’s
wallet key is created at random inside that machine and is written to disk only in sealed (encrypted) form. For each
agent the machine publishes an evidence document: a hardware-signed statement that this wallet belongs to an agent
running this exact code, on Intel’s confidential hardware. Anyone can check it from public data with npm run cli -- verify agent <agentId> from a checkout of the repository.
No release has been deployed yet. The TDX path has run end to end against dstack’s simulator, and quote verification has been tested on real Intel-signed quotes; The simulator below says what that does and does not show.
This page covers what runs where, what the enclave protects and what it does not, who can run other code against the keys, and how keys are sealed. The evidence document and every check on it are in Runtime evidence, field by field. The release procedure is in release.md.
- TEE (trusted execution environment): hardware that runs code so the machine’s owner cannot read or change it.
- Intel TDX (Trust Domain Extensions): Intel’s TEE for whole virtual machines. A protected VM is a TD (trust domain); Phala calls it a CVM (confidential VM).
- dstack: the open-source OS and services Phala Cloud runs CVMs on. Its guest agent answers the app over the
socket
/var/run/dstack.sock. dstack 0.6 added a versioned v1 API, which this code uses. - KMS (key management service): dstack’s service that gives each app its keys, after checking the CVM’s attestation and asking an authorization policy whether that code may have them.
- Quote: a report signed by the CPU’s quoting enclave, carrying the TD’s measurements and 64 bytes of report data chosen by the app.
- MRTD, RTMR0-3: measurement registers in the quote. MRTD holds the firmware; RTMR0-2 the VM configuration, the kernel and its command line; RTMR3 holds dstack’s runtime events (app id, compose hash, instance id, OS image, key provider).
- Event log: the list of everything extended into the registers. Replaying it must give the registers in the quote.
- App compose: dstack’s
app-compose.json, which embeds the docker compose file and the CVM’s settings. Its sha256 is the compose hash, measured into RTMR3. - App id: the 20-byte identity of a dstack app. With an on-chain KMS it is the address of the app’s
DstackAppcontract. - Collateral: Intel’s signed certificates, revocation lists and TCB data needed to check a quote. Served by Intel’s
PCS (Provisioning Certification Service) or a cache of it, a PCCS; Phala runs one at
pccs.phala.network. - TCB status: Intel’s verdict on the platform’s firmware and microcode, such as
UpToDateorOutOfDate.
What runs where
Section titled “What runs where”| Place | What | Trusted for |
|---|---|---|
Phala Cloud CVM (tdx.medium, dstack OS 0.6.5) |
the desk, the agent pool, the worker and the HTTP API (shipped-agents service); dstack-ingress for TLS on the desk’s domain (the release file’s domain) |
keys, sealed notes and the code that uses them |
| dstack KMS | derives the app’s keys from its app id and key epochs | releasing keys only to allowed code |
| Base (chain 8453) | the app’s DstackApp contract: which compose hashes may receive keys |
the code allow-list, once on-chain KMS is in use |
| Robinhood Chain (4663) | ERC-8004 identities, the Engagement Registry with each agent’s runtime record | the public record |
| Anthropic’s API | the model | nothing secret beyond what the task needs |
| Intel | the root of trust for quotes | that the hardware is genuine |
Phala’s gateway forwards encrypted traffic for the desk’s domain to the CVM; dstack-ingress obtains the TLS
certificate inside the CVM with a DNS-01 challenge, so the private key never leaves it.
What the enclave protects, and what it does not
Section titled “What the enclave protects, and what it does not”It protects:
- The agents’ wallet keys and the desk’s key. They are generated inside the CVM, sealed under a key only this app’s CVMs can obtain from the KMS, and never leave the CVM in the clear. Nobody with access to the host, the disk or the network can read them. Which code counts as this app’s is decided by the key service: with Phala Cloud’s KMS, Phala, and whoever controls the Phala Cloud workspace (the operator), could start code that reads the sealed wallet keys (Who can run other code against the keys).
- Sealed notes and anything else the agents seal.
- The binding between an agent’s wallet and the code it runs: the quote’s report data names the agent and its wallet, and the measurements name the code.
It does not protect:
- Prompts and what the agent reads. They go to Anthropic’s API over TLS. The model vendor sees them.
- Anything the agent sends out: payments, mail, requests to other services.
- Physical and side-channel attacks on the hardware. Intel TDX does not defend against an attacker with physical access to the machine or against every side channel. Intel publishes advisories for known ones; see TCB status.
- Availability. The host can stop or delete the CVM. Keys survive only as sealed copies (see backups in release.md).
- Unmeasured inputs. The encrypted secrets are not in the compose hash:
SA_ANTHROPIC_API_KEY,SA_RPC_URL,SA_RPC_URL_<chainId>,SA_EMAIL_API_KEY,SA_EMAIL_WEBHOOK_SECRETandSA_BLOCKED_PAYEES(or its older nameBLOCKED_PAYEES) for theshipped-agentsservice, andCLOUDFLARE_API_TOKENfordstack-ingress. Whoever deploys can replace them. A different RPC can report false chain state to the desk, which acts on what it reports; it cannot sign for the desk. A different model key changes who is billed; a different payee list changes which payments are refused; a different mail key or webhook secret changes which mail account an agent’s mail goes through and who can deliver mail to it; a different Cloudflare token changes who can edit the desk’s DNS records. Each secret reaches only the setting of its own name: the measured compose may admit only these secrets as encrypted variables, and only on a lineNAME: ${NAME}orNAME: ${NAME?message}of the service that takes them. Every other setting is written into the measured compose, and the desk refuses to boot, andverifyfailssettings_measured, when a compose admits another variable, takes settings or code from outside itself, or is not plain YAML. - Code in the TLS ingress container.
dstack-ingressholds dstack’s socket to obtain the desk’s certificate, so its code is trusted as the desk’s is: it could derive the sealing key and make quotes. Its image is pinned by digest in the measured compose, like the desk’s.
Nothing here is unbreakable. Intel’s hardware, dstack’s code and the KMS are each part of what is trusted.
Who can run other code against the keys
Section titled “Who can run other code against the keys”This decides whether “the operator is kept out” is true. dstack offers two key services. No deployment exists yet, so neither is in use.
With Phala Cloud’s KMS (Phala Cloud’s default). Phala’s backend decides which compose hashes receive the app’s keys, and the workspace that deploys the CVM can push a new compose. So Phala, and whoever controls the Phala Cloud workspace (the operator), could start code that reads the sealed wallet keys. In this mode the evidence still shows exactly which code produced it, but it does not keep the operator out.
With the on-chain KMS on Base. Keys go only to compose hashes the app’s DstackApp contract allows, and only its
owner can add one. With the owner a Safe on Base, every code change is a public Safe transaction calling
addComposeHash before the new code can get keys, and anyone can read the allow-list. What stays trusted: the Safe’s
signers, who can approve new code (so the operator is constrained only as far as every approval is public and
visible before it takes effect); Phala’s 2-of-3 Safe that owns the shared KMS contract and its list of allowed OS
images; and the KMS itself, which runs in its own TEE. release.md gives the steps for this
mode.
Keys and sealing
Section titled “Keys and sealing”Each agent’s wallet key and the desk’s key are random secp256k1 keys from generatePrivateKey(). The SDK warns not to
hold assets in keys derived by the KMS, so the derived key is used only to seal.
The sealing key is getKey("shipped-agents/seal/v1", "secp256k1") on dstack’s v1 API, put through HKDF-SHA256 to an
AES-256-GCM key. dstack’s KMS derives it from:
- the KMS root key of a root epoch, which Phala rotates (it did on 20 November 2026);
- the app id;
- the app’s app epoch, which the
DstackAppowner can advance withadvanceAppEpoch.
The compose hash is not an input. So an upgrade of the same app keeps every sealed file readable, provided the KMS lets the new compose hash have keys. A new app id (a fresh deployment instead of an update) cannot read anything the old one sealed.
Every sealed file starts with a header: format version 2, the root epoch and app epoch (u32, big endian), and a label
such as key:agent-3 or note:seat-1:plan. The whole header is AES-GCM associated data, so a file moved to another
slot, relabelled or given other epochs fails to open. At every boot the enclave walks the data directory, finds files
sealed under older epochs, asks the KMS for those epochs’ key explicitly (getKey(domain, alg, rootEpoch, appEpoch))
and re-seals them under the current one. The KMS answers that only while the running compose hash is allowed at the
old epoch too, which release.md covers.
Files are written atomically (temporary file, fsync, rename, fsync of the directory) with mode 0600 in 0700 directories. Decrypted key buffers and the derived AES key are overwritten after use. Node keeps private keys as strings, which cannot be wiped, so a key loaded for signing stays in the process’s memory until it is collected; that memory is inside the TD.
The data volume also holds, unsealed, the sqlite store (agents, tasks, quotes), each agent’s private ledger, each task’s transcript and the catalog’s skill files. dstack encrypts the whole data disk with a key bound to the app id and instance, so they are unreadable outside this CVM. Backups seal them (see release.md).
Runtime evidence
Section titled “Runtime evidence”For each agent, the enclave asks dstack for a TDX quote whose report data is the agent’s binding,
keccak256(abi.encode(chainId, identityRegistry, agentId, agentWallet)), and publishes it with the event log, dstack’s
attestation and the measured app compose as one canonical JSON document. The desk records the document’s keccak256 and
the compose hash on the Engagement Registry with setRuntime. The pool renews evidence older than 20 days, or evidence
that names another compose hash, and readers refuse evidence older than 30 days by default.
The enclave never publishes a document that fails its own offline checks. Ledger checkpoints and delivered reports are attested the same way, with a different tag in the report data, so neither can be passed off as an agent’s evidence.
- Runtime evidence, field by field lists every field of the document, every check, the values a reader pins, Intel’s TCB statuses and how collateral is fetched.
- verify agent runs every check from public data and explains each line of its report.
- Check it by hand makes the same checks with
cast,curl,jq,openssland Phala’sdcap-qvl, without this repository’s code.
What verification cannot show at all: that the hardware has no undisclosed flaw, that dstack’s OS image does what its source says (it is reproducible from source; building it is the check), and that the model vendor handles prompts as it says.
The simulator
Section titled “The simulator”dstack’s guest-agent simulator answers the guest API from a recorded attestation of a real TDX CVM. Two exist:
phala simulator startdownloads simulator 0.5.3 (July 2025). It has no v1 API, so this code cannot run against it.- The 0.6 simulator is built from dstack’s source. It has no macOS build upstream; on a Mac its Linux-only SEV-SNP code
needs stubbing. The run behind this page used tag v0.6.6 (commit
c87303818753), built with Rust 1.96.1.
git clone --depth 1 --branch v0.6.6 https://github.com/Dstack-TEE/dstack.git && cd dstack# macOS only: gate sev-snp-attest's Firmware and ioctl code behind #[cfg(target_os = "linux")] with stubs that bail.cargo build --release --manifest-path dstack/Cargo.toml -p dstack-guest-agent-simulator -p mock-attestationcd sdk/simulator && ../../dstack/target/release/dstack-simulator -c dstack.toml &DSTACK_SIMULATOR_ENDPOINT=$PWD/dstack.sock node --disable-warning=ExperimentalWarning --test test/enclave.test.tsThe stock fixture measures a compose other than the app-compose.json the simulator serves, so openEnclave correctly
refuses it (dstack's compose hash is not sha256 of the app compose it serves). To run the whole path:
- Render a release compose (
ops/release-compose.ts) and wrap it in anapp-compose.json(astest/fixtures/dstack/app-compose.json). node test/simulator/attestation.ts <stock v1 Attest output> app-compose.json attestation.bin [1|2]rewrites the fixture so RTMR3 measures that compose, in event log version 1 or 2.dstack-mock-attestation generate --output roots, thendstack-mock-attestation serve --config roots/tee-simulator.json --output activefor a mock PCCS on port 8088, and setmock_attestation_seedfromroots/tee-simulator.jsonin the simulator’sdstack.toml. The simulator then signs a fresh quote over the rewritten measurements and the requested report data with dstack’s mock PKI.
What the simulator run showed: v1 Attest returns a MessagePack attestation whose quote and event log equal v0
GetQuote’s byte for byte; the event log replays to all four RTMRs; every runtime digest recomputes, for log versions 1
and 2 (version 2 preimages written by dstack itself); the derived key is the same across restarts and for explicit
epochs; openEnclave({ dev: false }) boots, seals and re-opens keys and serves evidence that passes every check; the
seeded quote verifies against the mock PKI and is refused against Intel’s root. test/fixtures/dstack/ keeps that
evidence.
What it does not show: anything about real hardware. The simulator’s measurements come from a recording and its
quotes are signed by a test PKI. Quote verification against Intel was tested separately on two real quotes: Phala’s
published production quote (GET https://cloud-api.phala.com/api/v1/attestations/raw/b920…d6f6) and the original
quote inside dstack’s fixture. Both verify UpToDate with collateral from Phala’s PCCS and from Intel’s PCS, and the
fixture’s quote with its report data patched fails its signature, as it should. The measurements of this image on a real
CVM can be checked only after a first deploy (release.md).