Application-Level Isolation
Intel SGX (Software Guard Extensions) is Intel's TEE implementation, available on many Intel Core and Xeon processors since 2015. It allows a developer to designate a specific region of their application's memory as a protected Enclave. Think of it as drawing a circle around the most sensitive function in your code and telling the CPU: "Protect everything inside this circle."
How SGX Works in Practice
SGX introduces new CPU instructions to manage the enclave lifecycle:
ECREATE— Creates a new enclave and allocates its protected memory region (called the EPC, Enclave Page Cache).EADD— Adds pages of code or data into the enclave.EINIT— Finalizes the enclave, making it immutable and ready to run.EENTER/EEXIT— Transitions execution into and out of the enclave.
The enclave runs in the same process address space as the untrusted application, but the hardware prevents the untrusted portion from reading the enclave's pages.
SGX Trade-offs
| Aspect | Detail |
|---|---|
| Granularity | Very fine-grained. Only the sensitive function (e.g., key signing) runs in the enclave. |
| Attack Surface | Minimal — only the small enclave code is in the trust boundary (Trusted Computing Base). |
| EPC Size Limit | The protected memory region is limited (historically ~128MB on older hardware, larger on newer Xeon). Exceeding it causes performance-degrading page swaps. |
| Development Complexity | High. You must rewrite or adapt your application using SDKs like Open Enclave, Gramine (formerly Graphene), or Intel's own SGX SDK. |
| Side-Channel Attacks | SGX has been subject to several academic attacks (Spectre, Foreshadow, SGAxe) that exploit CPU microarchitectural side channels. Intel has mitigated most via microcode updates, but this remains an active research area. |
Gramine is worth highlighting: it is a library OS that lets you run unmodified Linux applications inside an SGX enclave, dramatically reducing the porting effort.