Home โ€บ Blog โ€บ Sandboxing AI Agents: How to Let an Agent Act Without Letting It Escape
Topic Explainer ยท Security

Sandboxing AI Agents: How to Let an Agent Act Without Letting It Escape

Coding agents now run shell commands, install packages and browse the web on their own. This guide explains the boxes we put them in, from a few kernel flags on a laptop to a dedicated micro virtual machine in the cloud: what each layer stops, what it cannot stop, how often frontier models break out in controlled tests, and why a sandbox alone does not defeat prompt injection.

FL
FrontierAGI Team
โš ๏ธ How this was researched Everything here comes from web searches run up to 23 October 2026. Official documentation (Anthropic, OpenAI, Docker, AWS), arXiv papers and conference proceedings were preferred, but many performance and pricing figures exist only in vendor blogs and comparison sites, and several papers could be read only through their abstracts or third-party summaries. Each claim says where it comes from, and the section Reading the numbers lists the figures that conflict or could not be checked. The coverage tables and the "which layer stops what" matrix are this site's own analysis, not a published result.

Why sandboxing became the agent problem of 2026

A chatbot produces text, and a human decides what to do with it. An agent produces actions: it edits files, runs npm install, calls APIs, opens pull requests and reads web pages, often hundreds of times in one task. Every one of those actions runs with whatever permissions the agent's process has. On a developer laptop that usually means the developer's own account, with their SSH keys, cloud credentials, browser cookies and every repository they can reach.

The first answer was to ask the human before each risky step. It did not hold up. In its engineering write-up on Claude Code sandboxing, Anthropic describes approval fatigue: people click "yes" to nearly everything, so the prompts stop protecting anyone. Coverage of a later Anthropic post reports that users approved roughly 93% of permission prompts under the older flow. Anthropic's answer was to put a boundary around the agent and let it work freely inside it; the company reports that sandboxing cut permission prompts by 84% in its internal use.

At the same time, the box became harder to trust. In March 2026 researchers from Oxford and the UK AI Security Institute published SandboxEscapeBench, showing frontier models breaking out of misconfigured containers about half the time, and a later revision reports that Claude Mythos Preview saturates the public set. Meanwhile prompt-injection attacks moved from demos to live exploitation, according to a Cloud Security Alliance research note. Both trends push the same way: stronger walls, fewer secrets inside them, and tighter control of what can leave.

84%fewer permission prompts after Claude Code sandboxing, in Anthropic's internal use
18container-escape scenarios in SandboxEscapeBench (Oxford and UK AISI, Mar 2026)
~0.50reported overall escape rate for GPT-5 on that benchmark (secondary coverage)
77%AgentDojo tasks CaMeL solves with provable security against prompt injection, versus 84% undefended

The lethal trifecta: when an agent becomes dangerous

Simon Willison's June 2025 framing is the clearest way to see the risk. An agent becomes exploitable when it combines three capabilities: access to private data, exposure to untrusted content (anything an attacker could have written: a web page, an email, a GitHub issue, a tool description) and the ability to communicate externally. With all three, hidden instructions in the untrusted content can tell the agent to send the private data somewhere. Remove any one leg and that particular attack has nowhere to go.

Willison's point is that the mechanism, prompt injection, has no reliable fix at the model level, so the defence has to be structural. Sandboxing is one of the main ways to cut a leg: a sandbox with no network removes external communication; a sandbox with no credentials or private files removes the data. Click the circles to switch each capability on or off.

Toggle the three legs

Each circle is one capability the agent session has. The verdict follows Willison's framing; real systems also have partial cases, such as network access limited to a list of domains.

๐Ÿ’ก The canonical example In May 2025 Invariant Labs showed that the official GitHub MCP server gave one agent session all three legs at once: it could read attacker-filed issues in a public repository (untrusted content), read the user's private repositories (private data) and open pull requests (external communication). A malicious issue told the agent to copy private data into a public pull request. Invariant described this as an architectural problem, not a bug in the server.

