The Prompt Encryption SDK establishes an end-to-end encrypted channel between a client and an inference workload running inside a Trusted Execution Environment (TEE). The security guarantee is stronger than standard TLS: the encrypted channel is cryptographically bound to the attested identity of the TEE endpoint, meaning neither the cloud operator nor any infrastructure-layer observer can read prompt or response content, even with access to the host OS or hypervisor.
This document describes the protocol, the component architecture, and the security properties of the system.
Standard TLS provides confidentiality and server authentication via a certificate chain. The client knows it is talking to whoever holds the private key associated with the certificate. What it does not know is where that private key lives — whether it is inside a hardware-isolated enclave or in a process fully visible to the cloud operator.
For regulated enterprise workloads like healthcare, finance, legal this distinction matters. The threat model is not an external attacker intercepting network traffic. The threat model is an infrastructure-layer observer: a compromised hypervisor, a cloud operator with privileged access, or a malicious co-tenant on shared infrastructure. Standard TLS provides no protection against any of these.
TEEs address the hardware isolation side of this problem. The missing piece is trust establishment: how does a client cryptographically verify that it is talking to a specific TEE running specific software, and how is that verification bound to the communication channel so it cannot be stripped or forged?
We assume an adversary who controls the network (routers, L4/L7 load balancers) as well as the underlying host infrastructure (Hypervisor, Host OS). Standard TLS offers no defense against an infrastructure-layer observer.
The objective is to establish a secure channel where sensitive data (e.g., prompts) is strictly confined to the memory space of a verified TEE running a specific, known-good software stack. The adversary must not be able to eavesdrop, tamper, or perform Man-in-the-Middle (MitM) or Attestation Replay attacks. To achieve this, we use Attested TLS.
Attested TLS aims to provide cryptographic proof of the integrity and identity of the environment (e.g., a TEE) at the other end of a connection. The primary variations differ in when attestation evidence is provided relative to the TLS handshake:
-
Pre-Handshake Attestation: Remote attestation occurs before the TLS handshake begins. The results influence the handshake, often by issuing a short-lived certificate to the server's TLS public key.
- Pros: Strong theoretical guarantee; no channel is established until attestation is verified.
- Cons:
- Requires significant changes to existing Public Key Infrastructure (PKI) and Certificate Authority (CA) workflows, heavily hindering real-world adoption.
- Self-signed certificate based Pre-handshake attested TLS has known vulnerabilities.
-
Intra-Handshake Attestation: Attestation evidence is exchanged during the TLS handshake, typically embedded in custom X.509 extensions or new TLS protocol extensions (e.g.,
ClientHello/Certificatemessages).- Pros: Direct binding of attestation to the handshake in progress.
- Cons: Requires deep modifications to core TLS libraries and breaks compatibility with standard network infrastructure (e.g., L4 Load Balancers). Furthermore, early IETF draft proposals for intra-handshake bindings were found to have potential security flaws in Confidential Computing threat models.
-
Post-Handshake Attestation: A standard TLS handshake completes first, establishing a secure channel. An application-layer attestation protocol is then run inside this encrypted channel, cryptographically binding the evidence to the live TLS session via Exported Keying Material (EKM).
The Prompt Encryption SDK strictly utilizes Post-Handshake Attested TLS for the following critical reasons:
- Infrastructure Compatibility: It works seamlessly with existing, hardened TLS libraries and real-world network infrastructure without requiring protocol-level modifications.
- Encrypted Attestation Payload: Exchanging attestation evidence, which contains detailed platform and software measurements, inside an already established TLS tunnel protects sensitive infrastructure metadata from passive network observers.
- Strong Session Binding: Using RFC 5705 EKM ensures the attestation is mathematically tied to the specific TLS session. Even though the assurance arrives "later," the cryptographic link prevents Replay and MitM attacks robustly.
- Standardization Momentum: Industry consensus and recent IETF drafts (e.g.,
draft-fossati-tls-exported-attestation) strongly favor post-handshake mechanisms for Confidential Computing due to their optimal balance of security and deployability.
The protocol operates over an established standard TLS 1.3 channel, leveraging the highly vetted TLS record layer for confidentiality, sequence numbering (replay protection), and integrity (AEAD MACs).
Client (urllib3/Pool) Server (TEE Workload)
| |
| [1] Standard TLS 1.3 Handshake (Any Cert) |
|<============================================================>|
| |
| [2] POST /_attest-connection |
|------------------------------------------------------------->|
| | |
| +--[3a] Derives EKM_svr (RFC 5705)
| +--[3b] Hardware signs Attestation Report (T_attest)
| +--[3c] Generates Payload = Protobuf(SHA256(EKM_svr), SHA256(T_attest))
| +--[3d] Computes Sig_session = Sign(PrivKey_instance, Payload)
| |
| [4] { T_attest, PubKey_instance, Sig_session } |
|<-------------------------------------------------------------|
| |
+--[5] Client Verification (See Section 2.3) |
| |
| [6] Verified E2E Encrypted Application Data |
|=============================================================>|
A standard TLS 1.3 handshake establishes an encrypted channel and a shared session secret derived from ephemeral key exchange (ECDHE). The server presents a standard PKI certificate.
Both sides independently derive a session-specific value using RFC 5705 TLS Exported Keying Material.
The label "EXPORTER-Prompt-Encryption-SDK" scopes this export specifically to this protocol, preventing cross-protocol attacks. The EKM is deterministically derived from the session's master secret; it cannot be forged without access to the session keys and uniquely identifies this specific TLS session.
The server maintains an ephemeral ECDSA P-256 key pair (
- Platform measurements: Hardware firmware version, CPU SVN, and platform configuration registers.
- Workload measurements: A hash of the software stack running inside the TEE (bootloader, kernel, application).
-
Hardware Identity Snapshot: The SHA-256 fingerprint of the public key (
$$PubKey_{instance}$$ ) is cryptographically bound into the hardware token (within theeat_nonceOIDC claim).
To prove possession of the key bound to the TEE, and to bind the hardware identity to the live TLS session, the server signs a specific payload using its private key
The core security of the SDK rests in the client's rigorous validation of the attestation response. If any step fails, the connection is immediately terminated.
-
EKM Derivation: The client independently derives
$$EKM_{client}$$ . Due to TLS properties,$$EKM_{client} == EKM_{svr}$$ if and only if both parties share the exact same TLS Master Secret. -
Signature Chain Verification (Root of Trust): The client fetches the JWKS from the configured OIDC Discovery URL and verifies the cryptographic signature of the JWT against the published public keys of the Root of Trust (e.g., Google Cloud Attestation).
-
Instance Key Binding Verification: The client computes
$$Hash_{key} = SHA256(PubKey_{instance})$$ . It extracts theeat_nonceclaim from the verified OIDC JWT and asserts that$$Hash_{key} \in claims['eat_nonce']$$ . -
TLS Session Binding Verification: To prevent Attestation Replay and MitM attacks, the client binds the verified hardware identity to the live TLS socket. It reconstructs
$$Payload_{client} = Protobuf(SHA256(EKM_{client}), SHA256(T_{attest}))$$ and verifies the ECDSA P-256 signature ($$Sig_{session}$$ ) using$$PubKey_{instance}$$ -
Policy Evaluation: The client parses the claims structure to enforce user-defined policies against the
AttestationPolicyprotobuf:-
Hardware Model: Evaluates
claims['hwmodel'](e.g.,"GCP_INTEL_TDX"). -
Workload Integrity: Evaluates
claims['submods']['container']['image_digest']to ensure the exact expected binary is running. -
Platform Isolation: Evaluates
claims['submods']['gce']['project_id']andinstance_idto prevent cross-tenant workload spoofing.
-
Hardware Model: Evaluates
The fundamental security guarantee of this SDK relies on an unbroken chain of trust linking the physical hardware, the software workload, and the live network transport. This trust is established through the following sequence of bindings:
-
Hardware Roots the Trust: The TEE hardware signs the attestation token (
$$T_{attest}$$ ) using a private key securely fused into the silicon, establishing undeniable proof of the platform's authenticity and the integrity of the measured workload. -
Token Binds to Instance Key: The SHA-256 fingerprint of the ephemeral Instance Public Key (
$$PubKey_{instance}$$ ) is embedded within theeat_nonceclaim of$$T_{attest}$$ before the hardware signs it. This proves to the client that the specific TEE described in the report is in possession of the corresponding$$PrivKey_{instance}$$ . -
Instance Key Binds to TLS Session: The server extracts the Exported Keying Material (
$$EKM_{svr}$$ ) from the active TLS session and signs it (along with a hash of$$T_{attest}$$ ) using$$PrivKey_{instance}$$ . Because the$$EKM$$ is deterministically derived from the TLS Master Secret, it uniquely identifies the live transport connection.
By verifying this entire chain (Hardware
PromptEncryptionClient: The top-level client object that owns the attestation policy and manages session lifecycle.AttestationPolicy: A protobuf-defined structure describing the trusted TEE state (hw_model, workload, and gce_instance).AttestedPoolManager& Lazy Revalidation: To maintain performance, the pool manager hooks intourllib3. Attestation is an expensive operation, so connections are reused. By default, connections are reused for up to 55 minutes, after which a new attestation handshake is transparently forced over the existing socket to ensure continuous TEE integrity and key freshness.
KeyManager: Manages the ephemeral cryptographic keys used in attestation token generation. It generates fresh signing keys, rotates them on a schedule, and maintains a brief overlap window during rotation.TokenManager: Runs in a background thread to proactively rotate the attestation tokens presented to clients, preventing latency spikes at rotation boundaries.AttestedTLS& EKM Extraction: Handles the post-handshake attestation exchange. Standard ASGI/WSGI servers abstract away the TLS socket. The middleware intercepts the ASGI scope and utilizes a custom C-extension (ekm/_ekm.c) to safely call OpenSSL'sSSL_export_keying_materialAPI.
When the client also runs inside a TEE, the same single /_attest-connection round trip can verify both directions: the client's proof travels in the request, the server verifies it before producing its own, and the server's proof travels back in the response.
That exchange drops the client and server nonces entirely and uses the TLS Exported Keying Material as the challenge — the EKM is already derived from both peers' handshake randoms, so it is unique and unforgeable per session. The consequence is that the binding is constant for the session's lifetime, so a mutually attested session is attested exactly once and is never revalidated; re-attestation means opening a new connection.
See Mutual Attestation for the protocol, the role/mode domain separation that replaces the nonces, and the API.
| Threat | Protected? | Mechanism |
|---|---|---|
| Network observer reading prompt/response | ✅ Yes | TLS encryption |
| Cloud operator reading prompt/response | ✅ Yes | TEE memory isolation + attested TLS |
| Infrastructure-layer observer (hypervisor, host OS) | ✅ Yes | TEE memory isolation |
| Attestation replay attack | ✅ Yes | EKM binding ties report to specific TLS session |
| MitM presenting valid cert but not a TEE | ✅ Yes | Attestation verification fails without TEE hardware key |
| Server running unexpected software | ✅ Yes | Workload measurement in policy evaluation |
| Debug-mode TEE weakening isolation | ✅ Yes | Policy validation (if configured correctly) |
| Threat | Protected? | Notes |
|---|---|---|
| Model weight confidentiality | ❌ No | Addressed by other Confidential Inference components |
| Malicious or compromised workload behavior | ❌ No | Attestation covers boot state, not runtime logic flaws/RCEs |
| Traffic analysis | ❌ No | Packet sizes and timing remain visible |
| Post-processing exfiltration | ❌ No | Depends entirely on the integrity of the workload inside the TEE |
| Denial of Service (DoS) | ❌ No | Hypervisor/Network operator can trivially drop packets |
- Pin Workload Measurements: A permissive policy accepting any workload on a given platform provides significantly weaker guarantees. High-assurance environments must pin specific workload hashes, requiring policy updates on every server-side deployment.
- Reject Debug Mode: Never accept debug-mode TEEs in production, as debuggers can inspect TEE memory.
- Validate Certificate Transparency: The attested TLS channel proves communication with a TEE. The server certificate proves which endpoint you are communicating with. Both checks are vital.
- Treat Policy as Code:
AttestationPolicyis a security-critical artifact. It must be version-controlled, strictly reviewed, and deliberately updated. Overly permissive policies silently destroy the SDK's security guarantees. - Attestation Cost Amortization: Generating fresh TEE quotes is computationally expensive. The SDK relies on connection reuse and background token rotation to maintain low-latency inference pipelines while preserving security guarantees.
- RFC 5705: Keying Material Exporters for Transport Layer Security (TLS)
- Intel Trust Domain Extensions (TDX) Architecture Specification
- AMD Secure Encrypted Virtualization-Secure Nested Paging (SEV-SNP)
- Google Cloud Confidential Computing
- IETF Draft: TLS Exported Authenticator (Basis for Post-Handshake Attestation)