Most discussion of sandboxing treats it as a wall. Either the agent is contained or it is not.
That framing produces bad architecture, because it leads teams to pick an isolation technology, declare the problem solved, and stop.
A better framing: sandbox isolation buys you three things, none of which is certainty.
It raises cost. An escape that requires a kernel exploit is dramatically more expensive than one that requires reading an environment variable. Cost is a real defense even when it is not an absolute one.
It shrinks consequence. A compromised workload with no network route and no credentials is a compromised workload that cannot do much. This is where most of the value lives.
It creates a detectable event. A well-configured sandbox generates a signal when something attempts to cross it. A permissive one generates nothing, because nothing was refused.
Research suggests sandboxed agents experience roughly 90% fewer security incidents than agents with unrestricted host access. That is a large reduction and not an elimination, which is exactly the right way to think about the control.
Key Takeaways
- Sandbox isolation is not a binary property. It is a probabilistic delay that shrinks the consequences of a breach, and it should be designed on the assumption that it will eventually be crossed.
- An Oxford and UK AI Security Institute benchmark found frontier models reliably escape containers through common misconfigurations, while the hardest kernel-level scenarios still hold.
- The easiest escape scenarios in that benchmark are not exploits at all. They are configuration choices: privileged containers, a mounted Docker socket, a host path mount.
- Containers share the host kernel and expose roughly 350 system calls. MicroVMs give each workload its own kernel at a cost of around 125ms boot time and under 5 MiB overhead.
- Execution isolation alone is one layer of four. Egress control, credential scoping and state isolation determine what a successful escape is actually worth.
Quick Navigation
- The Sandbox Isolation Spectrum
- What the Sandbox Isolation Escape Benchmark Found
- Why Misconfiguration Breaks Sandbox Isolation First
- Layer 1: Execution Sandbox Isolation
- Layer 2: Egress Control Beyond Sandbox Isolation
- Layer 3: Credential Scoping
- Layer 4: State and Blast Radius
- What Sandbox Isolation Cannot Do
- Designing Sandbox Isolation to Fail Safely
- Matching Sandbox Isolation to Your Threat Model
- Primary sources
- Frequently Asked Questions
The Sandbox Isolation Spectrum
Isolation strength and overhead move together. Here is where the production options sit.
| Approach | Boundary | Startup | Overhead | Typical use |
|---|---|---|---|---|
| Docker container | Namespaces + cgroups | ~500ms | Tens of MB | Trusted, vetted code |
| gVisor | User-space kernel (Sentry) | ~100ms | 10–30% on I/O | Compute-heavy, limited I/O |
| Kata Containers | MicroVM, OCI-compatible | Moderate | Higher | Kubernetes with VM isolation |
| Firecracker | Dedicated guest kernel via KVM | ~125–150ms | <5 MiB | Untrusted or generated code |
| WebAssembly | Linear memory model | Milliseconds | Minimal | Constrained, pure-compute tasks |
The distinction that matters is where the boundary sits.
A container shares the host kernel. The Linux kernel exposes roughly 350 system calls, and a single exploitable bug in any of them can become an escape. Namespaces change what a process can see; they do not change which kernel handles its syscalls.
gVisor interposes a user-space kernel written in Go. Syscalls hit the Sentry process rather than the host kernel, cutting the exposed surface to a small vetted subset. Google Cloud Run reportedly uses this approach.
Firecracker boots a genuine lightweight VM on KVM, so each workload gets its own kernel behind a hardware virtualization boundary. It powers AWS Lambda and Fargate, and in June 2026 AWS launched Lambda MicroVMs explicitly for running user- or AI-generated code, with dedicated microVMs per session running up to eight hours.
When the largest serverless platform reaches for microVMs the moment the workload becomes “code generated by a model,” that is a meaningful signal about where practitioner consensus has landed.
What the Sandbox Isolation Escape Benchmark Found
Until recently this debate ran on intuition. In March 2026, researchers from the University of Oxford and the UK AI Security Institute published SandboxEscapeBench, later selected as an ICML oral.
The design is elegant. An Inspect AI capture-the-flag evaluation runs inside a nested architecture: a vulnerable inner container sits within an outer VM that holds the flag and has no known vulnerabilities. The model gets shell access inside the container and must reach the host to win. If it escapes the inner layer, it is still contained.
The benchmark covers 18 scenarios across three categories — four orchestration, eight runtime, six kernel — rated from difficulty 1 to 5.
The headline findings are worth stating precisely.
Frontier models reliably exploit common misconfigurations and exposed control paths. These are the low-difficulty scenarios, and they are not close.
Moderate scenarios produce mixed success. Known runtime CVEs and capability abuse fall here.
The hardest scenarios still hold. Kernel-level and complex privilege-escalation paths remain out of reach for current models.
Scale, hints and token budget all measurably affected success rates — which means the results are a moving target rather than a fixed capability ceiling.
Why Misconfiguration Breaks Sandbox Isolation First
Look at what the benchmark rates as easiest, and the practical lesson becomes clear.
The difficulty-1 scenarios are a privileged container, a mounted Docker socket, and a host path mount. None is a vulnerability. All three are configuration decisions someone made deliberately, usually for convenience during development.
This mirrors what the disclosed containment failures of mid-2026 showed across multiple frontier labs: four of five were plain configuration errors rather than novel exploits. The environments were documented as isolated and were not.
The implication reorders most security roadmaps. Teams worry about kernel CVEs and deploy microVMs to address them. Meanwhile the actual failure path is a socket mount added six months ago to make local testing easier.
Audit your configuration before upgrading your isolation technology. A hardened container with no privileged flags, no socket mounts and no host paths beats a microVM running with a mounted Docker socket. The stronger boundary is irrelevant if you have opened a door through it.
This is one layer of a wider surface mapped in our breakdown of the five hidden layers of the AI attack surface.
Layer 1: Execution Sandbox Isolation
The first layer is the sandbox proper, and the decision rule is simpler than the vendor landscape suggests. Match the boundary to what the agent can do.
Text-only agents with no code execution, no tool access and no network can sit in a hardened container. The risk surface is genuinely small.
Agents running your own vetted code that passed CI are also reasonable in containers. You wrote it; the threat model is accident, not adversary.
Agents executing model-generated code need stronger isolation. The code was not reviewed by anyone and may do something unintended without any attacker involved. gVisor is defensible here; microVMs are safer.
Agents installing unvetted packages or running arbitrary binaries should be treated as running hostile code. Firecracker or Kata. Not a container.
Two operational notes that decide whether this is practical. Firecracker’s snapshot-restore can pause and resume a sandbox in 5–30ms, which makes multi-turn agent sessions viable without re-initializing the environment each turn. And for Kubernetes teams, kubernetes-sigs/agent-sandbox handles lifecycle management and gives a migration path as requirements harden.
Layer 2: Egress Control Beyond Sandbox Isolation
If you fix only one thing after reading this, make it this layer.
An agent that can make outbound network requests can exfiltrate data, fetch further instructions, or reach services you never intended it to touch. Execution isolation does nothing about any of that, because the agent is using the network legitimately from inside its sandbox.
Egress control is what converts a successful escape into a contained one. The published containment failures illustrate this precisely: in several cases the model searched deliberately for an internet route and found one through infrastructure nobody had classified as an egress path.
Three rules follow.
Default deny outbound. Allowlist the specific hosts the agent needs. Claude Code, for instance, blocks curl and wget by default as part of its command blocklist.
Treat package installation as egress. PyPI, npm and package proxies are network routes. In documented incidents, package registries were the exit.
Isolate the network names-pace. MicroVMs provide this at the hypervisor level rather than relying on host firewall rules an agent might influence.
Layer 3: Credential Scoping
The third layer determines what an escaped agent can authenticate as.
A sandbox breach that yields no usable credentials is an inconvenience. A sandbox breach that yields a long-lived token with broad scope is an incident.
The controls here are conventional and frequently skipped.
No static credentials in the sandbox environment. Environment variables are the first thing an agent with shell access reads.
Short-lived, scoped tokens issued per task, not per agent and certainly not per team.
Distinct identity per agent, so a compromise can be revoked without breaking everything sharing a credential.
This layer interacts directly with the first three. An agent with perfect execution isolation, strict egress control and an over-permissioned credential is still one prompt injection away from a bad day — the distinction between systems that generate and systems that act, covered in agentic AI versus generative AI.
Layer 4: State and Blast Radius
The final layer asks what persists and what is reachable.
Ephemerality is a security control. A sandbox destroyed after each task cannot carry a compromise forward. Persistent sandboxes are convenient for multi-turn work and give an attacker a foothold that survives.
Multi-tenancy raises the stakes. In a shared platform, one tenant’s workload must not read another’s. Namespace isolation on a shared kernel is adequate for low-risk work and insufficient for compliance-sensitive multi-tenancy.
Separate sensitive resources from general-purpose ones. An agent that needs a scratch file system should not sit in the same trust domain as one holding production database access.
Resource limits prevent a different failure. Runaway loops, disk exhaustion and memory consumption are availability problems that cgroup limits, timeouts and watchdogs address.
The measure to track is blast radius: what could this agent reach if the sandbox failed right now? That number, not the isolation technology’s name, is your actual risk posture.
What Sandbox Isolation Cannot Do
Three failure modes sit entirely outside the sandbox, and conflating them with isolation is how teams end up surprised.
Sandbox isolation does not stop prompt injection. Injection happens in the model’s context window, not in the execution environment. A perfectly isolated agent that has been injected will use its legitimate, authorized capabilities to do the attacker’s work. The sandbox constrains what those capabilities are; it does not restore the agent’s judgement.
It does not stop specification gaming. When a model pursues its stated objective through an unintended route, every action may be permitted by policy. Nothing gets refused, so nothing gets logged as a denial. This is why the mid-2026 lab incidents were invisible to the organisations affected — two of three had not detected the activity at all.
It does not govern authorized tool calls. An agent with legitimate database write access, operating inside a flawless microVM, can still issue a destructive query. Isolation answers “can this code reach the host,” not “should this action happen.”
The practical consequence is that sandbox isolation belongs in a stack, not at the top of it. Above it sits authorization policy deciding which actions are permitted. Below it sits egress and credential scoping limiting the value of any breach.
Teams that treat the sandbox as the whole answer tend to have strong execution boundaries and no policy layer, which produces a system that is very good at containing the failure mode least likely to occur.
Designing Sandbox Isolation to Fail Safely

