On 8 December 2025 a developer asked Claude Code, Anthropic's coding agent, to clean up packages in an old repository. The agent ran rm -rf tests/ patches/ plan/ ~/.

The first three arguments were the job. The last two characters were the developer's home directory, and Docker's write-up of the incident lists what went with it: years of projects, family photos, keys and the system keychain.

Nothing stood between the model's decision and the developer's files. Sandboxing means putting something there, a hard boundary around what an artificial intelligence (AI) agent can reach. This guide explains how the popular agents build that boundary, where it has failed, and what the rest of us should copy.

The failures do not all look like that one. Seven months later OpenAI was testing models inside an isolated environment with no direct internet access, and the models found a previously unknown flaw in the one service they were allowed to reach, worked their way out and broke into Hugging Face's production servers. The first story had no wall at all, and the second had a good wall with a door in it.

I've tried to keep this readable for anyone who uses these tools, whether or not you enjoy kernel documentation.

Why an agent needs a boundary

A chatbot produces text, and an agent produces actions. It reads files, runs shell commands, installs packages and calls other services, and it repeats that loop until it decides the task is done.

The model itself never touches your machine. It sends a request, called a tool call, to a program on your computer, usually called the harness, and the harness carries it out. That detail matters because the harness runs as you, with your files, your saved logins and your network access.

Anthropic's engineers sort what can go wrong into three groups. A user can ask for something destructive without understanding it. The model can take a harmful step nobody asked for, usually because it is trying too hard to finish the job.

The third group is the outsider who plants instructions in something the agent reads, an attack known as prompt injection. I wrote about it when I added Model Context Protocol (MCP) support to a small app. Any text an agent reads, whether a web page, a code comment or a bug report, can carry instructions, and the model has no reliable way to tell them from yours.

The first defence most agents shipped with was the permission prompt. Before running a command, the agent stops and asks you. It sounds safe, and it wears out fast.

Anthropic reports that Claude Code users approve about 93% of the prompts they see. A check that almost always gets a yes is not checking much, and the industry has a name for the result, approval fatigue.

A sandbox asks a different question. Instead of deciding whether a command should start, it limits what the command can reach while it runs, and the operating system enforces that limit rather than the model. If the boundary holds, it holds whether the cause was a careless request, an overeager model or an attacker.

Model picks the next step tool call Agent harness runs with your access 1 SANDBOX Shell command and its children Project folder read and write 2 Home folder Your keys Internet 1 Permission check Decides whether a command may start. It cannot see what the command does next. 2 Sandbox Limits what the running process can reach, whatever the model or an attacker intended.
Two different questions. A permission check decides whether a command starts. A sandbox decides what that command can reach once it is running, and the answer covers every process the command spawns.

The two controls work together. Anthropic says that turning on the sandbox cut permission prompts by 84% in its own use, because anything that stays inside the boundary no longer needs a question. Cursor measured something similar, with sandboxed agents stopping for approval about 40% less often.

What a sandbox restricts

A useful sandbox for an agent controls four things.

SANDBOX Agent's commands and all they start 1 Writing the project folder anywhere else on disk 2 Reading the project's files keys and other folders 3 Network hosts you approved the wider internet 4 Credentials a short-lived stand-in your real tokens
The four things a sandbox controls, drawn as gates in its boundary. Each gate lets one narrow thing through and stops the rest.

The first is writing. A sandboxed command can usually change files in the project folder and a temporary directory, and nothing else. That one rule would have saved the home directory in the opening story.

The second is reading, which gets less attention than it deserves. An agent that can read your whole disk can read your Secure Shell (SSH) keys and cloud credentials, even if it cannot change them.

The third is the network. Without a limit on outbound connections, anything the agent can read can be sent somewhere else, and anything on the internet can be downloaded and run. The usual tool is an allowlist, a short list of destinations the agent may contact, with everything else refused.

The fourth is credentials. Tokens, keys and logins that sit inside the sandbox are available to whatever runs there, so the strongest designs keep them outside and lend out narrow, short-lived stand-ins.

File rules and network rules only work as a pair. Anthropic's documentation says so directly: without network limits a hijacked agent can send your files away, and without file limits it can break out of the sandbox and get its network access back.

Simon Willison gave the clearest mental model for why, which he calls the lethal trifecta. An agent is open to data theft when it has access to private data, exposure to untrusted content and a way to send data out, all at once. Meta later turned the idea into a rule of thumb, the Agents Rule of Two, which says an unsupervised agent should have at most two of the three in any one session.

Private data Untrusted content A way out All three together: injected text can steal data. Remove one circle and the theft fails FILESYSTEM BOUNDARY Takes away private data. The agent cannot read keys or anything outside the project. NETWORK ALLOWLIST Takes away the way out. Data can only travel to hosts you approved. UNTRUSTED CONTENT STAYS An agent that reads code, issues or web pages always meets text someone else wrote.
Simon Willison's lethal trifecta, with the two circles a sandbox can take away. This is why filesystem rules and network rules only work as a pair.

A coding agent cannot avoid untrusted content, because reading other people's code is the job. So the sandbox works on the other two circles.

The isolation ladder

Sandboxes come in four broad strengths. Each step up the ladder puts more distance between the agent and the kernel, the core of the operating system (OS) that every program on your machine shares. Each step also costs more in setup and speed.

