Trusted execution: enclaves, the threat model they actually change, and what they cost

An enclave removes the host operator, hypervisor and co-tenants from the trust boundary of one small computation. It does not make your code correct — so keep the trusted computing base tiny and the interface narrow.

Read the briefing
About 4 min to read 6 drills

What to remember

  1. The honest claim is 'the operator cannot read the key', not 'the system is secure'. TEEs change who is in the trust boundary. Bugs in your enclave, a poisoned build and side channels are all still yours.
  2. Nitro Enclaves have no network, no disk, no shell — only a vsock to the parent. That constraint is the feature: the attack surface is one explicit API you wrote and can audit.
  3. Small TCB, narrow interface, no dynamic code. Everything inside the enclave is something you must reproduce, measure and defend. Put the signing function in, not the application.
  4. You lose the debugger. No shell, no attach, deploys gated on measurement. Design observability out through the vsock before you need it.
  5. Preallocate memory and pin vCPUs. The signing path should have no allocation and no scheduling surprises — the same tail-latency discipline as any hot path.

The big picture

Trusted execution environments let a specific computation run where the machine's operator cannot see into it. This topic is about what that actually buys, what it costs in engineering and operations, how the main technologies differ, and how to design an enclave whose claims you can defend in a security review.

The mental model

Draw the trust boundary as a box. A TEE lets you shrink the box to exclude the hypervisor, the host operator and the neighbours — but everything inside the box is still yours to get right, and every dependency you drag in makes the box bigger.

In depth

What it changes, and what it does not

A TEE gives you confidentiality and integrity for a computation against a privileged host: the operator cannot read enclave memory, the hypervisor cannot introspect it, and a co-tenant cannot reach it. That is a genuine and unusual property — it is what makes "we run signing in a shared cloud" defensible.

What it does not do: fix bugs in your enclave code, stop a malicious or careless build from being measured and admitted, eliminate side channels (a long research literature, particularly for SGX), or protect data once your own code sends it out. If your threat model is "a developer with commit access", a TEE is not the control; review, signing and attestation policy are.

Nitro Enclaves in practice

An enclave is carved from the parent instance's own vCPUs and memory, declared at launch. It has no network, no persistent storage, no interactive access, and no SSH — the sole channel is a vsock to the parent. That forces every capability to be an explicit message on an interface you designed, which is exactly what makes a security review tractable: "what can this thing do" has a finite answer.

Practical consequences. The parent is untrusted plumbing: it proxies KMS calls, feeds requests and collects responses, and it must be assumed hostile in your protocol design. Secrets come in as ciphertext the enclave can decrypt only because KMS releases the data key against its attestation. Observability leaves through the vsock as structured events you chose to emit, because there is no other way to see inside.

Choosing a technology

Intel SGX: process-level enclaves, smallest trusted computing base, requires structuring code into trusted and untrusted halves, and carries the most side-channel history. AMD SEV-SNP and Nitro Enclaves: VM-level isolation, larger TCB (a kernel is inside), much easier porting — you mostly lift an existing process. Confidential GPUs and CVMs extend the same model to accelerators and whole VMs.

The decision follows two questions: how little code can you afford to trust, and how much rewriting can the team absorb? For a signing service, VM-level isolation with a tiny purpose-built binary usually wins, because the porting cost of SGX buys a smaller TCB than you need.

Designing one you can defend

Keys generated inside and never leaving; a deterministic request/response protocol with no dynamic code loading or plugins; preallocated memory and pinned vCPUs so the hot path has no allocation or scheduler variance; strict input validation, because the parent is hostile; explicit rate limits and policy inside the enclave rather than in the caller; and structured audit events emitted over vsock for every operation. Then the deployment story: measurement-gated release, a reproducible build, and an inventory of which measurements are currently allowed to obtain keys.

Myths and facts

Myth: An enclave makes the application secure.

Fact: It removes the host from the trust boundary for one computation. Your code, your build pipeline and your interface are still the attack surface.

Myth: Enclaves are for running the whole service.

Fact: Everything inside must be reproduced, measured and defended. Enclaves are for the smallest high-value function — usually signing or key handling.

Myth: You can SSH in to debug it.

Fact: There is no network and no shell. Observability has to be designed as vsock messages before you need it.

Myth: SGX is strictly more secure than VM-level TEEs.

Fact: It has a smaller TCB and a longer side-channel record; the right choice depends on how much code must be trusted and how much rewriting is realistic.

Myth: Enclave memory is free capacity.

Fact: It is reserved away from the parent by the allocator service, along with the vCPUs, for as long as the reservation stands — capacity planning has to account for it.

How pros do it

  • Put only the high-value function inside; treat every added dependency as trusted-computing-base growth.
  • Generate keys in the enclave, never export them, and release data keys only against attestation.
  • Treat the parent as hostile: validate all input, enforce policy and rate limits inside.
  • Preallocate memory, pin vCPUs, and keep the signing path allocation-free.
  • Design audit and metrics as explicit vsock events, and plan for having no debugger.