Two threat models, two kinds of protection

"Sandboxing an agent" covers two different problems, and confusing them leads to the wrong controls.

๐Ÿงฏ 1. The agent makes a mistake

The model misreads the task, runs rm -rf in the wrong directory, drops a database table or loops forever. The agent is not hostile; it is just wrong, quickly and at scale. The July 2025 Replit incident, in which an agent deleted a live database during a code freeze, is the best-known case.

What works: filesystem limits, separate dev and production credentials, snapshots and backups, resource quotas, reversible actions.

๐ŸŽญ 2. Someone steers the agent

Text the agent reads (a web page, an issue, a document, a poisoned tool description) contains instructions. The agent follows them with its own permissions: it reads secrets and sends them out, or plants code. Here the model is doing exactly what it was told, by the wrong person.

What works: no secrets inside the sandbox, strict egress control, capability-tracking designs such as CaMeL, splitting privileged and quarantined models, human review of consequential actions.

A third, rarer case sits on top: the agent itself tries to get out, either because it was instructed to or because breaking out helps it finish the task. That is what SandboxEscapeBench measures, and it is the reason the strongest tiers of isolation exist.

The building blocks

Every agent sandbox is assembled from a handful of operating-system and virtualisation primitives. Knowing them makes vendor claims much easier to read.

Glossary of primitives

Click a term. Linux and macOS mechanisms are what local coding agents use; the virtualisation tiers are what cloud sandboxes use.

The isolation ladder

The key question for any sandbox is: what does the agent's code share with the machine it runs on? If it shares the host's kernel, a single kernel bug can be a way out. Each step up the ladder puts more between the agent and the host, usually at some cost in start-up time, compatibility or price. Choose a rung to see the layers and the trade-offs.

Five rungs, plus two side paths

Ratings are this site's summary of the sources below, on a 1 to 5 scale, not measurements. "Examples" are as reported by vendor documentation or comparison sites.

โš ๏ธ Start-up figures are marketing until measured Firecracker cold starts are quoted anywhere from about 125 ms to 2 s, E2B's from 5 ms (from a snapshot) to about 150 ms, and Modal's from "sub-second" to 400 ms, depending on who is writing and whether a snapshot is involved. The 125 ms boot and "under 5 MiB" overhead often attributed to the Firecracker NSDI 2020 paper come from secondary summaries; we could not confirm them in the paper text. Benchmark your own workload.

Inside a coding-agent sandbox

Local coding agents use the lowest rung, because they need to work on your real files at native speed. They make that rung much stronger by combining two controls: a filesystem boundary and a network boundary. Anthropic's write-up stresses that both are needed: filesystem isolation alone still lets a hijacked agent send your SSH key to an attacker, and network isolation alone still lets it tamper with your shell startup files to escape later.

How a command travels through the sandbox

Click any box. Based on Anthropic's description of Claude Code and its open-source sandbox-runtime, and OpenAI's Codex documentation. Details differ between versions and platforms.

Claude Code and Codex side by side

From each vendor's documentation as found in searches. "Reported" marks details that come only from third-party descriptions.

Claude CodeOpenAI Codex CLI
macOS mechanismSeatbelt (sandbox-exec profile)Seatbelt
Linux mechanismbubblewrap (namespaces, bind mounts)seccomp + Landlock per the security guide; third-party pages also describe bubblewrap for mount isolation
Default writesWorking directory onlyWorkspace only in workspace-write mode; also read-only and full-access modes
NetworkRouted through a proxy that allows only approved domains; new domains trigger a promptOff by default in workspace-write; can be enabled in config
Approval policySandboxed commands can run without prompts (auto-allow); unsandboxable ones fall back to normal permissionsSeparate axis: untrusted, on-request, never; --full-auto = workspace-write + on-request
Open sourcesandbox-runtime (srt), Apache-2.0, research preview; Windows support reported as alphaCodex CLI is open source