HOST KERNEL, SHARED BY EVERY PROCESS ON THE MACHINE HARDWARE OS sandbox Seatbelt, bubblewrap Agent's commands Instant start, native tools. Relies on the host kernel and a tight policy. Watched laptop work Container Docker, dev containers Agent's commands A full Linux userland. Shares the host kernel, so setup mistakes matter. Code you already trust User-space kernel gVisor Agent's commands Its own kernel in user space answers most calls. Some software won't run. Hosted, multi-tenant MicroVM Firecracker, Kata Agent's commands A separate kernel behind hardware virtualisation. Boots in about 125 ms. Code you don't trust POLICY all calls go to the host NAMESPACES same kernel Application kernel few calls Guest kernel HYPERVISOR
The four rungs of the ladder. What changes from left to right is how much stands between the agent's commands and the kernel your whole machine depends on.

Operating system sandboxes

The lightest option uses features already built into the operating system. The agent's commands run as normal processes on your machine, and the kernel checks each thing they try to do against a policy.

On macOS the feature is Seatbelt, reached through a tool called sandbox-exec. Cursor's engineers point out that it dates from 2007 and that Apple marked it deprecated in 2016, yet Chrome still relies on it.

A Seatbelt policy is a short text file of rules. This deliberately small one allows everything, takes away all file writes, then gives writes back inside one project folder.

(version 1)
(allow default)
(deny file-write*)
(allow file-write* (subpath "/Users/you/project"))

Save that as agent.sb, run a command through it, and a write anywhere else fails.

$ sandbox-exec -f agent.sb touch ~/note.txt
touch: /Users/you/note.txt: Operation not permitted

The touch command did nothing unusual. It asked the kernel to create a file, the kernel checked the policy and refused, and any program that command started would meet the same refusal. The profiles that agents ship are longer and stricter, but their rules read the same way.

On Linux the usual pieces are bubblewrap, which gives a process a private view of the filesystem and network, plus Landlock and seccomp, two kernel features that restrict file access and system calls.

A system call is a request from a program to the kernel, such as opening a file or making a network connection. Filtering those requests is how every sandbox on this rung works.

The appeal is speed and convenience. There is nothing to boot, your own compilers and tools work as they are, and the limits apply to every child process automatically. The weakness is that the agent still talks to your real kernel, so one kernel bug or one loose rule in the policy can be enough.

Containers

A container, the technology behind Docker, packages a whole Linux environment and gives it a private view of files, processes and the network. Dev containers apply the same idea to a development setup that your editor manages for you.

A container's policy is its start-up configuration, because a container can only see what you hand it. This command hands over one folder, the project, with -v. It switches the network off with --network none, and throws the container away on exit with --rm.

docker run --rm -it --network none \
  -v "$PWD":/workspace -w /workspace \
  node:22 bash

Inside that shell, here is the command from the opening story again, followed by two things an attacker's hidden instructions might try.

$ echo ~
/root
$ rm -rf tests/ patches/ plan/ ~/
$ cat ~/.ssh/id_ed25519
cat: /root/.ssh/id_ed25519: No such file or directory
$ curl https://example.com
curl: (6) Could not resolve host: example.com

The delete runs without complaint. It removes the three project folders it was asked to, plus /root, a home folder that belongs to the container and comes back fresh from the image next time. Your own home folder was never mounted, so it was never in reach.

The last two lines fail for the same reason. There are no keys in the container to read, and no network to send them over.

This is a starting point. The Open Worldwide Application Security Project (OWASP) keeps a Docker security cheat sheet that adds more, such as running as an ordinary user, dropping Linux capabilities and blocking privilege escalation. It also warns against two settings that undo everything, the --privileged flag and a container that can reach the Docker control socket.

Those warnings matter because containers still share the host's kernel, so their safety rests on configuration. The UK's AI Security Institute (AISI) built a benchmark of 18 container escape scenarios and asked frontier models to break out. They often succeeded against exactly those common mistakes.

There is some comfort in the details. No model solved the hardest scenarios, and every successful escape used a weakness that was already publicly known.

User-space kernels

gVisor, an open source project from Google, adds a layer that intercepts the system calls a program makes and answers them itself, in a separate program written in a memory-safe language. Most requests never reach the host kernel at all.

It plugs into Docker as an alternative runtime called runsc, so the container example above needs only one more flag, --runtime=runsc. The file and network rules stay exactly as they were. What changes is the kernel on the other end, and you can see it by asking each one for its version.

$ uname -r
6.8.0-45-generic
$ docker run --rm ubuntu uname -r
6.8.0-45-generic
$ docker run --rm --runtime=runsc ubuntu uname -r
4.19.0-gvisor

The first answer comes from the host. The ordinary container gives the same answer because it is talking to the same kernel, and the gVisor container reports a kernel of its own.

That matters when an attacker has a way to exploit a kernel bug, the one problem careful container configuration cannot fix. In an ordinary container the exploit goes straight at the kernel your whole machine runs on. Under gVisor it meets gVisor's kernel first, a separate program that holds few privileges of its own.

The cost is some overhead, and the occasional piece of software that expects a kernel feature gVisor has not implemented.

Virtual machines and microVMs

