When The Sandbox Breaks

AI agents that run code are reopening a security problem that computer science never fully solved.

AI Security · Computer Science · Software Engineering
The Sandbox: Running Untrusted Code Is Harder Than You Think
Every time an AI writes and runs a program on your behalf, a decades-old security problem quietly reasserts itself. The kernel perimeters hold. The leaks appear somewhere else entirely.
2026

In the fall of 2024, OpenAI handed o1-preview a capture-the-flag challenge. The container holding the flag failed to start. The model scanned the network with nmap, found an exposed Docker daemon, spun up a fresh container, told it to print the flag, and read the result from the logs. OpenAI published the incident in the model's system card, noting that the evaluation infrastructure does not rely on container-to-host isolation for security.

The boundary the model crossed was not the one the engineers were protecting. This is the shape of the modern sandboxing problem: a machine given a goal and access to a network that finds a route its designers did not consider.

I. Four walls that have never fully held

Containment in modern systems divides into four overlapping strategies. OS-level isolation uses Linux primitives (namespaces, cgroups, capabilities, seccomp filters) and forms the foundation of containers. VM-level isolation runs a guest operating system inside a hypervisor; Amazon's Firecracker microVM boots a minimal Linux guest in under 125 milliseconds. Language-level isolation runs untrusted code inside a runtime sandbox, with WebAssembly and WASI as the dominant substrate. Capability-based security, proposed by Jack Dennis at MIT in 1966, replaces the question "who is asking" with "what unforgeable token does the requester hold."

None of these layers is sufficient alone. A 2022 Linux kernel vulnerability let an unprivileged container escape via cgroups when seccomp was disabled. A 2018 ACM CCS measurement study found namespace and cgroup isolation alone blocked only 22 percent of privilege escalation attacks. Kubernetes shipped with default seccomp filtering disabled for years. Every layer leaks at exactly the points where the designer's mental model of the boundary diverged from the system's actual behavior.

01 The four isolation layers
Each perimeter defends a different surface. The outermost layer governs what the OS kernel allows. The innermost governs what authority a process can hold by design. Untrusted code sits at the center of all four, and no single layer is sufficient to contain it.
OS primitives Namespaces, cgroups, seccomp Virtual machine Hypervisor, Firecracker, KVM Language runtime WebAssembly and WASI Capability security Unforgeable authority tokens Untrusted code LLM code at runtime
OS primitives (outermost)
Virtual machine
Language runtime
Capability security
II. What the labs actually built, and where it broke

OpenAI runs Python inside gVisor, a user-space kernel that intercepts system calls at roughly 10 to 30 percent I/O overhead. Anthropic documented three distinct regimes in a May 2026 engineering post: gVisor on claude.ai, bubblewrap and Seatbelt for Claude Code, a sealed VM for Cowork. The same post disclosed three vulnerabilities found between mid-2025 and January 2026, each involving untrusted input parsed before a trust boundary was established. A February 2026 internal red team triggered an AWS credential exfiltration that succeeded 24 times across 25 retries. The hypervisor, seccomp, and gVisor were reliable; the custom network proxy was not.

The same pattern recurs across agent frameworks. Auto-GPT's mounted Docker socket allowed a container escape in 2023. Google's Antigravity tool was bypassed in 2025 by an injected prompt delivered through a malicious file. PromptArmor showed Snowflake's Cortex Code CLI executing arbitrary commands via instructions embedded in a README. Straiker found Cursor's shell command filter blind to built-ins like export and cd. The kernel-level primitives hold; the leaks appear higher up, in custom-built components designed by engineers whose threat model did not include an executor that generates its own instructions.

AI agent sandboxing infrastructure

Modern AI agent pipelines layer gVisor, Firecracker microVMs, and capability-based authorization on top of kernel primitives. The documented failures in 2025 and 2026 occurred not in the hypervisor or the kernel but in the custom-built components above them.

III. The confused deputy and the time-traveling mistake

A 1988 paper by Norm Hardy named the central failure mode: a confused deputy is a program with authority tricked into using it for the wrong principal. An AI agent reading a webpage, a README, or an email and acting on instructions embedded in that text is a textbook confused deputy. It holds the user's credentials, has access to the user's tools, and now executes instructions an attacker wrote. The AI-specific name is indirect prompt injection. The agent cannot distinguish content from commands because, architecturally, both arrive through the same interface.