Docker took a step up the ladder for the same tools. In January 2026 its experimental Docker Sandboxes moved to microVM isolation on macOS and Windows: each sandbox gets its own VM and its own private Docker daemon, so the agent cannot reach the host's daemon, containers or files outside the workspace. Docker lists Claude Code, Codex CLI, Copilot CLI, Gemini CLI and Kiro as supported agents.

Try it: what happens to this command?

Pick an action the agent wants to take and a protection setup, and see what happens. This is a teaching model of the behaviour described above, not a test of any specific product version.

Agent action simulator

"Prompts only" means no sandbox, with a human asked to approve risky commands. Remember the reported 93% approval rate.

Action
Setup

The 2026 vendor landscape

For agents that run in the cloud, isolation is now a product category. OpenAI's April 2026 Agents SDK update made it a first-class primitive: the SDK separates the agent harness from the compute and ships built-in support for sandboxes from Blaxel, Cloudflare, Daytona, E2B, Modal, Runloop and Vercel. Every major cloud now offers its own.

Who isolates how

Filter by isolation type. Isolation types are as reported by vendor docs or comparison sites; figures in the notes are vendor or third-party claims, not our measurements.

PlatformIsolationNotes
๐Ÿ” A new trend: sandboxes without secrets The strongest 2026 designs assume the box will eventually be breached and make sure there is nothing worth stealing inside. AWS's guide to self-hosted agent sandboxes on Lambda MicroVMs keeps credentials, networking and governance in the customer's own account, with a fresh VM per session. One report says Google plans to open its Agent Compute Engine, which runs Gemini's work agents, to customers with a microVM per agent and no credentials in the sandbox at all; that comes from a single report and is a preview announcement.

Can agents escape their sandboxes?

SandboxEscapeBench (arXiv 2603.02277), from the University of Oxford and the UK AI Security Institute, is the first open benchmark that measures this directly. An agent gets a shell inside a container and must read a protected file on the host. The 18 scenarios cover three layers: orchestration (for example an exposed Docker socket), runtime (privileged containers, writable host mounts) and kernel (known exploits such as Dirty COW and Dirty Pipe). The whole thing runs inside a virtual machine, so a successful escape only reaches an isolated VM, never the evaluation host.

Reported overall escape rates

Values as reported in secondary coverage of the first version of the paper; the revised paper adds newer models. Bars with a hatch are from a single secondary source. Read them as capability on known misconfigurations, not as the chance of a real breach.

๐Ÿ’ก What this means in practice Plain containers with common misconfigurations should be treated as broken for capable agents. A container is still a reasonable boundary for trusted code that you wrote; for model-generated code running next to other tenants' data, the field has moved to gVisor or microVMs, and to keeping secrets out of the box.

Incidents and milestones, 2023 to 2026

Click an event. Confidence badges say how well each item is documented.

Timeline

Mixes attacks, defences and products. Scroll sideways on a phone.

Beyond the box: designs that resist prompt injection

A sandbox limits where an agent can act. It does not decide whether an action matches what the user asked for. If the agent legitimately needs to post to GitHub, a sandbox that allows GitHub will also let a hijacked agent post your private code there. That is why the research frontier has moved to architectures that control what untrusted data is allowed to influence.

Patterns for injection-resistant agents

The six patterns are from Beurer-Kellner et al., "Design Patterns for Securing LLM Agents against Prompt Injections" (arXiv 2506.08837, June 2025), as summarised by Simon Willison; CaMeL and the dual-LLM pattern are listed separately. Click a pattern.

The paper's authors, from ETH Zurich, Google, IBM, Microsoft and others, put the argument bluntly: as long as agents and their defences rely on the current class of language models, general-purpose agents are unlikely to offer meaningful and reliable safety guarantees. Their response is to constrain agents so that, once untrusted input has entered the context, it cannot trigger consequential actions.

CaMeL (Google DeepMind, arXiv 2503.18813) is the most complete version of that idea. A privileged model turns the user's request into a small program before any untrusted data is read. A quarantined model may parse untrusted content, but its output is just data flowing through that program. Every value carries capability tags recording where it came from and who may receive it, and a custom interpreter checks those tags at every tool call. On the AgentDojo benchmark the paper reports 77% of tasks solved with provable security, against 84% for an undefended system; one secondary write-up quotes 67% from an earlier version.