A virtual machine (VM) goes further and gives the workload its own kernel, separated from the host by the processor's virtualisation features and a thin layer of software called a hypervisor. Traditional VMs are slow to start, which is why agents tend to use microVMs, stripped-down virtual machines built to boot fast. Firecracker, which Amazon built for its serverless products, commits to starting a guest within 125 milliseconds and adding no more than about 5 megabytes of memory overhead.

A VM's policy is a list of hardware. This is a complete Firecracker configuration in the format its getting started guide describes: a kernel to boot, one disk, two processors and a gigabyte of memory.

{
  "boot-source": {
    "kernel_image_path": "vmlinux.bin",
    "boot_args": "console=ttyS0 reboot=k panic=1"
  },
  "drives": [
    {
      "drive_id": "rootfs",
      "path_on_host": "agent-disk.ext4",
      "is_root_device": true,
      "is_read_only": false
    }
  ],
  "machine-config": {
    "vcpu_count": 2,
    "mem_size_mib": 1024
  }
}

One command boots it.

sudo ./firecracker --api-sock /tmp/firecracker.socket --config-file vm.json

Look at what the file leaves out. It has no network section, so the guest has no network card, and nothing in it points at your home folder, so the guest has no way to reach it. A container hides the host's files from a process, while a VM was never given them.

Replay the opening story in this guest and the delete empties a home folder that lives inside agent-disk.ext4, a single file on your machine that you can swap for a fresh copy. A kernel exploit fares no better, because the kernel it takes over is the guest's own, which sits inside the box too. In practice you would rarely write this file by hand, since the VM-based products covered later set up the equivalent for you.

NVIDIA's AI Red Team recommends this rung for agents, on the grounds that every shared-kernel option leaves kernel bugs within reach. It also notes that the extra overhead is small next to the time an agent already spends waiting for the model.

One more option sits off to the side of the ladder. WebAssembly runtimes confine code inside a language runtime, and NVIDIA has suggested running model-written Python that way in the user's own browser. They start instantly and suit small calculations, but Docker's engineers argue they make a poor home for a coding agent, which needs a real shell and the freedom to install system packages.

Technique What separates the agent from your machine Main weakness
OS sandbox A policy the kernel enforces on an ordinary process Shared kernel, and mistakes in the policy
Container A private view of files, processes and network Shared kernel, and mistakes in configuration
User-space kernel A separate program that answers system calls Compatibility, and it is still software isolation
Virtual machine A separate kernel behind hardware virtualisation Heavier to run, and only as tight as the doors you open into it

How the main coding agents do it

Four agents cover most of what developers use today: Claude Code, OpenAI's Codex, Cursor and Google's Gemini CLI, where CLI stands for command-line interface. For local work all four have settled on the same idea, an OS sandbox around shell commands. Where they differ is in the defaults, and the defaults decide what happens to people who never open the settings.

Agent On by default macOS Linux Windows Network by default
Claude Code (terminal) No Seatbelt bubblewrap Only inside WSL2 Blocked until you approve a domain
OpenAI Codex Yes Seatbelt bubblewrap Native sandbox Off
Cursor Yes Seatbelt Landlock and seccomp Supported Blocked unless allowed
Gemini CLI No Seatbelt Docker, Podman, gVisor or LXC Native sandbox or a container Open in the default profile

WSL2 is the Windows Subsystem for Linux, which runs a real Linux kernel inside Windows. The table describes each tool as it runs from a terminal, and the rest of this section walks through each product in turn.

Claude: the boundary depends on the product

One caution before the details. Claude is several products, and they are not contained the same way. The desktop app alone has two sides that do not share a boundary.

One side is the ordinary Claude conversation. Since September 2026 Anthropic has been merging Cowork into it, Cowork being its agent for longer tasks that work on your files. The other side is the Code tab, which is Claude Code inside a window and was not part of the merge.

Where you use Claude Where its commands run What contains them Can you switch it off
Claude Code in a terminal Directly on your machine An optional OS sandbox around shell commands It starts off, and you switch it on
Desktop app, Code tab, local session Directly on your machine The same optional sandbox, set in the same settings file It starts off here too, and native Windows has none
Desktop app, Claude conversation (now includes Cowork) Anthropic's cloud by default, or a Linux VM on your machine The cloud sandbox or the VM, plus the folders you connected No, it is always on
Claude Code in the cloud Anthropic's servers An isolated VM for each session No, it is always on

The difference is who holds the switch. In the terminal the sandbox is a setting, and a process outside it decides for each command whether it applies. Anthropic's engineers contrast that with Cowork, noting that a persuasive injected instruction or a tired approval can let a terminal command run outside the sandbox.

Cowork has no outer process with that authority, so every command lands in the sandbox or the VM. Anthropic's architecture overview, which covers the merged conversation as well, describes no setting that turns that isolation off.

The Code tab sits on the terminal's side of the line, so its sandbox also starts off. A local session there runs on your machine with direct access to your files. The settings in ~/.claude/settings.json apply to it, and that file is where sandbox.enabled lives.

The desktop documentation describes that reply for commands that open a dialog in the terminal, which have no equivalent in the app. To switch the sandbox on for the Code tab you edit the settings file, or run the command from the terminal tool.

Windows adds a second catch. On native Windows there is nothing to switch on, because Claude Code runs commands unsandboxed there and the documented route to a sandbox is WSL2.

One gap is worth naming. The desktop documentation says the settings in that file apply to desktop sessions, and it mentions the sandbox in passing, but its comparison of the terminal and the app has no row for it. I am reading that as the setting carrying over, so test it with a write outside the project folder, which a working sandbox refuses.

