tappd
) sets up the in-VM environment and mediates all security-sensitive requests from application containers. It handles remote attestation and secret retrieval: when a CVM boots, the agent gathers the attestation quote from the TEE and uses it to request keys from dstack-kms, supplying those keys to container processes without ever exposing them outside the enclave. The agent also assists the dstack-gateway in establishing RA-TLS connections by generating attestation-bound TLS key material and certificates from within the enclave. Overall, dstack-guest-agent acts as the in-enclave security coordinator, ensuring the application inside the CVM can attest its trustworthiness and securely obtain the resources it needs.
meta-dstack – A Yocto-based build layer that produces the minimal, secure guest OS image used inside the CVM. Rather than relying on a general-purpose VM image, meta-dstack provides a purpose-built, hardened environment for confidential containers. It includes only the essential kernel, system libraries, and dstack runtime components, minimizing the attack surface. The resulting OS (sometimes called dstack-os) serves as a hardware abstraction layer between the application containers and the TEE hardware, and is configured with security best practices out of the box. By using meta-dstack, every CVM launched by dstack-vmm starts with a vetted, trustable software stack, reducing the complexity of building confidential apps.
*.dstack.host
domain for that deployment), the gateway verifies the CVM’s attestation and then routes the traffic over a TLS channel that terminates inside the enclave. In this way, the application’s users interact with it as they would any web service, but under the hood every request and response is confined within a secure enclave context. The diagram shows the end-to-end flow: from building the confidential image, to launching the CVM, attesting and provisioning keys, and finally serving client traffic—ensuring at each step that the code running is exactly what it should be and that data remains confidential and tamper-proof.
dstack.host
domain) so that it can be reached via the internet. The dstack-gateway either obtains a TLS certificate for that domain or uses an ephemeral certificate generated by the enclave, embedding the CVM’s attestation into the certificate via RA-TLS. In either case, the gateway ensures that any client connecting over HTTPS will negotiate a TLS session that is cryptographically linked to the CVM’s identity. In practical terms, when a user visits the application’s URL, the gateway will forward the incoming TLS connection directly into the CVM (either by acting as an SNI router in TLS passthrough mode, or by terminating TLS after verifying the enclave’s certificate). The result is that the TLS handshake itself attests the enclave: a client can be presented with a certificate chain proving the server is a legitimate TEE instance, and the gateway will only route traffic to the CVM if that verification passes. All HTTP requests from the user are thus handled by the application inside the enclave, and responses travel back the same way, with the gateway simply relaying encrypted data. This RA-HTTPS flow gives end-to-end encryption with confidentiality and integrity guarantees that extend into the application’s runtime. The user experiences a standard HTTPS connection, but behind the scenes dstack has layered in additional trust verification.
Completion and Continuous Trust: After the above steps, the deployment is complete: the developer’s application is running as a confidential service. From the developer’s perspective, they wrote a containerized app and specified it should run on dstack; dstack then automated everything else—provisioning a secure VM, attesting it, injecting secrets, and exposing a secure endpoint. The “enhanced” nature of this deployment flow lies in the invisible security measures taken throughout. At no point does untrusted code execute, and at no point can data be accessed without proper attestation. Even after deployment, these guarantees continue: the dstack-gateway can periodically or continuously verify attestation quotes from the CVM (for instance, if the VM restarts or after a certain time interval, new quotes can be checked) and the dstack-kms can issue rotated keys if needed. If the application or the CVM needs to be updated, the process can be repeated, with the assurance that any change in code will produce a different measurement, and thus would not be trusted by KMS or gateway until explicitly approved. In summary, the deployment flow not only launches your application but does so in a way that each stage is fortified by cryptographic trust – from build time, to boot time, to run time, and to user access.
tdx-attest
) and RA-TLS support (ra-tls
, ra-rpc
), which allow it to perform cryptographic operations tied to the enclave’s identity. One of the key secure sub-components of the guest agent is the attestation quote generator: it interfaces with the TDX module to produce an attestation report that is cryptographically signed
by the CPU (via the Intel EPID or DCAP attestation scheme). The agent then formats this report for consumption by external services, bundling it into requests to dstack-kms or presenting it via TLS certificates to clients. The RA-TLS certificate module within the guest agent deserves special mention: it generates a private key and X.509 certificate signing request (CSR) inside the enclave and embeds the attestation quote into a certificate extension. This CSR can be used to obtain a certificate from a CA (which in Phala’s system is automated by a built-in Certbot service for the gateway), or for a self-signed certificate that clients explicitly trust. In either case, the result is that the enclave proves ownership of a keypair that’s bound to its secure state. The guest agent’s design ensures that no sensitive operation occurs without attestation. For instance, if the application container tries to fetch a secret, the agent will only fulfill that request after it has attested to KMS and obtained the key. If the application tries to open a listening socket, the agent can enforce that only TLS connections with the proper certificate are used (or coordinate with the gateway to do so). Additionally, the guest agent runs with the least privilege necessary inside the VM and is isolated from the application’s workload (for example, running as a separate process, possibly with stronger privileges to interact with TEE device drivers, but not exposed to external network except through defined channels). This separation means even if the application were compromised by an exploit, the attacker would still have to bypass the guest agent’s controls to extract secrets or break TEE bounds.
dstack-gateway (Zero-Trust Networking): The gateway component is the guardian at the network frontier, embedding Zero Trust principles into external connectivity. One of its core security sub-components is the RA-TLS verification engine. When the gateway proxies a connection to a CVM, it uses an RA-TLS library to validate the TLS certificate presented by the CVM’s enclave (or it presents an attestation-bound certificate to the client on the CVM’s behalf, depending on the mode). Essentially, the gateway will only establish or forward a connection if it can confirm the server on the other end is an attested enclave matching the expected measurement. To facilitate this, dstack-gateway works hand-in-hand with the guest agent: for example, the guest agent might supply a signed certificate to the gateway, and the gateway’s job is to advertise that cert to clients (via standard TLS) and/or to verify it continuously. The gateway also incorporates a certificate management sub-component (built atop Let’s Encrypt’s ACME protocol via an internal Certbot tool) which automates obtaining TLS certificates for the human-friendly domain names of services. These certificates are issued only after the gateway proves to the CA that it controls the domain, and they might be short-lived. The combination of attestation-backed internal certificates and public CA-issued certificates means that even traditional web browsers (which require standard CAs) can be used to access enclaves securely, without custom plugins. Additionally, the gateway is hardened to prevent common web entry-point attacks: it can enforce host-based routing (ensuring one deployment can’t impersonate another’s domain), it terminates or forwards connections in a way that an eavesdropper on the host cannot man-in-the-middle the traffic, and it exposes only a minimal API (just forwarding) to the outside. In dstack’s security model, the gateway is not fully trusted by the enclaves—it’s more of a broker that must itself verify attestation. Should the gateway be compromised, it could not silently connect users to a fake service because it wouldn’t have a valid enclave certificate to use. In summary, dstack-gateway embeds a policy of “never trust, always verify” for network traffic, ensuring that clients and enclaves are mutually authenticated at the cryptographic level before any data flows.
dstack-kms (Distributed Trust Anchor): As the provider of keys and secrets, dstack-kms is arguably the most security-critical component, and it’s architected with multiple safeguards accordingly. First, the KMS never stores plaintext keys long-term; instead, it employs a deterministic key derivation scheme. The secret derivation function (a secure cryptographic hash or KDF) takes inputs like the application’s identity, possibly a deployment-specific seed, and (if policy dictates) recent blockchain randomness or other entropy, to yield the Root Key. This means that if the KMS service is down, it can recreate keys on restart exactly as before, but if an attacker steals the KMS database, they get no usable secret material (since the keys aren’t simply sitting there). Second, dstack-kms is often backed or controlled by a blockchain or decentralized consensus (in Phala’s implementation, the key derivation may involve on-chain governance or seed distribution). This adds resilience: no single party, not even the cloud provider hosting the KMS, can arbitrarily issue keys to an enclave that isn’t authorized. The KMS checks the enclave’s attestation against a ledger of legitimate deployments – for example, it might verify that the enclave’s measurement corresponds to a hash that was registered on-chain when the developer deployed the app. Only if this check passes will it derive and release keys. Third, the KMS supports key rotation and revocation. If a vulnerability is discovered in the application or the TEE firmware, new keys can be derived (by changing the input parameters or using an updated derivation epoch), and the old keys can be scheduled for revocation, effectively re-securing data under new secrets going forward. This feature is vital for censorship resistance and compromise recovery: even if an attacker somehow got hold of an old key (say by breaching a TEE at one point), they cannot decrypt new data after a rotation, nor can they easily fake a new enclave to obtain keys because the attestation verification would fail. Finally, dstack-kms is typically run in a redundant, fault-tolerant manner (and could itself potentially run in TEEs for additional security, though the current design treats it as a highly trusted external service). The protocols between KMS and the guest agent are encrypted and authenticated, and the KMS logs can be audited to detect any irregular access attempts. In essence, dstack-kms functions as a decentralized root-of-trust for the system, and its internal mechanisms ensure that secrets are only handed to the right enclaves under the right conditions, with a clear audit trail and the ability to adapt if the threat landscape changes.
Together, these built-in security subsystems ensure that each part of dstack’s infrastructure reinforces the others. The hardware-level isolation and attestation from dstack-vmm/TDX provide the foundation, the minimal OS and guest agent inside the CVM maintain the enclave’s integrity and mediate access to secrets, the gateway links external interactions to internal attestation, and the KMS anchors the trust chain and manages secrets without ever creating a single point of failure. This defense-in-depth approach means that even if one layer were to be breached or misconfigured, the other layers would continue to protect the confidentiality and integrity of the application. For developers and users, the end result is a cloud deployment platform where strong security is not an afterthought but an intrinsic quality of the runtime. Every request, every byte of data, and every management operation is checked and secured at multiple levels. For further details on the security rationale and threat model behind these components, please refer to the dstack security model documentation, which delves into how trust is established and maintained throughout the system.