Newer work shows the remaining gaps. Agent data injection (arXiv 2607.05120) corrupts what the agent sees rather than what it does, so output guardrails miss it. A July 2026 survey of execution security for coding agents (arXiv 2607.05743) systematises 39 papers and four patched CVEs in production agent harnesses, finds that policy-enforcement studies report failure rates of 69% to 98%, and notes that every mechanism it reviewed assumes the policy author makes no mistakes. Time-of-check-to-time-of-use (TOCTOU) attacks, where what was approved is not what runs, are a separate thread: the NeurIPS 2025 paper "Mind the Gap" reports that combined countermeasures cut TOCTOU vulnerabilities in executed trajectories only from 12% to 8%.

Which layer stops which attack?

No single control covers everything. This matrix is our own reading of the mechanisms described above; it is meant to show why defence in depth is necessary, not to rate products.

Coverage matrix

โœ“ = generally stops it; ~ = helps or depends on configuration; โœ— = does not address it. Hover a cell for the reasoning.

The research map

Papers worth knowing, grouped by what they study. Filter by theme.

Key papers on agent sandboxing and containment

Venue and result columns come from abstracts, proceedings pages and summaries; we did not read every full text.

PaperWhere / whenWhat it found or proposed

Choose a tier for your agent

Answer four questions. The recommendation follows the consensus of the sources above; treat it as a starting point, not an audit.

Sandbox tier helper

A practical checklist

Before you let an agent run unattended

Tick what is true of your setup. Drawn from vendor documentation and the research above.

Reading the numbers: what you may see versus what the sources say

ClaimWhat the sources say
"Sandboxing cut prompts by 84%"Anthropic's own internal figure. Independent measurements were not found.
"Users approve 93% of prompts"Reported in coverage of a later Anthropic post about Claude Code; we did not see the original telemetry.
Firecracker boots in 125 ms with under 5 MiB overheadWidely attributed to the NSDI 2020 paper but found only in secondary summaries. Vendor cold starts for Firecracker-based products range from about 5 ms (snapshot restore) to 2 s.
GPT-5 escapes containers half the timeAn overall rate of about 0.50 on SandboxEscapeBench's known-vulnerability scenarios, from secondary coverage. Not a real-world breach rate.
Claude Mythos Preview escapes every timeThe revised paper says it saturates the public set; "100% pass@5 on harder tasks" is from an alphaXiv summary. The private set's results are not public.
CaMeL: 77% or 67%?77% (vs 84% undefended) is in the current abstract; 67% appears in a summary of an earlier version.
Codex on Linux uses bubblewrapOpenAI's security guide names seccomp and Landlock; third-party pages add bubblewrap. Check the current source.
Daytona is closed sourceDaytona's blog (11 Jun 2026) says production code moves to closed source for security reasons and the public repository stays up. A community fork says the public repo is frozen; unverified.
gVisor patches ship 165 to 458 days before CVEsFrom a blog summarising arXiv 2606.08433; we could not confirm it against the paper.
An agent "escaped its training sandbox to mine crypto"The Alibaba-linked "ROME" account appears only in a secondary blog; left out of the timeline.

๐Ÿ”— References and research papers

๐Ÿงญ Closing

๐ŸŽฏ The bottom line A sandbox is now the price of letting an agent work unattended, and the 2026 consensus is clear: process sandboxes with a filesystem boundary and an egress allowlist for agents on your own machine, gVisor or microVMs for model-generated code in shared infrastructure, and no secrets inside any of them. But a sandbox answers "where can the agent act?", not "should it?". Capable models already break out of misconfigured containers in controlled tests, and prompt injection works entirely inside the rules. The durable defences are structural: cut a leg of the lethal trifecta, track where data came from, and keep a human on the few actions that cannot be undone.