Questions people ask

How does a secret get into an enclave safely?

As ciphertext the parent cannot read. The enclave calls KMS through a vsock proxy on the parent and includes its attestation document; the key policy releases the data key only for matching measurements, and KMS encrypts the response to the enclave's public key, so the parent relays bytes it cannot open. The caveat: the parent still controls whether traffic flows at all and sees its timing, so treat it as hostile plumbing and keep policy inside.

What happens on a rebuild?

The measurements change, so the key policy or allow-list has to admit the new ones before the deploy — or signing stops. Add the new measurement alongside the old, deploy, verify, then remove the old: expand, migrate, contract. Pinning the signing certificate rather than the image hash avoids the policy change for your own rebuilds.

Can I run a whole web service in an enclave?

You can, and you will regret it. Everything inside is trusted computing base you must reproduce byte-for-byte, measure and defend, with no debugger — so the TCB, the build and the incident story all get worse. Split out the trust-critical function, usually signing or key handling, and leave the application outside.

Are side channels a practical concern?

For most threat models, no — and say so rather than overclaim. The published attacks are mostly against SGX and need co-residency and time; for 'a cloud operator reading a key at rest', VM-level isolation is sufficient. The honest caveat is that side channels are a residual risk you accept, not one the hardware removes.

How do I test enclave code?

Outside the enclave first. Build the same binary to run as a normal process for unit tests, keep the vsock protocol thin enough to fake, and reserve real enclave runs for integration and attestation tests. The caveat is that anything you cannot exercise outside — KMS release against attestation, the allocator's reservation — needs a real run before you trust it.

Further reading

Drills · 6

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Pick the strongest answer

You run signing inside a Nitro Enclave. A counterparty's security team asks what that actually protects against. What do you tell them?

  1. It removes the need for key rotation and multi-sig. It complements them; custody tiering and quorum are separate controls.
  2. Even a developer with commit access cannot cause an unauthorised signature. Only true if attestation policy plus review plus signing gates make that build unadmittable — that is a pipeline claim, not a TEE claim.
  3. The key cannot be misused because the enclave is cryptographically secure. Vague and false — the enclave will sign whatever your admitted code decides to sign.
  4. The cloud operator, the hypervisor and co-tenants cannot read the signing key or the enclave's memory; the key is generated inside and never leaves. It does not protect against a bug in our enclave code or a build we measured and admitted. Precise about what moves outside the trust boundary and what stays inside it.
In short

Say the operator, hypervisor and other tenants cannot read the key, and say bugs in your own code are still your problem.

Why

The value of a TEE in a diligence conversation is precision. Saying exactly which adversary is excluded — and admitting which ones are not — is what makes the rest of your security story believable.

The common mistake

Overclaiming. "Even someone with commit access cannot get a bad signature" is a pipeline claim — attestation policy, review, signed builds — not something the hardware gives you, and a good interviewer will pull on it.

Read the docs

2 Answer out loud

Walk me through how you would design a signing service for cloud-hosted trading on a TEE. Where is the trust boundary, what does the interface look like, how do keys and secrets get in, how do you see what it is doing, and what does it cost you? Five to seven sentences.

In short

A strong answer names who the enclave keeps out and who it does not: your own code, your build, and side channels.

What a strong answer does
  • trust boundary: States precisely who is excluded and who is not (own code, build pipeline, side channels), and where those residual threats are handled instead.
  • design: Minimal TCB, fixed message types, in-enclave policy and rate limits, keys generated inside, KMS attestation for any imported secret, preallocated memory and pinned vCPUs, structured vsock audit events.
  • operations: Reproducible pinned builds, overlapping allowed measurements during rollout, measurement inventory, no debugger so observability is designed in, capacity taken from the parent.
  • honesty: Names the residual risk and what it would take to reduce it, in the language a counterparty or auditor would use.
Why

Staff answers are precise about the boundary, keep the TCB small, put policy inside, and name the operational costs and residual risk without flinching.

The common mistake

Describing the enclave as the whole service. The moment the application goes inside, everything in it is something you must reproduce, measure and defend; put the signing function in and keep the rest out.

3 Pick the strongest answer

You are designing what the signing enclave will accept over the vsock, and where policy lives. Which of these would you build?

  1. A general-purpose RPC surface inside the enclave so future use cases need no redeployment. A wide interface is a wide attack surface and makes the measurement meaningless as a description of behaviour.
  2. Let the parent enforce policy and rate limits, keeping the enclave minimal. The parent is untrusted; policy enforced there can be bypassed by whoever controls the host.
  3. Allow the enclave to load signing plugins at runtime for flexibility. Dynamic code destroys the link between the measurement and what actually runs.
  4. A single vsock request/response protocol with a fixed set of message types, strict validation, policy and rate limits enforced inside, keys generated in-enclave, and structured audit events emitted for every operation. Narrow, explicit, self-policing, and observable without a shell.
