
AWS Nitro Sandboxes: Hardware Isolation for AI Agents and Untrusted Code
A complete technical guide to AWS Nitro Sandboxes, explaining how to run each EKS pod, ECS task, or AI agent in its own hardware-isolated virtual machine, including setup, isolated vs confidential modes, and security best practices.
Cybersecurity Student | Pentester | AWS Cloud Learner
When you run containers on AWS, every pod or task on the same EC2 instance shares a single Linux kernel. If an attacker exploits a kernel vulnerability and escapes their container, they can reach every other workload on that host. For years, the only solution was to give each workload its own dedicated EC2 instance. That was secure, but expensive and inefficient.
In November 2026, AWS changed the game with AWS Nitro Sandboxes.
Nitro Sandboxes give every EKS pod, ECS task, or AI agent its own hardware-isolated virtual machine, even when they all share the same physical EC2 instance . You get the security boundary of a dedicated instance without paying for one.
This guide will explain what Nitro Sandboxes are, how they work, the difference between isolated and confidential modes, how to set them up, and why this matters for the future of AI and multi-tenant security.
1. The Problem: Shared Kernels and Container Escapes
Containers are popular because they are lightweight. But that lightness comes from sharing the host operating system's kernel. A single kernel vulnerability, like a container escape, can expose every container on the machine.
The AWS Compute Blog explains it clearly: "A weakness in the shared kernel reachable by one container also exposes every other container on the host. With the current rate of Linux Common Vulnerabilities and Exposures (CVEs), containerized workloads need an architecture that isolates each workload from other workloads and from cluster operators" .
Before Nitro Sandboxes, if you needed true isolation, you launched a separate EC2 instance for every tenant or workload. This worked, but it left you paying for idle capacity and managing many more instances than necessary.
2. What Are AWS Nitro Sandboxes?
A Nitro Sandbox is a lightweight virtual machine managed by the Nitro Hypervisor. Each sandbox gets its own kernel and a hardware-enforced boundary from the parent instance and from every other sandbox .
Here is the key concept: The sandbox runs on your EC2 instance, but it is not the EC2 instance.
Think of it like this. You have one large EC2 instance (the parent). Inside that instance, you can run multiple Nitro Sandboxes. Each sandbox is a child VM that uses the parent's CPU, memory, and I/O, but the Nitro System enforces strict separation. The parent cannot read the sandbox's memory. Other sandboxes cannot reach it .
Key facts about Nitro Sandboxes:
- Launch date: November 9, 2026 .
- Availability: Most Nitro-based EC2 instances in all commercial regions .
- Cost: No additional charge. You pay only for the underlying EC2 instance and normal EKS/ECS fees .
- Performance: Near-native EC2 performance because there is no nested hypervisor .
3. Isolated vs. Confidential: Two Modes of Trust
Nitro Sandboxes offer two isolation modes, and choosing the right one depends on who you trust.
3.1 Isolated Mode
Who it trusts: It trusts the EC2 host instance (and the cluster operator) but does not trust the workload running inside the sandbox.
What it protects: The host and other workloads from a compromised container. If an attacker escapes the container inside the sandbox, they are still trapped inside the sandbox VM. They cannot reach the parent instance or other sandboxes.
What it does not protect: The host can still access the sandbox. The cluster operator can exec into the container, read its logs, and see its processes. This is useful for debugging and normal operations .
Best for: Multi-tenant SaaS applications, CI/CD build jobs, and AI agents running code where the primary concern is preventing lateral movement.
3.2 Confidential Mode
Who it trusts: It does not even trust the EC2 host or the cluster operator.
What it protects: Your data and code from everyone outside the sandbox, including the instance operator and AWS itself. The sandbox's memory is moved out of the parent's reach using Nitro Enclaves technology .
How it works: The sandbox generates a cryptographic attestation document. This document proves exactly what code is running inside. You configure an AWS KMS key policy that releases secrets only when the attestation measurements match. If someone tampers with the environment, the measurements change, and KMS refuses to release the key .
Important limitation: Confidential mode does not protect data from the workload itself. If your application code writes secrets to stdout, the host can read them. The runtime cannot stop your own code from defeating its own confidentiality .
Best for: Regulated industries (healthcare, finance), processing sensitive customer data, and workloads where the platform operator must not be able to see the data.
4. How to Set Up Nitro Sandboxes
The setup process is different for EKS, ECS, and standalone EC2.
4.1 On Amazon EKS
Option A: EKS Auto Mode (Easiest)
If you are using EKS Auto Mode, enabling Nitro Sandboxes is a one-line change .
Add
runtimeClassName: isolated-sandbox (or confidential-sandbox ) to your Pod spec:yaml
apiVersion: v1kind: Podmetadata: name: my-agentspec: runtimeClassName: isolated-sandbox containers: - name: runner image: my-agent-imageEKS Auto Mode will automatically provision a node that supports sandboxes, and each pod gets its own VM .
Prerequisites:
- Kubernetes 1.36 or later .
- The
isolated-sandboxandconfidential-sandboxRuntimeClasses must exist. Verify withkubectl get runtimeclass.
Option B: Managed Node Groups (More Control)
Managed node groups require a custom AMI. You need:
- Amazon Linux 2023 with kernel 6.18.51 or later .
- Firecracker v1.18.0 or later.
- containerd 2.0 or later.
- The
nitro_enclaves.mempoolkernel parameter set (e.g.,95%-1G) .
-
EnclaveOptions.Enabled=truein the launch template .
- Node label
eks.amazonaws.com/nitro-sandbox=true.
AWS provides a script in the
amazon-eks-ami repository called install-pod-isolation.sh that builds this AMI using Packer .4.2 On Amazon ECS
ECS Nitro Sandboxes run on Amazon ECS Managed Instances only. They are not available with the EC2 or Fargate launch types .
Step 1: Enable Nitro Sandbox on the capacity provider.
Set
nitroEnclavesEnabled to true in the capacity provider's InstanceLaunchTemplate .Step 2: Set the isolation mode in the task definition.
json
{ "trustedExecutionConfiguration": { "isolationMode": "ISOLATED_SANDBOX" }}For confidential mode, use
CONFIDENTIAL_SANDBOX and provide an attestationPolicy .Step 3: Launch the task.
No application changes are required. From the workload's perspective, it looks like a normal Linux container .
4.3 On Self-Managed EC2
For full control, you can run Nitro Sandboxes directly on EC2 with your own AMI and orchestration. You manage the virtual machine monitors (VMMs) yourself. Amazon Linux and Firecracker are natively supported .
Critical security warning: If the parent instance routes sandbox traffic, block traffic from sandboxes to
169.254.169.254 . Otherwise, generated code inside the sandbox could read the parent's instance metadata and steal its IAM role credentials .5. The AI Agent Connection: Why This Matters Now
The biggest driver behind Nitro Sandboxes is the rise of AI agents that generate and execute their own code.
When an LLM writes code and an agent runs it, that code is untrusted. A prompt injection attack could trick the agent into running malicious code. If that code runs in a shared container, it can reach other workloads. If it runs in a Nitro Sandbox, it is trapped in its own VM, which is deleted when the session ends .
This is a perfect fit for AI agent platforms. Each user session or agent task gets its own sandbox. If the agent is compromised, the blast radius is limited to that one sandbox.
6. Performance and Density Limits
Nitro Sandboxes are efficient, but they have limits you must understand.
Limit | Value | Why It Matters |
|---|---|---|
vCPU per sandbox | Up to 5x the instance's vCPUs (time-sliced) | Allows oversubscription, but CPU-bound workloads will compete |
Memory per sandbox | Reserved at boot, not shared | Memory is the primary constraint for density |
Sandboxes per instance | Up to 896 (instance-dependent) | Plan your instance size carefully |
Network bandwidth | Default 100M bandwidth, 1,500 packets/sec | Data-heavy agents will be throttled |
Outbound connections | 4,096 per IP family | Agents opening many connections will hit this |
DNS queries | 100/sec default, 512 max | Crawlers and tool fan-out can exhaust DNS |
Cost calculation example: A 2 vCPU / 4 GiB sandbox running for one hour costs approximately $0.05 to $0.07 on an
m7g.2xlarge instance holding 5-6 sandboxes. This is significantly cheaper than dedicated instances, but it assumes your nodes stay full .7. Security Best Practices
1. Choose the right mode.
Start with isolated mode. Move to confidential mode only when the people or software operating the instance must not see the data .
2. Treat task definitions as trusted inputs.
For confidential mode, the task definition and attestation policy are trusted. Restrict who can register task definitions and run tasks using IAM. An actor who can author a task definition chooses the image and mounts .
3. Always use attestation-gated KMS keys for confidential workloads.
Without external verification, attestation is passive. A modified environment still starts; KMS just refuses to release the key .
4. Block metadata service access on self-managed EC2.
If the parent routes sandbox traffic, block
169.254.169.254 to prevent credential theft .5. Audit your container images.
Confidential mode protects data from the host, but not from your own code. Review what your application does with secrets after decrypting them .
8. Final Summary
AWS Nitro Sandboxes solve a fundamental problem in cloud security: how to run untrusted workloads safely without the cost of dedicated instances.
By giving every EKS pod, ECS task, or AI agent its own hardware-isolated VM, you get the security of separate instances with the efficiency of shared infrastructure. Isolated mode protects neighbors from compromised workloads. Confidential mode protects workloads from everyone, including the platform operator.
For cybersecurity professionals and AI builders, this is a critical new tool. As AI agents become more autonomous, the ability to contain their code execution is no longer optional. Nitro Sandboxes make it practical.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article