Secure Enclaves
Low-Level Authentication & Crypto Hardware · Security Fundamentals track
6 min read
In this module
Isolation Beyond the OS
Traditional security takes the OS kernel as trusted, full stop. Compromise the kernel and the assumption falls. Cloud providers run your code on their silicon — do you trust their kernel? Secure enclaves answer with something blunt: hardware-enforced isolation that protects code and data even from privileged software, the OS kernel and hypervisor included.
Intel SGX: Software Guard Extensions
Intel SGX carves out isolated memory regions called enclaves. An enclave is a slice of virtual address space whose physical contents the CPU encrypts on the fly. The encryption key is born at boot and lives exclusively inside the CPU; it never lands in RAM, on disk, or on a bus.
Code running inside the enclave sees plaintext: the CPU decrypts on access. Code outside — yes, including the kernel — touching the same physical memory sees only ciphertext. The CPU itself becomes the sole trusted component on the trust boundary.
The SGX programming model splits the application down the middle: a trusted half lives inside the enclave, an untrusted half runs normally:
// Untrusted code (normal application)sgx_enclave_id_t eid;sgx_create_enclave("enclave.signed.so", &eid);
// Call into the enclave (ECALL)int result;ecall_process_secret(eid, &result, encrypted_input, input_size);
// The enclave processes the secret data internally// Even if the OS is compromised, it cannot read the enclave's memorySGX enclaves come with serious caveats. Enclave memory was originally capped at 128 MB (later expanded). Entering and exiting an enclave is expensive. Side-channel attacks — cache-based and speculative-execution flavours especially — have repeatedly punctured them. Intel pulled SGX from consumer CPUs starting at 12th-generation, but it lives on in Xeon server parts.
Before you ship secrets into an enclave, you want proof it's running the code you expect on genuine hardware. That's remote attestation. The CPU records a measurement of the enclave (a hash of its code and data) in a report, and a special Intel-provided quoting enclave on the same machine signs that report with an attestation key Intel has certified. A verifier checks the signature chain (genuine Intel hardware) and the measurement (the expected code is loaded).
ARM TrustZone
ARM TrustZone takes a wholly different architectural turn. Rather than spinning up isolated enclaves inside a process, TrustZone splits the entire system into two worlds: the Normal World, home to the OS and applications, and the Secure World, home to trusted firmware and security services.
Hardware enforces the split at every layer:
- CPU: each core can run in either world, with separate register banks and MMU configurations
- Memory: the memory controller enforces access policy — Secure World memory is invisible from Normal World
- Peripherals: each peripheral is assigned to one world, so Normal World software has no direct path to secure peripherals like the crypto accelerator or key storage
The Secure World runs a Trusted Execution Environment (TEE) — a minimal OS hosting trusted applications (TAs). Common TEEs include OP-TEE (open source), Trustonic's Kinibi, and Qualcomm's QSEE.
The diagram shows the two worlds side by side, with the EL3 secure monitor (Trusted Firmware-A on most designs) as the only bridge between them. Follow the arrows to see how a Normal World app reaches a trusted application: through its own kernel's driver, an SMC (Secure Monitor Call) instruction, and a world switch performed by the monitor.
TrustZone runs on a colossal share of mobile silicon, handling fingerprint processing, DRM key management, secure payment, and verified boot.
AMD SEV: Secure Encrypted Virtualisation
AMD SEV tackles the cloud trust problem head-on: how does a tenant know the cloud provider's hypervisor isn't reading their VM's memory? SEV encrypts each VM's memory with per-VM keys managed by the AMD Secure Processor — a dedicated ARM core sitting on the CPU die.
SEV (basic): VM memory is encrypted with a per-VM key. The hypervisor never sees plaintext.
SEV-ES (Encrypted State): also encrypts the VM's register state during context switches, so the hypervisor can't read registers either.
SEV-SNP (Secure Nested Paging): layers on integrity protection. The hypervisor can't replay old memory contents or remap pages without being caught.
Without SEV:VM Memory → RAM (plaintext) → Hypervisor can read everything
With SEV-SNP:VM Memory → AES encryption (per-VM key) → RAM (ciphertext) → Hypervisor sees only ciphertext → Integrity checks prevent tamperingAttestation Across Platforms
Every enclave technology offers attestation, but the wiring differs:
- SGX: quotes are signed with EPID keys, checked by Intel's online attestation service, or with ECDSA keys under DCAP (Data Center Attestation Primitives), checked against Intel-issued certificates
- TrustZone: attestation varies by vendor; some lean on GlobalPlatform TEE standards
- SEV-SNP: AMD's attestation uses the Secure Processor to sign VM measurements, with certificates rooted in AMD's key infrastructure
- Apple Secure Enclave: uses Apple's Device Attestation service for hardware verification
The shape is always the same. Hardware measures the software, hardware signs the measurement with a device-specific key, and a verification service walks the signature chain back to the silicon manufacturer.
Limitations and Attacks
Secure enclaves are not bulletproof. Researchers have landed plenty of solid hits:
Side-channel attacks: SGX enclaves share CPU caches and branch predictors with untrusted code. Foreshadow and Plundervolt pulled secrets out of SGX through speculative execution and voltage manipulation respectively.
Controlled-channel attacks: the untrusted OS still owns page tables for enclave memory. By tweaking page permissions, the OS can watch which pages the enclave touches, leaking information about its execution path.
Physical attacks: enclaves shrug off software, but physical access opens other doors. A cold boot attack on DRAM only gets encrypted enclave pages, since the memory encryption keys never leave the CPU, but power and electromagnetic side channels can sometimes leak keys from code running inside the enclave.
Each round of attacks has pushed the hardware forward: newer parts ship more side-channel mitigations, more integrity protection, and a slimmer attack surface. The lesson is durable. Hardware isolation lifts the bar far higher than software ever could, while not paving over every vector.
SGX gives per-process isolation with fine-grained attestation — handy for protecting one specific computation. TrustZone gives a system-wide secure/normal split — perfect for mobile security services. SEV gives per-VM isolation — the natural fit for confidential cloud computing. Pick by threat model and deployment shape.