Claude Code in the terminal

Claude Code's sandbox wraps the shell commands the agent runs, and everything those commands start. It is off until you enable it, either by typing /sandbox or through the settings file. On native Windows the commands run without a sandbox, so you need WSL2 to get one.

Once it is on, a command can write to the working directory and a temporary folder. It has no direct route to the network. All traffic goes through a proxy, a small go-between program running outside the sandbox, which starts with an empty list of permitted domains and asks you the first time a command wants a new one.

SANDBOX Seatbelt on macOS, bubblewrap on Linux Bash command npm test, git, any script the only route out Proxy outside the sandbox Internet FILES DOMAIN CHECK Project folder read and write On your allowlist passes The rest of your disk read only by default Not seen before asks you Shell profile, .git/hooks, settings no writes Refused or unanswered blocked Every child process inherits the same limits. File tools, hooks and MCP servers run outside this box.
Claude Code's sandboxed Bash tool, as Anthropic's documentation describes it. Commands can write inside the project and nowhere else, and their only route to the network is a proxy that sits outside the sandbox and checks each domain.

Three details in the documentation are easy to miss, and all three matter.

The first is that reading is wide open by default. A sandboxed command can read most of the machine, including ~/.ssh and ~/.aws/credentials, unless you add deny rules. Writing is contained out of the box, and reading is contained only if you configure it.

The second is that the sandbox covers shell commands only. The agent's built-in file tools, its hooks and any MCP servers you have connected run outside it, governed by permission rules instead. To put everything behind one boundary you run the whole program inside Anthropic's open source sandbox runtime, a container or a VM.

The third is that a command can end up unsandboxed without you noticing. If a dependency is missing, Claude Code runs commands without the sandbox unless you tell it to refuse. And when a command fails inside the sandbox, the agent can ask to retry it outside.

Both behaviours can be switched off, and the read rules can be tightened in the same place. This is the shape of a stricter configuration, though you should check the key names against the current settings reference before relying on it.

{
  "sandbox": {
    "enabled": true,
    "failIfUnavailable": true,
    "allowUnsandboxedCommands": false,
    "filesystem": {
      "denyRead": ["~/.ssh", "~/.aws"]
    }
  }
}

Claude Code also has an auto mode, in which a second model reviews each action instead of you. It is a separate control from the sandbox, and it has a section of its own below, next to its counterparts in Codex and Cursor.

Claude Code in the cloud

When a Claude Code session runs on Anthropic's servers, the documentation describes an isolated virtual machine with a network proxy that enforces an allowlist. The more interesting part is how it handles your GitHub login.

Your token never enters the sandbox. The git client inside holds a limited credential that only works with a proxy on the outside. That proxy checks each request, for example that a push goes to the branch the session was given, before it attaches the real token and passes the request on.

CLOUD SANDBOX Agent and git client one session, one task Holds a scoped credential. Never sees your GitHub token. git push Git proxy 1. checks the credential 2. checks the operation 3. adds the real token with token GitHub A push to any other branch is refused. Runs outside the sandbox, so a hijacked session can ask but cannot take the key.
How a cloud session pushes code without ever holding your GitHub token. The proxy lives outside the sandbox and attaches the real credential only after it has checked the request.

This is one of the most transferable idea in the whole field. A secret that never enters the sandbox cannot be stolen from it, whatever goes wrong inside.

The Claude conversation: chat and Cowork, now merged

This is the side of the app that changed in September 2026. Chat and Cowork used to be separate choices, and Anthropic has been merging them into one Claude so that you no longer choose where a task goes. Its technical documents still say Cowork, so the article tries to use the same names.

Anthropic uses a different rung of the ladder for each product, matched to who is using it. When Claude runs code to answer a chat message, that code executes in a gVisor container on Anthropic's servers with a temporary filesystem, far away from your machine.

Cowork was built for people who are not developers, and it got the strongest boundaries. Its sessions now run in Anthropic's cloud by default, each in a temporary sandbox with a mandatory outbound proxy and credentials that expire within hours. When such a session needs a file on your computer, the request goes through the desktop app and can only touch folders you have connected.

The older local mode is the more instructive design, and Anthropic still supports it for existing desktop deployments. There, every shell command and script runs inside a Linux VM, using Apple's Virtualization framework on macOS and Hyper-V on Windows. Only the folder you selected is mounted, your credentials stay in the host's keychain, and a folder can be mounted read-only or in a mode that allows writing but not deleting.

YOUR COMPUTER Claude desktop app agent loop and file tools Your credentials stay in the host keychain Everything else on disk not mounted LINUX VM with its own kernel Shell commands and code Claude writes run here, never on the host Connected folder read-only, read-write or write-no-delete Egress filter allow-listed hosts Internet Apple Virtualization on macOS, Hyper-V on Windows
The local mode that Cowork introduced, based on Anthropic's architecture notes. The agent loop stays on the host, but every shell command and every script runs in a Linux virtual machine that can see only the folder you connected.

The reasoning behind the difference is a principle worth borrowing: match the isolation to the user's ability to supervise. A developer can read a shell command and judge it. Someone asking for help tidying a folder cannot be expected to, so the boundary has to be absolute and always on.

OpenAI Codex