In short

Use one small vsock protocol with fixed message types, and keep the policy, rate limits and keys inside the enclave.

Why

The enclave's measurement is a statement about its behaviour, which is only useful if the behaviour is fixed and narrow. Policy inside, no dynamic code, one small protocol.

Read the docs

4 Find what's broken

A team hands you this enclave deployment for security review before launch. Five lines defeat the reason an enclave was chosen. Find all five.

# enclave deployment description
enclave_cpu_count = 2
enclave_memory_mib = 512
contents = ["signing-binary", "python3", "pip-packages", "openssh-server", "debug-shell"]
key_material = "imported at start-up from the parent over vsock, as plaintext"
policy_enforcement = "in the parent process"
observability = "none; attach a debugger if needed"
build = "docker build from :latest base image"
In short

The five bad lines are the plaintext key from the parent, the SSH server and debug shell, policy in the parent, no observability with a debugger plan that cannot work, and the :latest base image.

What's broken
  • Line 5: Key material is imported as plaintext from the untrusted parent, so the host operator sees the key — the exact property the enclave was chosen for.
  • Line 4: An SSH server and debug shell inside the enclave create an interactive path into the trusted boundary and inflate the TCB enormously.
  • Line 6: Policy is enforced in the parent, which is untrusted — whoever controls the host removes the policy.
  • Line 8: Building from a :latest base image makes the build non-reproducible, so the measurement corresponds to nothing you can re-derive.
  • Line 7: No observability is designed in, and the fallback — attaching a debugger — does not exist for an enclave: there is no shell and no attach, so the first incident is a black box.
Why

Two vCPUs and 512 MiB (lines 2–3) are sizing choices, defensible or not depending on the workload — the reviewer's question there is "why", not "no". The five flagged lines each destroy a property the enclave exists to provide, or leave you blind when it fails.

Read the docs

5 Quick recall

The enclave has no network. So how does a signing request reach it, and how does it call KMS?

In short

Only through the parent, over a vsock; the parent proxies its KMS calls.

Accepted

vsock · a vsock · vsock socket

Why

Everything crosses one vsock to the parent: the parent feeds requests in and relays the enclave's KMS calls out through a vsock proxy. That single channel is what makes 'what can this thing talk to' a finite, auditable answer.

6 Scenario: what do you do next?

The signing enclave starts failing to launch after a routine dependency bump: nitro-cli run-enclave reports insufficient memory on half the fleet, and on the hosts where it does launch, signature latency p99 has doubled.

Step 1. First step?

  1. Roll back the dependency bump across the fleet immediately. Reasonable as a mitigation once you know it is the cause, but the diff is a two-minute check.
  2. Increase enclave memory on every host and move on. It may work, and it hides an image that grew for a reason nobody has examined.
  3. Diff the new enclave image against the previous one — size, dependencies, and the --memory and --cpu-count the launch now asks for — and compare that request with what the allocator service reserves on each host. The symptom pair — launch failures on some hosts, latency everywhere it runs — points at an image that grew and a fleet whose reservations are not uniform.
  4. Restart the parent instances. Does not address allocation, and takes signing offline.

Step 2. The bump pulled in a dependency that added 300 MB to the image, so the launch script's --memory was raised to make it fit; on the affected hosts that request now exceeds the pool the allocator reserves in allocator.yaml. Fix?

  1. Pin the dependency and stop bumping it. Freezes a security-relevant dependency, which is the wrong trade for an enclave.
  2. Move the enclave to a bigger instance type. The same growth will consume that too, and you have added cost without a control.
  3. Cut the enclave image back to what the trusted function needs, make the allocator reservation explicit and identical across the fleet in IaC, and re-measure latency — then treat image size as a reviewed property with a budget. Addresses TCB growth and the reservation drift, and turns image size into something the team watches.
  4. Raise the allocator reservation on every host until the new image fits. Buys time without asking why the trusted computing base grew by 300 MB.

Step 3. Systemic fix?

  1. Alert when enclaves fail to launch. Necessary but reactive; the budget check prevents it.
  2. A runbook step to check memory before deploying. Manual, and it will be skipped.
  3. An image-size and dependency budget checked in CI with the attestation build, the allocator reservation declared in IaC and identical across the fleet, and latency plus launch success as monitored SLIs on the signing path. Makes TCB growth visible at review time and reservation drift impossible by configuration.
In short

First diff the new enclave image against the old one — its size, its dependencies, and the memory and CPUs the launch now asks for — against what each host reserves.

Why

Enclaves make ordinary dependency growth into a security and capacity event at once. The interview signal is treating image size as a reviewed property of the trusted computing base, not just as a build artefact.

Read the docs

Next lesson SOC 2, MiFID II and MiCA for engineers: controls, evidence, and audits you can pass twice
Drill · Trusted execution
0:00

Loading…