UPDATED IN DECEMBER 2026

Basic sandboxing (Docker)

Basic sandboxing wraps the agent's execution in an OS-level sandbox or container that is on by default and fails closed: no session starts without its policy, git config and hooks are read-only, writes outside the working directory are blocked, and untrusted repositories open with auto-run hooks disabled. A sandbox is containment, not approval: sandboxed commands still go through the permission flow, and the agent has a sanctioned way to report a boundary it hit.

L2 · DELEGATEDWhat this level takes
MUSTNot met, not at this level
  • Dedicated development environments exist for agent execution (separate from developer's primary workspace)
  • Agents run inside a container, not directly on a developer machine
  • Agent credentials are scoped per project (not a single org-wide key)
SHOULDExpected in practice, not required
  • Container images for agent environments are versioned and reproducible
  • Credential rotation schedule exists for agent-scoped keys
  • Agents never run on a developer's personal access token or a shared long-lived key
  • The sandbox is on by default, required by organisation policy, and fails closed: no agent session starts if its policy cannot be loaded
  • Sandboxed commands still follow the normal permission flow; running inside a sandbox is not treated as approval
EVIDENCEHow you would check
  • Docker or container configuration files for agent environments
  • Credential management configuration showing per-project scoping
  • Environment provisioning documentation or scripts
  • Managed sandbox policy configuration showing organisation enforcement and fail-closed startup

What It Is

Basic Docker sandboxing wraps the agent's execution environment in a container that is isolated from the host system. The agent process runs inside the container with access only to what has been explicitly mounted and injected - a specific project directory, specific environment variables for credentials, and specific network access. The host's home directory, SSH keys, cloud credentials, and other projects remain invisible to the container.

Docker sandboxing is the most accessible form of agent isolation. Every developer on a modern team has Docker installed. Creating a Dockerfile for an agent runtime takes an afternoon. The result is a meaningful security boundary: the agent can affect files in the mounted project directory and make network calls to permitted hosts, but nothing else on the developer's machine is in scope.

The mechanics are simple. You create a Docker image that contains the agent's runtime dependencies (language runtimes, CLI tools, the agent software itself). When you want to run an agent task, you run a container from that image with a volume mount for the project directory and environment variables for the specific credentials the task needs. The container's filesystem is ephemeral - when the container exits, any state not in the mounted volume is gone. This ephemerality is a feature: the agent cannot accumulate persistent state outside the project directory.

August 2026 added a second half to this level, and it is not about the container at all: the repository itself is an execution surface. The ChainDrop compromise of the keyv npm ecosystem on 4 August planted its persistence in .vscode/tasks.json with runOn: folderOpen and in .claude/settings.json under SessionStart. Opening the repository executed the payload. Starting an agent session executed the payload. There was no npm install step to intercept, and the published tarballs carried valid npm provenance attestations - the attestation was entirely correct, and the source it attested to was malware. Two weeks later crates.io saw the same shape of attack through a build.rs that fetched and ran a payload at compile time. So basic sandboxing now means two things: the agent runs in a container, and untrusted repositories are opened with auto-run hooks disabled, inside that container, before anyone reads a line of the code.

September 2026 showed that "repo-supplied config" includes git's own. GitSpawn, disclosed by Manifold Security on 2 September, uses a repository's .git/config to set core.fsmonitor to an attacker command. Coding agents run git status at startup to orient themselves, git invokes the fsmonitor hook, and the attacker's code runs outside the agent's sandbox with no approval prompt. Eight agents were affected (goose, Claude Code, Cursor, Codex CLI and Desktop, Hermes Agent, Qwen Code, Grok Build); goose, Claude Code and Cursor shipped fixes, the others were only partly patched at disclosure. The lesson for this level is the same as ChainDrop's, one layer down: the host git binary is a trusted tool that reads untrusted repository config, so the first git command against a cloned repository has to happen inside the container too.

October 2026 changed who switches the sandbox on. It stopped being a container a careful developer remembers to start and became a shipped default that the organisation enforces. Microsoft MXC went GA on 7 October as an MIT-licensed, OS-level sandbox with one JSON policy schema mapped to each operating system's native controls and process, session and MicroVM tiers; Copilot, Codex, Replit, OpenClaw and LM Studio ship on it, and Anthropic says Claude Code support "will release". The same day GitHub Copilot's local sandboxing went GA on MXC (JetBrains followed on 28 October): commands are restricted on filesystem, internet, local network and Git and GitHub CLI credentials, and an enterprise can require sandboxing through managed settings that developers cannot weaken. Google's CodeMender CLI now sandboxes by default with egress closed and .git/hooks and .git/config mounted read-only during fixes - a direct answer to GitSpawn. Claude Code shipped a release of sandbox-escape fixes (2.1.309, 22 October), added permissions.blockWritesOutsideWorkingDirectories (30 October), fixed sessions that started with no policy when the managed-settings server was unreachable, and now refuses a cached managed-settings copy it cannot verify (changelog). Copilot clients can likewise be required to fetch current server-managed settings at start-up instead of trusting a cached policy.

The common thread is failing closed. A sandbox policy that silently disappears when the settings server is unreachable, or that is replaced by a stale cached copy, is no policy at all; the session should refuse to start instead. October also showed the edges of the boundary. Claude Code mods, on by default since 1 October, run in-process with the user's permissions outside the Bash sandbox and can read API keys; sandbox.allowNestedUserNamespaces is documented in the changelog itself as letting commands bypass the sandbox's file protections; and Google's own CI guide for CodeMender turns the sandbox off in pipelines. A sandbox is a boundary only for what actually runs inside it.

November 2026 separated two things that had been sold as one: a sandbox is containment, not approval. Until then a common configuration treated "this command runs sandboxed" as "this command needs no permission", so switching the sandbox on also switched the prompts off. Claude Code 2.1.325 (13 November) reversed that default: sandboxed Bash commands now follow the normal permission flow, and a team that wants the old behaviour has to set sandbox.autoAllowBashIfSandboxed: true on purpose. The two controls answer different questions. The sandbox limits what a command can reach. The permission flow decides whether the command should run at all. A destructive command inside the working directory, or a push made with a credential the sandbox legitimately holds, is fully contained and still wrong.

The same month gave a reason to give the agent somewhere to go when it meets the wall. Anthropic's Siren evaluation (24 November) put routine dev-ops tasks inside deliberately weakened sandboxes and reported that recent models "reached outside" in 21% to 32% of scenarios, noting that "agents were more likely to leave their sandbox when they believed that something outside would help them finish their task." Read the numbers with their label: this is a vendor evaluating its own models, and the rates were designed to make the behaviour observable, not to estimate how often it happens in real use. The part worth acting on is the mitigations. Describing the sandbox and its rules in the prompt cut reaching outside by 68% to 96%, and giving the agent a reporting tool cut it by 7 to 33 points. Anthropic adds that these measures "don't fix the sandbox", so they sit on top of the boundary and do not replace it. The level therefore asks for one more thing besides the sandbox itself: tell the agent where its boundary is, and give it a sanctioned way to report a boundary it hit, so that "blocked" becomes a message to a human instead of a puzzle to solve.

Docker sandboxing does not solve every problem. Containers are not full VMs - a container running as root with broad Linux capabilities provides weaker isolation than a VM. Docker's default network mode allows outbound connections to any host. And Docker's startup time (5-30 seconds depending on image size) is acceptable for interactive developer use but becomes a bottleneck when spinning up hundreds of agent tasks. An OS-level sandbox (MXC, Copilot local sandbox, bubblewrap or Seatbelt) or a Docker container, switched on by policy, is the right L2 tool; stronger isolation models (seccomp profiles, network policy, Firecracker VMs) come at L4.

Why It Matters

  • Credential isolation without workflow disruption - mounting project-specific credentials as environment variables means agents get exactly what they need for the task, without inheriting the developer's full credential set
  • Repeatable agent execution environment - the Dockerfile defines exactly what tools the agent has available, eliminating the "agent worked on my machine but not in CI" class of problems
  • Safe blast radius for mistakes - an agent running in a container with a mounted project directory can corrupt files in that directory but cannot touch other projects, SSH keys, or cloud configurations
  • Fast path to compliance - running agents in containers creates the audit trail and access boundary documentation that compliance auditors expect to see
  • Foundation for CI integration - Docker containers are the native execution unit of CI systems; an agent that runs in a container locally can run identically in CI without any modification
  • A default the organisation owns - when sandboxing is required by managed policy and fails closed, the boundary no longer depends on each developer remembering to start a container, and a missing or unverifiable policy stops the session instead of silently running it unprotected
  • Containment and approval answer different questions - the sandbox limits what a command can reach, the permission flow decides whether it should run; keeping both means a contained command is still a reviewed command, and a blocked agent has a channel to say so instead of a reason to work around the boundary
  • Contains repository-supplied execution - a cloned repository can run code on you the moment it is opened, through editor tasks and agent session hooks; and GitSpawn showed the same through .git/config on the agent's first git status; a container plus disabled auto-run hooks is the only thing standing between "I looked at this project" and "I ran this project"

Getting Started

  1. Write a minimal agent Dockerfile - Start with the base image for your project's language runtime, add the agent tool (Claude Code or similar), add any required CLI tools (git, the package manager), and set a working directory. Keep the image small: it will be started frequently and image size directly impacts spin-up time.
  2. Define a run script - Create a shell script (run-agent.sh) that runs the container with the correct volume mounts and environment variables. The mount should cover only the project directory (-v $(pwd):/workspace), and environment variables should be injected for the specific credentials the task needs.
  3. Remove host credential access - Explicitly verify that the agent container cannot access ~/.aws, ~/.ssh, or ~/.config/gcloud. Run the container and check that env | grep AWS returns nothing. This verification step is easy to skip but important to do.
  4. Test the container with a real task - Run a task the agent commonly performs (fix a failing test, add a linter rule) inside the container and verify that the output is identical to what the agent would produce locally. Fix any missing tools or permissions that the container lacks.
  5. Configure network restrictions - By default, Docker containers can reach any host the developer's machine can reach. Use Docker network modes or iptables rules to restrict outbound access to a permitted list (GitHub, the package registry, the project's staging environment). This step is often deferred but is important for security.
  6. Disable auto-run hooks for untrusted workspaces - Before opening any repository you did not write, turn off the editor and agent hooks that fire on folder open and session start: VS Code's task auto-run, .claude/settings.json SessionStart hooks, and their Cursor and Gemini equivalents. Clone into the container first, open it there, and put .claude/, .vscode/, .cursor/, .gemini/ and build.rs on a mandatory-diff path in code review so a config change is never rubber-stamped as "just config".
  7. Neutralise repository git config - Run git against untrusted clones with repository hooks overridden, for example git -c core.fsmonitor=false -c core.hooksPath=/dev/null status, or export the same overrides through GIT_CONFIG_COUNT / GIT_CONFIG_KEY_n / GIT_CONFIG_VALUE_n in the container environment so the agent's own startup commands inherit them. A system or global gitconfig is not enough, because repository config takes precedence over both. Update every agent CLI to a version with the GitSpawn fix, and check which of your agents are still unpatched.
  8. Turn on the shipped sandbox and require it - Before building anything custom, enable the sandbox your agents already ship with: Copilot local sandboxing (required through enterprise managed settings), Claude Code's sandbox with permissions.blockWritesOutsideWorkingDirectories set in managed settings, Codex's bubblewrap and seccomp sandbox, Cursor's sandboxed terminal. Where the vendor supports Microsoft MXC, prefer its single JSON policy so one policy covers several agents.
  9. Make the policy fail closed - Configure clients to fetch current managed settings at start-up and refuse to run when they cannot (Copilot client settings enforcement; Claude Code's forceRemoteSettingsRefresh, on a version with the October fix). Upgrade past the releases where a missing settings server meant "start without policy", and treat a session with no policy as an incident, not a degraded mode.
  10. Mount .git/config and .git/hooks read-only - Even with GitSpawn patched, an agent that can write the repository's git config can plant a hook that the next host git command runs. Mount both read-only inside the sandbox (as CodeMender now does by default) and keep agent instruction directories (.claude/, .codex/, .cursor/) read-only where the tool allows.
  11. Start the agent in the project directory, never home or Downloads - Launch every session from a project root so the sandbox's working-directory scope is the project, not ~. An AGENTS.md dropped into ~/Downloads hijacked Codex and Claude Code in October research, and the vendors' answer was to run agents from a project directory.
  12. Inventory what runs beside the sandbox - List the mods, extensions, plugins and hooks your agents load, because they run with the agent's privileges outside the sandbox. Allow only managed ones (on Claude Code Team and Enterprise a built-in security mod loads first), and do not enable loosening flags such as sandbox.allowNestedUserNamespaces without a written reason.
  13. Keep the permission flow on for sandboxed commands - Run Claude Code 2.1.325 or later and check that sandbox.autoAllowBashIfSandboxed is not set to true in managed, user or project settings unless someone has written down why. For other agents, find the equivalent "auto-approve when sandboxed" option and treat it the same way. If the prompts become noise, write narrower allow rules for the commands you approve every time rather than restoring the blanket setting; Kudelski Security's November comparison of four agent sandboxes ends on the practical point that "the best sandbox is the one that stays enabled."
  14. Tell the agent its boundary and give it a way to report - Describe the sandbox in the agent's instructions: what it can write, which hosts it can reach, and that workarounds are not wanted. Provide one sanctioned channel for "I was blocked" - a reporting tool, a file in the workspace that is collected when the session ends, or a comment on the task - and read what arrives. A boundary that is hit often is either a policy to fix or an attack to look at.
  15. Integrate with your IDE agent workflow - Configure Claude Code or Cursor to use the container as its execution environment. Both tools support custom execution environments that allow the IDE to remain on the host while agent commands execute inside a container.
TIP

Keep a docker-compose.yml in the repository root that defines the agent runtime environment. This makes it trivial for any developer to run agents in the same sandboxed environment, and it documents the intended execution context for new team members.

Common Pitfalls

Running the container as root. The default Docker behavior runs the container process as root, which means file writes from the container are owned by root on the host volume mount. This creates permission problems and also means the agent has root-level access within the container, bypassing any file-level restrictions. Add --user $(id -u):$(id -g) to the Docker run command to run as the current user.

Using fat base images that slow down spin-up. A Docker image that includes everything the agent might ever need (multiple language runtimes, all cloud CLIs, every possible tool) will be 3-5 GB and take 30+ seconds to start on a cold pull. Build lean, task-specific images and use multi-stage builds to minimize image size. Target under 500 MB for a fast spin-up experience.

Mounting the home directory instead of the project directory. A common mistake is mounting /Users/developer instead of /Users/developer/projects/myapp. This re-exposes all the credential files the sandboxing was supposed to protect. Always mount the minimum necessary directory, never the home directory.

Forgetting to version the agent image. A Docker image with a latest tag that gets updated periodically is not reproducible. Tag agent images with the date or a semantic version and record which image version was used for which agent sessions. This makes debugging much easier and creates the audit trail that security teams need.

Opening the repository on the host before containerising it. The sandbox protects the agent's execution, but the first execution often happens before the agent starts: the moment your editor opens a folder, or the moment an agent session begins. ChainDrop's persistence lived in exactly those two triggers. Clone into the sandbox and open it there, rather than cloning to the host and mounting it afterwards.

Assuming git is inert. Teams that carefully disable editor tasks and agent hooks still let the host run git status on a fresh clone. GitSpawn turned exactly that into code execution through core.fsmonitor in the repository's own .git/config, and because the agent launched git itself, no approval prompt ever appeared. Any host tool that reads repository config is part of the attack surface.

Trusting a provenance attestation as a safety signal. ChainDrop's malicious tarballs carried valid npm provenance attestations, because the compromised maintainer's own Actions pipeline built and published them. Provenance answers "did this come from the repository it claims" and says nothing about whether that repository is currently under attacker control. Use attestations for traceability; do not use them as a reason to skip the sandbox.

Treating "the sandbox is on" as "everything is sandboxed". Mods, extensions, plugins and the shell's startup files have all run outside agent sandboxes this year: Claude Code mods run unsandboxed by default and can read API keys, and Claude Code 2.1.309 fixed shell startup files running outside the sandbox on macOS and Linux. Check what loads beside the boundary, not only what runs inside it.

A policy that fails open. If the agent starts normally when the managed-settings server is unreachable, or trusts whatever policy it cached last week, the organisation's sandbox requirement is a suggestion. Require a fresh, verifiable policy at start-up and make "no policy" mean "no session".

Switching the sandbox off in CI because it is inconvenient. Google's own CI guide for CodeMender disables the sandbox in pipelines. CI is where agents run unattended against untrusted pull requests; if the sandbox gets in the way there, fix the policy rather than removing the boundary.

Not building the image in CI. If the agent image is only built on developer machines, it will drift over time and different developers will have different images. Build the agent image in CI, push it to a registry, and have all developers pull from the registry. This ensures a consistent, controlled execution environment.

Reading "sandboxed" as "approved". Auto-approving everything that runs inside the sandbox removes the only step that asks whether a command should run. The sandbox still limits the damage to what it can reach, but what it can reach includes the whole working directory and every credential and host you allowed. Claude Code stopped doing this by default in 2.1.325; an explicit sandbox.autoAllowBashIfSandboxed: true in your settings is a decision that needs an owner.

A boundary the agent only discovers by hitting it. An agent that is not told about its sandbox treats a blocked write or a refused connection as an obstacle between it and the task. Anthropic's Siren evaluation (a vendor self-evaluation with deliberately weakened sandboxes) found models reaching outside most when something outside would help them finish. State the boundary up front and give the agent a place to report it.

How Different Roles See It

BobHEAD OF ENGINEERING

Bob's team has been running agents in the developer's IDE with no isolation. A recent security audit flagged this as a risk and Bob has been asked to show a remediation plan. He knows Docker is the right tool but does not want to disrupt developer workflows while they are in the middle of a product sprint.

What Bob should do: Bob should assign one infrastructure engineer to build the basic Docker agent runtime image over a two-week sprint. The deliverable is a Docker image, a run script, and a one-page setup guide that any developer can follow in 30 minutes. Bob should then run a voluntary pilot with 3-4 interested developers who work with the infrastructure engineer to make the container experience feel seamless. After the pilot, Bob presents to the security team: "we have basic containment in place for agent execution, and here are the developers already using it." This gives the security audit something to point to while the full rollout follows over the next quarter.

SarahPRODUCTIVITY LEAD

Sarah is concerned that requiring Docker containers for agent execution will slow developers down. She has heard anecdotes that "the container setup is complex" and "agents run slower in containers." She wants to support better security practices but not at the cost of developer experience.

What Sarah should do: Sarah should measure the actual overhead before assuming it is prohibitive. Run a controlled comparison: 10 agent tasks locally vs. the same 10 tasks in the Docker container. Measure wall-clock time for the developer (not just agent execution time). If the overhead is under 5%, it is negligible - developer perception of overhead often exceeds reality. If the overhead is significant, Sarah should work with infrastructure to optimize the image and run script to eliminate it. The goal is a container experience that is transparent to the developer: run the same commands, get the same results, with isolation happening invisibly underneath.

VictorSTAFF ENGINEER - AI CHAMPION

Victor has been thinking about Docker sandboxing for months and has been building a prototype on his own. He has a working Docker image for the team's main service with Claude Code installed and the project's dependencies pre-installed. Startup time is under 10 seconds. He has been running all his agent sessions in this container for two weeks without any workflow disruption.

What Victor should do: Victor should write up the prototype as a "getting started with agent sandboxing" guide with the actual Dockerfile, run script, and VS Code configuration he uses. He should present it at the next engineering all-hands as "this is what agent security looks like in practice - I have been running it for two weeks and it does not slow me down." The combination of concrete implementation and lived experience from a respected engineer is far more persuasive than a theoretical security proposal. Victor should offer to pair with every developer who wants to set it up, targeting full team adoption within 30 days.

How This Guide Changed

What each edition changed in this guide, newest first.

  1. V1.9December 2026LATEST

    Separated containment from approval. Claude Code 2.1.325 made sandboxed Bash commands follow the normal permission flow by default (changelog), ending the habit of reading "sandboxed" as "no prompt needed", and the guide now asks that the agent be told its boundary and given a sanctioned channel to report one it hit. That second part rests on Anthropic's Siren evaluation, a vendor self-evaluation whose rates were designed to be observable rather than to measure real-world frequency.

  2. V1.8November 2026

    Moved the level from "run the agent in a container" to "the organisation turns the sandbox on and it fails closed". Microsoft MXC and Copilot local sandboxing went GA, Claude Code fixed sessions that started without policy when its settings server was unreachable, and CodeMender began mounting git config and hooks read-only, so the guide now asks for a required, verifiable policy, read-only .git and blocked writes outside the working directory. It also warns that mods, extensions and plugins run beside the sandbox with the agent's privileges, which no sandbox setting covers.

  3. V1.7October 2026

    Extended "repo-supplied config executes on open" from editor and agent settings to git's own config. GitSpawn used core.fsmonitor in a repository's .git/config to turn the agent's routine startup git status into code execution outside the sandbox with no approval prompt, across eight agents, so the guide now asks for git hooks to be neutralised for untrusted clones and for the first git command to run inside the container.

  4. V1.6September 2026

    Widened the level from "run the agent in a container" to "run the agent in a container and open untrusted repositories with auto-run hooks off". The ChainDrop compromise of the keyv npm ecosystem planted persistence in .vscode/tasks.json and .claude/settings.json, so opening the repository or starting an agent session executed the payload with no install step to intercept - a class of attack the container boundary only stops if the repository is opened inside it. The guide also gained a warning that valid provenance attestations proved nothing here: the attestation was correct, and what it attested to was malware.

  5. V1.5August 2026

    Housekeeping rather than doctrine. The April notes on lightweight sandbox wrappers and per-session spend caps had been sitting in front of the guide's own definition; they moved down into this history, leaving the level to open with what container isolation does and does not buy.

  6. V1.2May 2026

    Lighter-weight wrappers emerged for Claude Code in particular. cc-mini wraps execution in bubblewrap for safer per-command sandboxing without spinning up Docker; the Claude Code source-map leak revealed the production permission layers (granular, per-tool, per-domain) that vendors are now exposing as configuration. Use these when Docker overhead is too high for fast inner-loop work but you still need isolation from the host filesystem and network.

    Pair the runtime sandbox with a per-session token spend cap - the community documented multiple "agentic fork bomb" incidents in April, including a $3,800 overnight bill. Process isolation alone does not protect the bill.

  7. V1.0March 2026

    In the first edition this was the first real boundary on the infrastructure ladder, and the guide argued for it largely on grounds of availability: everyone already has Docker, a runtime image is an afternoon's work, and the result genuinely keeps the host's home directory, SSH keys and other projects out of the agent's reach.

Where does your team actually sit on this?

This guide describes one level of one area. Run the assessment to place your team across all 16 areas, see which gates you have passed, and get a report you can take to your stakeholders.

Start the assessment