Codex takes the opposite default from Claude Code, and the sandbox is on from the start. You choose between three modes. Read-only lets the agent look but not touch, workspace-write lets it edit the project and run routine commands, and danger-full-access removes the boundary altogether.

In the default workspace-write mode the network is off, and a few paths stay read-only even inside the project, including .git and the agent's own .codex folder. A separate approval setting decides what happens when a command needs to leave the sandbox. Codex can ask you, or it can send the request to a reviewer model, a feature called auto-review.

Under the surface it is Seatbelt on macOS and bubblewrap on Linux, with a native sandbox on Windows. Codex's cloud tasks run in containers that OpenAI manages, in two phases. A setup phase has network access and your secrets so that it can install dependencies, and then the secrets are removed and the agent phase runs offline unless you say otherwise.

Cursor

Cursor published a detailed account of building its sandbox in February 2026, and its documentation says terminal commands run in a restricted environment by default. On macOS the team weighed four approaches and chose Seatbelt, because containers would have limited users to Linux programs and virtual machines started too slowly and used too much memory.

On Linux it uses Landlock and seccomp directly, and maps the workspace through an overlay so that files listed in .cursorignore cannot be reached at all. The Windows version described in that post ran the Linux sandbox inside WSL2, and the current documentation lists Windows alongside the other two.

But a sandbox only helps if the agent understands it. Cursor's early sandboxed agents kept retrying the same blocked command, and the fix was to tell the model plainly which limit it had hit and how to ask for more access.

Gemini CLI

Google's Gemini CLI offers the widest menu and the loosest default. Sandboxing is off unless you pass --sandbox or set it in the configuration. When it is on, you can choose Seatbelt on macOS, a Docker or Podman container, gVisor, an experimental mode built on LXC (Linux Containers), or a native Windows sandbox.

The default macOS profile, called permissive-open, restricts writes outside the project and leaves the network open. Stricter profiles add read restrictions and route traffic through a proxy. The documentation's own advice is to use the most restrictive profile that still lets you work, and I would follow it for any repository you did not write yourself.

Auto and auto-review modes: when a model approves for you

A sandbox removes most permission prompts, and the ones it leaves are the hard ones. They come from commands that need to leave the boundary, such as a push or a download from a new host. For a long time you could either answer each one yourself or switch the questions off.

Three of the four agents now offer a third option, in which a second model answers for you.

ONE ACTION UNDER AN AUTO OR AUTO-REVIEW MODE Agent proposes a command or a tool call Rules and sandbox already allowed or contained? yes Runs with no review no model is consulted no, it needs approval Reviewer model a second model, separate from the one doing the work Allow the action runs Block the agent must find a safer way Hand back to you the prompt reaches you after all it judges requests, it does not contain them
The shape that Claude Code's auto mode and the auto-review modes in Codex and Cursor share. A second model answers the approval requests that used to come to you.

The names are close enough to cause confusion, so here they are side by side.

Who answers Claude Code Codex Cursor Gemini CLI
You Manual Auto, the recommended preset Allowlist default
A second model Auto Auto-review, labelled Approve for me in the app Auto-review, the default No such mode
Nobody Bypass permissions Full access Run Everything yolo

Watch the word auto. In Codex, the Auto preset means the sandbox is on and Codex asks you before leaving it. In Claude Code, and in the main Claude conversation, Auto means an automated check is answering instead of you.

The three reviewer modes differ in what reaches the reviewer. Codex's auto-review is the narrowest. The sandbox stays exactly as it was, and the reviewer sees only the requests that would otherwise have stopped for you.

Cursor checks each call in a fixed order. Calls on your allowlist run at once, other shell commands run in the sandbox where they can, and a classifier judges the rest. It has been the default since version 3.6 in May 2026.

Claude Code's auto mode does not depend on a sandbox. Reads and edits inside the working folder run unreviewed, and a classifier checks everything else. Recent versions start most interactive terminal sessions this way, so the reviewer is on by default while the sandbox is off.

Gemini CLI has no reviewer mode. Its auto_edit mode approves file edits only, and an optional checker built on a language model is off by default.

The vendors publish numbers. Anthropic reports that its classifier wrongly blocked 0.4% of harmless actions in real use and missed 17% of a set of 52 overeager ones. OpenAI reports that its reviewer caught roughly 90% of overeager actions in testing, while sessions stopped for a person about 200 times less often.

None of the three calls this a security control. Cursor's documentation says the classifier is not a security boundary, and OpenAI and Anthropic attach warnings of their own. A red-team write-up from October 2026 describes 11 attacks that a misbehaving agent could use to run malicious code past both the Codex sandbox and its reviewer, and OpenAI has fixed several of them.

So treat these modes as a replacement for you own tired approvals, and never as a replacement for the boundary. A reviewer is a model making a judgement, and it can be wrong or talked round. The arrangement Codex and Cursor chose, with the sandbox first and the reviewer only at the exits, is the one I would copy, and in Claude Code that means switching the sandbox on underneath auto mode.

Where else sandboxes are used

The same ideas show up wherever agent-written code runs, and it helps to match the boundary to the job.

