cd /news/ai-agents/sandboxing-coding-agents-the-approva… · home › topics › ai-agents › article
[ARTICLE · art-182942] src=danholloran.me ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Sandboxing Coding Agents: The Approval Prompt Is Not the Boundary

Coding agent sandboxes must enforce filesystem and network boundaries below the agent rather than relying on approval prompts, because an approved command like `npm install` can execute arbitrary `postinstall` scripts and an approved `make` runs whatever the Makefile says, according to Docker's write-up of coding agent incidents, which notes Cursor now calls its command allowlist best-effort. Claude Code's built-in sandbox uses Seatbelt on macOS and bubblewrap on Linux with outbound traffic routed through a local proxy checking hosts against an allowlist that starts empty, but by default sandboxed commands can still read most of the machine, including `~/.ssh` and `~/.aws/credentials`, and a failed sandboxed command can be retried unsandboxed after a prompt unless `allowUnsandboxedCommands` is set to false. For unattended agents, Anthropic's guidance recommends against plain Docker/runc in favor of microVMs such as Firecracker on Linux and Hypervisor.framework-based VMs on macOS, with egress enforced outside the guest.

recommendation

Configure deny-by-default filesystem reads and network egress below the agent, and disable the unsandboxed retry escape hatch, because an approved `npm install` or `make` can run arbitrary code the command text never reveals.

more in playbook: Securing agents and AI tools
read5 min views2 publishedDec 5, 2026
Sandboxing Coding Agents: The Approval Prompt Is Not the Boundary
Image: Danholloran (auto-discovered)

Every coding agent ships with some version of the same safety model: before it runs a shell command, it asks you. After the fortieth npm test prompt in an afternoon, you add an allowlist, then a broader one, then you start hitting Enter without reading. The prompt is still there. It just stopped being a control.

Allowlists have a deeper problem than fatigue. Docker's write-up of coding agent incidents describes an injected instruction getting a payload executed through a command the user had already approved, and notes that Cursor now calls its command allowlist best-effort. An approved npm install can run any postinstall script in the dependency tree. An approved make runs whatever the Makefile says, and the agent can edit the Makefile. Matching on command text can't tell you what a command will do.

The fix the industry has converged on is to stop asking "should this command run?" and start enforcing "whatever runs, here is everything it can touch."

Two walls, and you need both #

A useful sandbox restricts two things: what the process can read and write on disk, and where it can send bytes over the network. Claude Code's sandboxing docs put the reasoning plainly. Without network isolation, a compromised agent can read your SSH keys and ship them somewhere. Without filesystem isolation, it can rewrite a shell startup file or its own settings to get the network access you denied it.

Claude Code's built-in sandbox is a good concrete example because it uses OS primitives you can reason about: Seatbelt on macOS and bubblewrap on Linux, with outbound traffic routed through a local proxy that checks each host against an allowlist that starts empty. The restrictions apply to every subprocess, so npm, terraform, and anything a postinstall script spawns are covered, not just the agent's own tools.

The default read policy surprises people, though: sandboxed commands can still read most of the machine, including ~/.ssh and ~/.aws/credentials, until you say otherwise. A tighter project-level .claude/settings.json looks like this:

{
  "sandbox": {
    "enabled": true,
    "filesystem": {
      "denyRead": ["~/"],
      "allowRead": ["."]
    },
    "network": {
      "allowedDomains": ["registry.npmjs.org"]
    },
    "credentials": {
      "envVars": [
        { "name": "GITHUB_TOKEN", "mode": "deny" },
        { "name": "NPM_TOKEN", "mode": "deny" }
      ]
    }
  }
}

That blocks reads across your home directory except the project, allows exactly one outbound host, and unsets two tokens before each sandboxed command runs. Two caveats from the docs are worth knowing before you trust it:

  • By default, a command that fails inside the sandbox can be retried unsandboxed after a prompt, which brings back the approval-fatigue problem. You can turn that escape hatch off at launch with claude --settings '{"sandbox": {"enabled": true, "allowUnsandboxedCommands": false}}' .
  • The OS sandbox covers shell commands. The agent's built-in Read and WebFetch tools follow permission rules instead, so a denyRead entry doesn't stop the Read tool. Configure both layers.

Other agents have their own knobs; the shape to look for is the same: deny-by-default reads outside the workspace, deny-by-default egress, enforced below the agent rather than by it.

Containers, VMs, and how strong a wall you need #

If your agent has no built-in sandbox, a container gets you most of the way for interactive work:

docker run --rm -it \
  --network none \
  --cap-drop ALL \
  --security-opt no-new-privileges \
  -v "$PWD":/work -w /work \
  node:22 bash

Only the project is mounted, there's no network at all, and the process can't gain privileges. The catch is that a container shares the host kernel. For agents running unattended, Anthropic's guidance recommends against plain Docker/runc and points to microVMs instead (Firecracker on Linux, Hypervisor.framework-based VMs on macOS), with egress enforced outside the guest. Docker's own Sandboxes product went the same way: each agent gets a microVM with its own kernel and a deny-by-default network behind a host-side proxy.

A reasonable rule: OS-level sandboxing or a locked-down container while you're watching, a microVM when you're not.

The allowlist is also a channel #

Here's the part that's easy to miss. Network isolation decides where data can go, not what goes there. If github.com is on your allowlist and the agent can read a secret, a prompt-injected agent can push that secret to a public gist without escaping anything. Vercel makes this argument directly: isolation without egress control contains the process but not its consequences, and egress control without keeping secrets out still leaves allowed channels open.

So the last wall is keeping credentials out of the sandbox entirely:

  • Keep the allowlist narrow.registry.npmjs.org is a much smaller channel than*.github.com .
  • Don't hand the agent raw tokens. Inject them outside the sandbox instead. Claude Code can mask an environment variable so commands see a placeholder and the proxy substitutes the real value only on requests to hosts you name. Vercel's sandbox does the same with a TLS-terminating proxy on the host, so the key never enters the VM.
  • Treat repo content as untrusted input. Instructions hidden in a README, an issue, or an agent config file are the attack. Sandboxing limits the blast radius; it doesn't make injected text safe to follow.

Where to start #

Turn on your agent's sandbox today and deny reads outside the project, even if you change nothing else. Then audit your network allowlist for anything broader than a package registry, and move tokens out of the environment the agent can see. Approval prompts can stay as a speed bump. Just don't mistake them for the wall. For the other half of this problem, see prompt injection is an architecture problem.

── more in #ai-agents 4 stories · sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/sandboxing-coding-ag…] indexed:0 read:5min 2026-12-05 · —