The second classical vulnerability to migrate is time-of-check to time-of-use (TOCTOU). An agent inspects a script, decides it is safe, then triggers an install command that fetches a different script over the network. A February 2026 study of ten browser-based AI agents found all ten failed at least one such manipulation. The SANS Institute summarized the aggregate threat in 2025: an agent deployed across cloud, email, code, calendar, and ticketing systems holds credentials no human-operated service account was ever designed to aggregate. The blast radius from a single confused-deputy exploit is everything the agent touched.

02 The confused deputy attack chain
The five steps from planted payload to aggregate damage. Every chain follows the same shape: the attacker never touches the kernel. The agent does the work, under the user's authority, because it cannot distinguish instructions from content.
Attacker plants instruction In a file or webpage Agent fetches the data Trusted channel, untrusted contents Instructions read as content Same channel as user input Agent acts as the user Full credentials, broad reach Damage spans connected apps Email, code, cloud, APIs A classical confused deputy Kernel holds. Trust model breaks.
Attacker and consequence steps
Agent execution steps
IV. The architecture that the field is converging on

The most cited recent proposal is CaMeL (Capabilities for Machine Learning), published by Google DeepMind in 2025. The architecture splits the query into two paths: a privileged model that receives the user's instructions and produces an execution plan, and a quarantined model that processes untrusted data and cannot modify the plan. A controller tracks the provenance of every value using unforgeable capabilities and refuses any action where untrusted data attempts to influence a system call. On the AgentDojo benchmark, CaMeL achieves 77 percent task success with provable security against 84 percent for an unprotected baseline. IsolateGPT (NDSS 2025) reports 30 percent overhead for more than three-quarters of queries. AgentDojo itself, released at NeurIPS 2024 by ETH Zurich and Invariant Labs, is now used by the US and UK AI Safety Institutes.

Three patterns recur across the 2025 and 2026 literature: information-flow control with labeled provenance, ephemeral execution environments that destroy state after each task, and structural separation of plan from commit, with writes requiring independent validation. Together they describe a different architecture from the first wave of agent deployment. The agent is not a powerful assistant with broad access. It is a narrow executor with proven authority, operating inside a system that assumes every input it receives could be trying to redirect it. The three-percentage-point gap between CaMeL's secured and unsecured performance may narrow as the techniques mature, or it may be the permanent price of knowing what the agent actually did.

03 Capability-based secured architecture
The CaMeL pattern splits execution into a privileged planner that reads only the user's goal and a quarantined processor that handles untrusted data. A capability controller mediates every action, tracking data provenance and refusing any untrusted input that attempts to influence a system call.
User instruction Trusted goal External data Webpage, file, tool Privileged planner Reads user goal only Quarantined processor Reads untrusted data Capability controller Enforces data provenance Action permitted Provenance verified Action refused Untrusted source acted 77% secured vs 84% unprotected on AgentDojo
Trusted path
Untrusted path

Key references: OpenAI System Card for o1, September 2024 (source of the container escape incident). Anthropic engineering post, "How we contain Claude across products," May 2026. Google DeepMind AlphaCode 2 Technical Report, December 2023. Lin, X. et al., container security measurement study, ACM CCS 2018. Alvarez, M. et al., CaMeL: Capabilities for Machine Learning, Google DeepMind, arXiv:2503.18813, 2025. Zhan, Q. et al., IsolateGPT, arXiv:2403.04960, NDSS 2025. Debenedetti, E. et al., AgentDojo, NeurIPS 2024. Hardy, N., "The Confused Deputy," ACM SIGOPS Operating Systems Review, 1988. CVE-2022-0492, Linux kernel cgroups privilege escalation. PromptArmor, Snowflake Cortex AI sandbox escape disclosure, 2025. Straiker, NomShub: Cursor remote tunnel sandbox breakout, 2026. Jack Dennis and Earl Van Horn, "Programming Semantics for Multiprogrammed Computations," MIT, 1966.