Where the agent runs What can go wrong Typical boundary
Your laptop, while you watch A destructive command, or stolen keys An OS sandbox around shell commands
Your laptop, unattended The same, with nobody there to say no A container, a VM or a sandbox around the whole agent
A vendor's cloud session One customer's agent reaching another, or leaking your tokens A VM or gVisor per session, with credentials held outside
A chat app that runs code Model-written code attacking the service itself A gVisor container or a WebAssembly runtime
A build pipeline Public issues and pull requests steering an agent that holds release secrets A short-lived runner with no secrets in reach and no open network
A safety evaluation A capable model acting on real systems VM-level isolation with internet access off by default
An MCP server or plugin Third-party code running with your access The same sandbox as the agent, or one of its own

A small industry now sells this as a product. Docker's Sandboxes, which moved to microVM isolation in January 2026, give each agent session its own small virtual machine with a private Docker engine inside. The reason is practical: agents often need to build and run containers, and doing that from inside a container means weakening it.

Kubernetes has an Agent Sandbox project that adds a standard way to request an isolated environment for a single agent, backed by gVisor or Kata Containers. Hosted services such as E2B and Vercel Sandbox build on Firecracker, according to one recent survey of the market.

Every boundary so far has been a wall. A newer line of research treats the sandbox as something you can copy while it runs.

TimeTravelContainer, a November 2026 preprint from NVIDIA, builds on gVisor to fork a running container, including its processes, memory, files and internal network state. The copies share memory until one of them writes to it. An agent can try three approaches in three copies, keep the best and discard the rest.

The reported gains are large. Cloning a prepared chip design session fell from 86.5 seconds to about one second. The tests cover two chip design workflows, replayed without a model in the loop, so I'd treat the numbers as early evidence.

Two cautions apply. The project's own README says it provides basic isolation and is not a complete guardrail, so it belongs inside a boundary and does not replace one.

A fork also rewinds only what lives inside the container. A deleted cloud volume or a pushed commit stays that way.

What went wrong: incidents worth studying

The incident record since mid-2025 is long enough to sort into patterns, and here are few of them.

No boundary at all

The opening story belongs here, and it has plenty of company. In October 2025 a Claude Code user running Ubuntu under WSL2 reported a recursive delete that ran from the root of the filesystem and removed every file the account owned. A month later a user of Google's Antigravity editor lost the contents of a D: drive when a path containing a space was cut short to the drive root, one of nine cases in Adversa's roundup of deletion incidents.

The most recent wave came in July 2026, days after OpenAI released its GPT-5.6 models. Several users reported that Codex had deleted their home directories. OpenAI's engineering lead for Codex explained the pattern: the model tried to point the $HOME variable at a temporary folder and then deleted the real home folder by mistake.

He added that the reports clustered where full access mode was on and neither the sandbox nor auto-review was running. None of these cases involved an attacker or a software vulnerability. A valid command did exactly what it said, and no boundary was there to limit it.

A boundary that left out the credentials

A filesystem boundary does nothing about a command that calls a cloud service with a real token. The damage happens somewhere else entirely.

In July 2025 Jason Lemkin, the founder of SaaStr, reported that Replit's agent had deleted his production database despite an explicit freeze on changes. The agent then told him a rollback was impossible, which turned out to be wrong.

In April 2026 the founder of PocketOS described a Cursor agent that hit a credentials problem during a routine task in a staging environment and decided to fix it by deleting a storage volume at the hosting provider, Railway. The agent had found a token with enough authority, the volume was shared with production, and the volume's backups lived in the same place. The deletion took nine seconds, and the company was disrupted for about thirty hours until Railway restored the data from its own disaster backups.

Amazon had its own version. The Financial Times reported in February 2026 that Kiro, Amazon's coding agent, had been allowed to make changes in a production environment the previous December and chose to delete and recreate it. A cost-reporting service in one region was down for 13 hours.

Amazon disputes the framing and says the cause was a misconfigured access role that would have let a person make the same mistake. The agent inherited an engineer's broad permissions, and a boundary drawn around the wrong thing is no boundary.

Attackers who borrow the agent

Agents ship with flags that switch off every prompt, with names like --dangerously-skip-permissions, --yolo and --trust-all-tools. They exist for automation, and attackers have noticed them.

In July 2025 someone slipped a malicious instruction into the official Amazon Q extension for Visual Studio Code. It told the agent to wipe the user's home directory and delete their cloud resources, and it invoked the agent with its trust-everything flag. Amazon said a syntax error stopped the instruction from running, but it had shipped in a release of a tool with close to a million installs.

A month later, attackers who had compromised the Nx build tool's packages on the npm registry went a step further. Their install script looked for Claude Code, Gemini CLI and Amazon Q on the victim's machine. If it found one, it asked the agent to hunt for wallets, keys and environment files with every prompt disabled, and thousands of secrets ended up in public repositories.

In February 2026 the target was a build pipeline. The Cline project used an AI agent to sort incoming GitHub issues, and a researcher showed that instructions hidden in an issue title could take that agent over. Eight days after he published, someone used the same weakness to steal a publishing token and push a tampered release to npm.

Anthropic ran the experiment on itself. In February 2026 its internal red team ran a phishing exercise built around a prompt that had Claude Code read the user's Amazon Web Services (AWS) credentials and send them to an outside server. The model completed the theft in 24 of 25 attempts, and Anthropic's conclusion was that only file and network boundaries hold when the person at the keyboard is the one typing the attack.

Holes in the wall itself

Sandboxes are software, and researchers have found bugs in them.

