Intel SGX & TDX
Hardware Security Architecture · Hardware Foundations track
13 min read
In this module
Enclaves: Isolation Inside the Process
Intel Software Guard Extensions (SGX) approaches hardware security from a very different angle to ARM TrustZone. Where TrustZone splits the whole system into two worlds, SGX carves isolated memory regions called enclaves inside individual user-space processes. The CPU encrypts an enclave's memory, putting it out of reach for every other piece of software on the box — kernel, hypervisor, BIOS, even other enclaves.
The threat model is the unusual part. SGX treats the OS, hypervisor, and firmware as untrusted. The trusted set is just the CPU hardware and the code inside the enclave. That model was built for cloud computing, where a tenant wants to run sensitive code on a server they don't really control.
Enclave Memory Architecture
SGX reserves a slice of physical memory called the Enclave Page Cache (EPC). On SGX1 that's typically 128 MB (about 93 MB usable once metadata takes its cut). The BIOS carves the EPC out of DRAM at boot, and the CPU's Memory Encryption Engine (MEE) encrypts everything written to EPC pages.
The MEE sits between the last-level cache (LLC) and the memory controller. Software never sees it operate:
- When a cache line belonging to an enclave gets evicted from the LLC to DRAM, the MEE encrypts it under a key only the CPU knows and computes a MAC for integrity.
- When the line comes back from DRAM, the MEE decrypts and verifies the MAC. MAC failure (tampering) triggers a machine check exception.
That's the client design. The MEE also keeps a tree of counters so that an attacker can't replay an old, validly MACed line, and the tree is a big part of why EPCs stayed small. Scalable SGX on Xeon (Ice Lake SP onwards) drops it: EPC pages are encrypted with the same AES-XTS engine as Total Memory Encryption (TME-MK), with integrity checking but no replay-protection tree. That's how the EPC grows to hundreds of gigabytes, and it's also why physical attacks on the memory bus came back into play (more on that below).
So enclave data is only ever plaintext inside the CPU package — caches and registers. In DRAM it's always ciphertext. An attacker probing the memory bus, or running a cold boot attack, sees garbage.
The EPC is the protected physical memory region where enclave pages reside. It is finite (up to 128 MB on client SGX parts; up to 512 GB per socket on Scalable SGX Xeons) and shared among all enclaves on the system. SGX2 doesn't make the EPC bigger; it adds instructions (EAUG, EMODPR and friends) that let an enclave add pages and change permissions after it's been built. The SGX driver can page enclave pages in and out of the EPC using hardware-assisted encryption, allowing enclaves to use more virtual memory than the EPC's physical size, at a performance cost.
Enclave Lifecycle
An enclave goes through a defined lifecycle controlled by dedicated CPU instructions:
Creation
-
ECREATE: The untrusted application allocates an enclave within its virtual address space and calls ECREATE, which sets up the SGX Enclave Control Structure (SECS) - a metadata page that records the enclave's base address, size, and attributes.
-
EADD: Each page of enclave code and data is added to the EPC using EADD. The CPU records the page's virtual address, permissions, and type in the Enclave Page Cache Map (EPCM) - a hardware structure that tracks every EPC page.
-
EEXTEND: For each page, EEXTEND hashes the page contents into a running measurement (256 bytes at a time). This builds the enclave's MRENCLAVE - a SHA-256 hash of the enclave's initial code and data, including the order in which pages were added and their permissions.
-
EINIT: Finalises the enclave. The CPU verifies the enclave's signature (an RSA-3072 signature produced by the enclave author) and locks the MRENCLAVE measurement. After EINIT, no more pages can be added (in SGX1) and the enclave is ready to execute.
Execution
-
EENTER: The untrusted application transfers control into the enclave. The CPU switches to enclave mode, enables the enclave's memory mappings, and jumps to a predefined entry point. EENTER itself doesn't scrub the general-purpose registers: the untrusted caller can pass anything in them, so the SDK's entry code inside the enclave sanitises register and flag state before running enclave logic.
-
EEXIT: The enclave returns control to the untrusted application. EEXIT doesn't clear registers either, so the SDK's exit code wipes everything except the return value before executing it, or enclave secrets would leak out in registers. (An asynchronous exit, AEX, caused by an interrupt is different: there the hardware saves the enclave's registers inside the enclave and loads synthetic values.)
Destruction
- EREMOVE: Removes individual enclave pages from the EPC.
Interrupts and Exceptions
If an interrupt or exception fires while the enclave is running, the CPU performs an Asynchronous Enclave Exit (AEX). It dumps enclave register state to a State Save Area (SSA) inside the enclave, scrubs all registers, then hands control to the OS interrupt handler. The OS can't peek at the saved registers because the SSA lives in encrypted enclave memory. After the interrupt is handled, ERESUME restores enclave state and continues.
The full lifecycle as a state machine. The loop on the right is the one that matters later in this lesson: every interrupt hands control to the OS mid-computation, and the OS decides when the enclave gets to carry on.
Sealing: Persistent Enclave Storage
Enclave memory is volatile. Tear down the enclave or reboot the machine and it's gone. Sealing lets an enclave encrypt data so only the same enclave (or a related one) can decrypt it later.
SGX offers two sealing policies:
-
Seal to MRENCLAVE: Encrypted with a key derived from the enclave's exact code measurement. Only an enclave with byte-identical code can unseal it. The strictest policy. Even a minor code update yields a different measurement and breaks access.
-
Seal to MRSIGNER: Encrypted with a key tied to the enclave author's signing identity. Any enclave signed by the same key can unseal, which lets data move across code versions.
The sealing key is produced by the EGETKEY instruction, which mixes a hardware root key fused into the CPU with the enclave's identity (MRENCLAVE or MRSIGNER) and an optional key policy. The result is deterministic for a given CPU/enclave identity pair, so the enclave can rederive it after reboot without storing anything.
Sealing is the mechanism by which an enclave encrypts data bound to its identity and the specific CPU. The sealed blob can be stored on disk and later unsealed only by the same enclave (or same signer) on the same CPU. This enables persistent storage without trusting the file system.
Attestation: Proving Enclave Identity
Attestation lets an enclave prove to a remote party that it's running on genuine SGX hardware, with a specific code measurement.
Local Attestation
Two enclaves on the same platform can verify each other through local attestation. Enclave A asks the hardware for a report containing its MRENCLAVE measurement, MRSIGNER, and user-defined data. The report carries a MAC under a key only target enclave B can verify (derived from B's identity). Enclave B verifies via EGETKEY, confirming that the report came from genuine SGX hardware on the same platform and that A really has the measurement it claims.
Remote Attestation
Remote attestation allows a remote verifier (a server on the internet) to verify an enclave. The flow:
- The enclave generates a local report as above.
- A special Quoting Enclave (provided by Intel) verifies the local report and signs it with an attestation key to produce a quote.
- The quote is sent to the remote verifier.
- The verifier checks the quote's signature against Intel's attestation infrastructure, confirming the enclave is running on genuine Intel hardware with the claimed code.
That infrastructure has changed. Original SGX used EPID group signatures, and verifiers had to send every quote to Intel's online Attestation Service (IAS), which Intel has since retired. Current deployments use DCAP (Data Center Attestation Primitives): the Quoting Enclave signs with an ECDSA key whose certificate chains to Intel's root through the Provisioning Certification Service, so anyone holding Intel's published collateral (certificates, revocation lists, TCB levels) can verify a quote themselves. TDX reuses the same ECDSA quote format, with a TD Quoting Enclave signing the TD's report.
A trust chain runs from the CPU hardware, through the Quoting Enclave, out to the remote verifier — and the OS and hypervisor never have to be trusted along the way.
SGX Attacks and Deprecation
SGX's promise of untrusted-OS security drew researchers in droves. They came back with several classes of attacks:
Controlled-Channel Attacks
The OS manages the enclave's page tables (SGX protects memory contents, not access patterns), so a malicious OS can:
- Yank page table entries to force page faults, watching which pages the enclave touches.
- Read the Accessed and Dirty bits to trace enclave memory access patterns at page granularity.
These controlled-channel attacks spill the enclave's memory access pattern, which can betray secret-dependent code paths and data accesses.
Here's the trick against a branch that runs code on page A when a secret bit is 1 and page B when it's 0 (the page names are illustrative). The OS unmaps both, then reads the answer from the fault address it's handed, one bit per fault:
The enclave can't hide the fault either: SGX masks the low 12 bits of the faulting address, but the page number is exactly what the attacker wanted.
Foreshadow (L1 Terminal Fault)
Foreshadow (CVE-2018-3615) exploited a flaw in Intel's speculative execution. Even when a page table entry is marked not-present, the CPU still speculatively reads from the L1 cache using the physical address in the entry. An attacker could ride that to read any L1-resident data, enclave pages included. Devastating, because it sidestepped SGX's memory encryption entirely — the data was being lifted from L1, where it lives in plaintext.
Plundervolt
Plundervolt rode Intel's software-accessible voltage control interface. Undervolting the CPU during enclave computation produced controlled bit flips in arithmetic operations. The resulting faulty ciphertexts let attackers extract AES keys — classic differential fault analysis, only achieved by software voltage knob rather than physical probing.
SGX Deprecation
Intel pulled SGX from consumer CPUs starting with 11th-generation Core (Rocket Lake, 2021). The combined weight of these attacks, the mismatch between SGX's threat model and consumer use cases, and the silicon-area cost of the MEE all stacked up against keeping it on client platforms. One visible casualty: Ultra HD Blu-ray playback on PCs, whose DRM required SGX, stopped working on the newer chips. SGX lives on in Xeon server processors (Ice Lake, Sapphire Rapids, successors), where confidential cloud computing is the dominant use case and the bigger EPCs — up to 512 GB on some Xeon configurations — make it practical for server workloads.
SGX was removed from 11th-generation Intel Core consumer processors (2021 onward) but continues on Xeon server chips. The consumer deprecation reflected both the poor fit of SGX's threat model for client machines (where the user owns the hardware) and the accumulation of side-channel attacks that undermined confidence in the technology. Server-side SGX continues to receive silicon investment and security hardening.
Intel TDX: VM-Level Confidential Computing
Intel Trust Domain Extensions (TDX) is the next stop after SGX. Instead of isolating enclaves inside a process, TDX isolates whole virtual machines — Trust Domains (TDs) — from the hypervisor.
Architecture
TDX introduces a new software component called the TDX Module, running at a new privilege level (SEAM — Secure Arbitration Mode) between the hypervisor and the hardware. The TDX Module manages TD lifecycle and enforces isolation:
- The hypervisor can create, schedule, and destroy TDs but can't read or modify TD memory.
- TD memory is encrypted via Total Memory Encryption — Multi-Key (TME-MK), which gives each TD its own hardware-managed encryption key.
- The TDX Module sanity-checks every hypervisor action before it touches a TD, blocking a malicious hypervisor from injecting data or code.
Why TDX Succeeds Where SGX Struggled
TDX clears up several of SGX's pain points:
- No application changes: An entire existing VM — OS, applications, middleware — runs inside a TD with zero code modifications. SGX demanded extensive partitioning of app code into trusted and untrusted halves.
- Larger memory: TME-MK encrypts all TD memory at near-zero performance overhead, killing the EPC bottleneck. A TD can use full system memory.
- Simpler attestation: TD attestation verifies the entire VM, not individual enclaves. A cloud tenant ships a VM image and TDX proves that exact image is running unmodified.
- Smaller controlled-channel surface: The guest OS handles its own page tables inside the TD, so the hypervisor can't observe page-level access patterns the way a malicious OS could against SGX enclaves.
TDX underpins confidential computing offerings from the major cloud providers, letting customers run workloads in encrypted VMs that even the provider's infrastructure software can't peek into.
TDX vs SGX: Isolation Granularity
The key architectural difference is granularity:
| Property | SGX | TDX |
|---|---|---|
| Isolation unit | User-space enclave | Entire virtual machine |
| Code modification | Required (partition into trusted/untrusted) | None (run existing VMs) |
| Memory limit | Up to 128 MB EPC (client), up to 512 GB per socket (Xeon) | Full system memory |
| Memory encryption | MEE with integrity tree (client); TME-MK-based, no replay tree (Xeon) | TME-MK (with integrity, no replay tree) |
| Page table management | Untrusted OS | Guest OS inside TD |
| Attestation scope | Individual enclave | Entire VM |
| Primary use case | Specific sensitive computations | Full confidential VMs |
Same core goal in both technologies: protect computation from a compromised or untrusted privileged software stack. TDX's VM-level take has proven more practical for the industry's confidential-computing push. SGX's fine-grained take stays relevant for workloads that genuinely need enclave-level isolation on server hardware.
TDX's main competitor is AMD's SEV-SNP, which protects whole VMs on EPYC processors with per-VM keys and a reverse map table that stops the hypervisor remapping guest memory. Both have drawn their own research: Heckler (2024) abused the interrupts a malicious hypervisor can inject into confidential VMs on both SEV-SNP and TDX, WeSee (2024) did something similar with SEV-SNP's #VC exception, and TDXdown (2024) got around TDX's single-stepping defences. Then in 2025 three groups (WireTap, Battering RAM and TEE.Fail) built cheap interposers on the DRAM bus. Because server memory encryption is deterministic and has no replay protection, they could observe or replay ciphertext and went on to extract SGX attestation keys, forge SGX and TDX quotes, or break SEV-SNP guarantees. Intel's position is that a memory-bus interposer is outside what its memory encryption protects against, which is worth knowing before you promise a customer protection from the cloud provider's own staff.