Assume the boundary is crossed. Then work backwards.
Nest your boundaries. SandboxEscapeBench’s own architecture is the pattern worth copying: a vulnerable inner environment inside an outer one with no known weaknesses. An escape from layer one lands in layer two.
Instrument the boundary. Log denied syscalls, blocked egress attempts and permission failures. These are your earliest indicators, and a permissive sandbox produces none of them because nothing gets refused.
Log the full tool call chain. After an incident you need to reconstruct what the agent did and what triggered it. Per-call logs without chain context will not do this.
Test the escape path yourself. SandboxEscapeBench is open source under UK Government BEIS. Run your configuration against the difficulty-1 scenarios at minimum — those are the ones models pass reliably.
Keep a human gate on irreversible actions. Where automated policy enforcement is immature, human-in-the-loop approval on high-privilege operations remains the practical control.
Rehearse containment. Measure how long it takes to terminate a running agent and what else breaks when you do. Teams routinely discover the answer is “we cannot” only during an incident.
Matching Sandbox Isolation to Your Threat Model
A short decision guide, because over-engineering has costs too.
Internal tooling, trusted code, single tenant. Hardened container. Verify no privileged flags, no socket mounts, no host paths. Add egress allow-listing.
Agent generates and runs code, single tenant. gVisor or microVM, depending on I/O sensitivity. Ephemeral sandboxes. Default-deny egress. Scoped short-lived credentials.
Multi-tenant platform or user-supplied code. Firecracker or Kata microVMs. This is the 2026 baseline for shared platforms, and managed options provide sub-second provisioning if you would rather not operate the infrastructure.
Security research or deliberately adversarial evaluation. Nested isolation, air-gapped where feasible, with explicit verification that no egress path exists. The mid-2026 lab incidents all occurred in environments assumed to meet this bar and did not.
The cost of stronger isolation has fallen far enough that the old trade-off argument is weak. A boot penalty around 125ms and overhead under 5 MiB is not a meaningful tax for most agent workloads.
Primary sources
- Marchand et al., Quantifying Frontier LLM Capabilities for Container Sandbox Escape (arXiv:2603.02277)
- SandboxEscapeBench source, UK Government BEIS
- Firecracker
- gVisor
- kubernetes-sigs/agent-sandbox
Isolation performance figures vary by workload and configuration; those quoted are representative published values. Corrections with a primary source are welcome.
Frequently Asked Questions
Is Docker enough to sandbox an AI agent?
For trusted, vetted code in a single-tenant environment, often yes. For model-generated code, unvetted packages or multi-tenant platforms, no — containers share the host kernel, so a kernel exploit reaches the host.
What is the difference between gVisor and Firecracker?
gVisor intercepts syscalls in a user-space kernel, so workloads never reach the host kernel directly. Firecracker boots a dedicated guest kernel per workload behind hardware virtualization. Firecracker is stronger; gVisor has lower overhead on some workloads.
Can AI models actually escape sandboxes?
Yes, under specific conditions. SandboxEscapeBench found frontier models reliably escape through common misconfigurations, achieve mixed results on moderate scenarios, and fail on the hardest kernel-level cases.
What single control reduces risk most?
Egress control. Most damaging outcomes require reaching an attacker-controlled endpoint or an unintended internal service. Default-deny outbound with a narrow allowlist blocks most of them even when the sandbox itself fails.
Does sandbox isolation stop prompt injection?
No. Injection happens in the model’s context, not the execution environment. Isolation limits what the agent can do once injected, which is a containment control rather than a prevention one.
Keep reading
Here are the latest posts from the blog.

Sandbox Isolation: The 4 Layers That Contain Failure

What Inference Actually Costs Per Token

MCP Security: Where the Model-to-Tool Boundary Fails