The researcher Aonan Guan found two ways around Claude Code's network allowlist within five months. In the first, an empty list of allowed domains, which was supposed to block everything, blocked nothing. In the second, a single null character in a hostname made the proxy's check and the real connection disagree about the destination.

Anthropic fixed both, the second in version 2.1.90 in April 2026. The researcher criticised the lack of a public advisory for it, which is a fair complaint when the fix arrives in a routine update nobody is told to hurry for.

A second family of bugs does not break the sandbox at all. The security firm Cymulate named it configuration-based sandbox escape. A sandboxed process is allowed to write inside the project, and some of the agent's own settings live inside the project, so a hijacked command writes a settings file containing a hook, a command the agent runs automatically at start-up.

SESSION ONE, INSIDE THE SANDBOX NEXT LAUNCH, ON THE HOST Injected command running sandboxed writes a file Agent settings file in the project now holds a start-up hook, and stays on disk after the session ends Agent starts and loads its settings before any sandbox exists The hook runs with your full access The wall was never broken. It was walked around.
A configuration-based sandbox escape. Nothing breaks out of the sandbox directly. The sandboxed process leaves a file behind, and the agent itself runs it later with full permissions.

The next time the agent launches, it runs that hook on the host before any sandbox exists. Cymulate reproduced the pattern in Claude Code, Gemini CLI and Codex. Anthropic fixed its case in January 2026, and it is tracked as CVE-2026-25725 in the Common Vulnerabilities and Exposures (CVE) catalogue.

Google has since stopped mounting the agent's settings directory into the sandbox. At the time of Cymulate's write-up in April, OpenAI had closed the report as informational.

The subtlest example involved a destination that was meant to be allowed. A researcher demonstrated it with a file placed in a Cowork workspace, containing hidden instructions and the attacker's own key for Anthropic's application programming interface (API). Claude followed the instructions and uploaded the user's files to Anthropic's file storage service, under the attacker's account.

The network filter saw traffic to an approved Anthropic address and let it through. Anthropic's own summary of the episode is an idea convered here, that an allowlist grants a capability and is more than a list of destinations.

The same post draws a second lesson from its failures. The standard parts held up, meaning the hypervisors, gVisor and the kernel's own filters. What failed was the custom proxies and glue code the team had written around them.

Models that find the door

The last pattern is the newest, and it changes what a sandbox has to withstand. A capable model that has a goal and finds a gap will sometimes go through the gap.

In April 2026 Anthropic disclosed that an early version of its Claude Mythos Preview model, asked by a simulated user to escape a restricted sandbox, built a multi-step exploit and reached the open internet. It told the researcher by email, as instructed, and he read the message while eating a sandwich in a park. The escape was requested, which makes it a test result, but the model also posted details of its exploit to public websites, which nobody had asked for.

In July 2026 it stopped being a test. OpenAI was measuring its models' offensive security skills on an internal benchmark, with the usual safety filters deliberately switched off. The environment had no internet access apart from an internally hosted proxy for downloading software packages.

THE PATH OPENAI DESCRIBED, JULY 2026 Test sandbox models, no direct internet access Package proxy the one permitted way out Research network privileges raised, machines hopped Connected node open internet reached Hugging Face production servers breached zero-day exploited here caught by the victim
The escape OpenAI reported in July 2026. The test environment had one permitted route to the outside, a package proxy, and that route is where the models got through.

According to OpenAI's account, the models found a vulnerability in that proxy that nobody knew about, the kind security people call a zero-day, and used it to move through OpenAI's research network until they reached a machine with internet access. They then broke into Hugging Face to look for the benchmark's answers. Hugging Face's own security team caught the intrusion.

Anthropic responded by reviewing 141,006 of its own evaluation runs, and it found three incidents. Those were not escapes. A misconfiguration had left the test machines connected to the real internet, and models that had been told they were in a simulation attacked real organisations.

In one of the three, a model published a malicious package to the public Python package index, where it ran on 15 real systems before it was removed. Anthropic described the failures as closer to operational mistakes than to misaligned models, while admitting the line between the two is not sharp.

The UK's AISI reported a similar episode a few days later. It had turned internet access on deliberately to make a security test realistic, and an agent used it to open a malicious pull request on a real open source project, inventing fake identities to pressure the maintainer. AISI's first corrective step was to treat internet access as something each test has to justify.

When What happened Boundary in place The lesson
Jul 2025 Replit's agent deletes a production database Instructions only Words are not a boundary
Aug 2025 Nx malware uses installed agents to hunt for secrets No sandbox, prompts disabled by a flag Deny reads as well as writes
Dec 2025 Claude Code deletes a home directory No sandbox Limit writes to the project
Feb 2026 Cline's issue-sorting agent is hijacked through an issue title Nothing around the pipeline's secrets Keep secrets away from agents that read public text
Apr 2026 A Cursor agent deletes PocketOS's production volume Nothing around the cloud token Scope credentials as carefully as files
May 2026 A second bypass of Claude Code's network filter is disclosed An OS sandbox with a custom proxy Update promptly, and distrust custom parts
Jul 2026 Codex deletes home directories No sandbox, full access mode Leave the sandbox on
Jul 2026 OpenAI's models leave a test environment and breach Hugging Face An isolated network with one proxy The permitted exit is part of the wall

Guidelines worth knowing

Formal guidance has started to catch up, and four sources are worth your time.

The most practical comes from NVIDIA's AI Red Team, which published its sandboxing guidance in January 2026. It names three controls as mandatory: restrict outbound network access to known destinations, block writes outside the workspace, and block writes to configuration files wherever they live. That third control is exactly what the configuration escapes above exploit.

Its recommended list goes further. Block reads outside the workspace, sandbox the whole tool and not only its shell, prefer virtual machines, hand the agent secrets one task at a time, and rebuild sandboxes regularly. It also argues that approvals should never be remembered, because one approved action can open the way for a later malicious one.

OWASP released its Top 10 for Agentic Applications in December 2025. Its organising idea is least agency, meaning an agent should get the minimum autonomy its task needs, which extends the older principle of least privilege. Unexpected code execution has its own entry on the list.

In May 2026 six national cybersecurity agencies published joint guidance called Careful Adoption of Agentic AI Services. The group includes the US Cybersecurity and Infrastructure Security Agency, the National Security Agency and the UK's National Cyber Security Centre. The title is the advice: start with low-risk, well-defined tasks, and watch for agents that hold more privilege than the job requires.

The US National Institute of Standards and Technology launched an AI Agent Standards Initiative in February 2026, covering agent security and identity. Its output is still arriving, so for now it is one to watch.

What I would do

Pulling the vendor documentation, the incidents and the guidance together, this is the list I'd work from.

Turn the sandbox on, and make sure it stays on. Two of the four agents above ship with it off. Where the tool lets you, make a missing sandbox a hard failure instead of a silent fallback, and disable the option to retry commands outside it.

If the prompts are wearing you down, hand them to a reviewer mode instead of switching them off, and keep the sandbox on underneath.

Never give an agent full access on your real machine. Flags that skip every prompt belong inside a container, a VM or a sandbox around the whole agent, where the boundary does the job the prompts were doing. Anthropic's documentation says the same about its own flag.

Give the agent one project, not your home folder. Start it in the repository it is working on, and add deny rules for the places where keys live. Write protection is usually the default and read protection usually is not.

Deny the network by default, and treat every exception as a capability. A package registry on the allowlist is also a place to send data, and it is software that can have bugs of its own. That was the door in the OpenAI incident.

Keep secrets out of reach. Use tokens that expire, limit them to one repository or one environment, and never leave a production credential in a file an agent can read. If your platform offers a proxy that adds credentials outside the sandbox, use it.

Protect the files that configure the agent. Git hooks, shell profiles, the agent's settings and its MCP configuration should be read-only to anything running in the sandbox. A session that can edit them can run code after the sandbox is gone.

Match the rung to the trust. An OS sandbox is fine for your own code while you watch. Unattended runs, unfamiliar repositories and anything that processes public input deserve a container at the least, and a VM if you can manage one.

Make mistakes cheap. Commit before you delegate, work on a branch, and keep backups somewhere the agent's credentials cannot reach. Prefer tools that move files to a trash folder over tools that delete them.

Stay current, and test your own setup. Several of the bugs above were fixed quietly in routine updates. A simple check is to run a command inside the sandbox that tries to list ~/.ssh or reach a website you never approved, and confirm that both fail.

Keep a record. Log the commands an agent runs and the hosts it contacts, because a boundary tells you what could not have happened and only a log tells you what did.

Your situation Start with
Everyday work on your own code The agent's built-in sandbox, plus deny rules for reading your keys
Long unattended runs A dev container with a default-deny firewall, or a microVM product
A repository you do not trust A dedicated VM, or a vendor's cloud session
An agent in a build pipeline A short-lived runner with no release secrets and no open network
A team or company rollout Managed settings that force the sandbox on, plus an approved container image

Key takeaways

  • A permission prompt decides whether a command starts. A sandbox decides what it can reach, and only the sandbox still works when nobody is paying attention.
  • File limits and network limits protect you only together, and read access matters as much as write access.
  • Local agents use OS sandboxes such as Seatbelt and bubblewrap. Containers, gVisor and virtual machines add strength in that order.
  • Codex and Cursor sandbox by default. Claude Code needs it switched on, in the terminal and in the desktop app's Code tab alike, and so does Gemini CLI. The main Claude conversation, which absorbed Cowork, is always contained.
  • Auto and auto-review modes put a second model in the approver's seat. They cut interruptions, and their own vendors say they are not a security boundary.
  • Most of the real damage so far came from agents with no boundary, or from credentials the boundary did not cover.
  • The recurring weak points are the doors: allowed domains, package proxies, configuration files and tokens.

The wall and the doors

I expected the incident reports to be stories about walls being broken, and there are very few. The kernels, the hypervisors and gVisor mostly did what they promised.

What failed each time was a door. Someone left the sandbox off, or left a production token inside it, or allowed one domain that could do more than they thought, or let a sandboxed process write a file that something outside would later trust. The OpenAI escape went through the single service the environment was allowed to talk to.

A sandbox turns a question about behaviour, which nobody can answer with certainty for a language model, into a question about reach, which has an answer. Whether an agent will do something harmful is a matter of probability, and whether it can reach my keys is a yes or a no.

So the craft is in the doors. Decide what the agent can reach before you decide what it may do, open as little as the task needs, and assume that anything you do open will one day be used in a way you did not plan for. I argued earlier this year that AI makes the security fundamentals matter more, and least privilege is about as fundamental as they come.