Skip to main content

Running Claude Code in a Devcontainer for Untrusted Repos

Why run Claude Code in a dev container

Run Claude Code in a dev container because a repository can execute code on your machine before Claude Code asks you anything. On 1 September 2026 Manifold Security published GitSpawn: eight arbitrary-code-execution findings across seven AI coding agents (Claude Code, OpenAI Codex CLI, Cursor, Goose, Qwen Code, Grok Build and Hermes Agent). All seven failed the same test.

The mechanism is core.fsmonitor, a legitimate Git performance setting for large repositories. It names a helper program that Git runs whenever it refreshes the index, and a repository can set it in its own .git/config. Agents run git at session startup to gather context: the branch, the dirty files, the recent diff. Most of those calls refresh the index, so Git launches the helper as a subprocess before any trust prompt and outside the agent's sandbox.

This is not prompt injection. The model never sees it, and neither does the agent's permission model. The code runs as your user account, with everything that account can reach.

A dev container changes what that account can reach. If the first git call against unknown code happens inside the container, the helper runs as the container user and sees only what the container was given. In SWARECO's write-up of GitSpawn, opening unknown code in a container or a virtual machine before any agent touches it is one of the changes we recommend for teams running coding agents on client code.

Where Claude Code stood after disclosure

Both Claude Code findings had different outcomes: the core.fsmonitor path was patched, and a second path was still unpatched when Manifold Security published.

Claude Code finding Version tested Status on 1 September 2026 CVE
core.fsmonitor path 2.1.196 Patched None assigned
ultrareview path 2.1.252 Unpatched at publication None assigned

Across all seven agents, four of the eight findings were still unpatched on the day of publication. Cursor and OpenAI Codex were listed as patched.

When SWARECO checked on 10 September 2026, the current released Claude Code version was 2.1.267, newer than both versions tested. That does not by itself mean both findings are fixed, and we have not re-tested them. Upgrade, then record the version you actually have installed; nine days was enough for the versions to move.

Which git commands run the repository's code

Only git commands that refresh the index run the helper. SWARECO tested this on 10 September 2026 on git 2.39.1 on macOS, using a scratch repository whose core.fsmonitor pointed at a harmless program that writes a marker file, deleted before each run.

Git invocation Ran the repository's program
git status Yes
git diff Yes
git log --oneline -1 No
git rev-parse --show-toplevel No
git config --list No
git -c core.fsmonitor=false status No
git -c core.fsmonitor= status No

This matters for a devcontainer setup because the helper runs wherever the calling process lives. An agent inside the container that opens with git status runs it inside the container. Anything on the host machine that runs git status or git diff against the same directory runs it on the host, container or not.

Why a global git setting and workspace trust don't help

Setting core.fsmonitor to false in your global git config does not protect you. SWARECO tested it on 10 September 2026: with git config --global core.fsmonitor false in place, a plain git status inside the poisoned repository still ran the program. Repository-local config takes precedence over global config, and here the repository is the attacker.

The inline form does work, because a value passed with -c outranks the repository file:

git -c core.fsmonitor=false status

You can use that in your own scripts, but you cannot make an agent's background git calls use it. Manifold Security's recommended fix is for vendors to sanitise the git config on those context-gathering calls, so that part is your vendor's job.

Workspace-trust dialogs don't close the gap either. They gate what the editor does after it loads a folder; GitSpawn fires inside a git subprocess during context gathering, which happens first. That leaves isolation as the control you own.

Get code into the container by cloning, not copying

Clone from the forge inside the container rather than mounting a folder someone sent you. SWARECO tested this on 10 September 2026: git never carries core.fsmonitor across a clone, and the cloned copy did not run the program.

The risk arrives when a directory that already contains its own .git folder lands on your machine.

How the code arrives Keeps the sender's .git/config What to do
git clone from GitHub or another forge No Clone inside the container
Zip, archive attached to a ticket, shared drive, sync folder, USB stick Yes Check before anything opens it; re-clone if you can
Handover from a previous vendor or an export from someone's laptop Yes Same as above

For a consultancy, receiving a folder is routine: a client who cannot grant repository access yet sends a zip, and the next step is usually opening it in an agent to see what is inside. Re-cloning from the forge removes that vector.

Check a received folder before mounting it

Check one repository:

git config --get core.fsmonitor

Empty output means the setting is absent. Any output is worth reading before you open the folder in anything. Sweep a directory of repositories without invoking git at all:

find . -path '*/.git/config' -exec grep -l 'fsmonitor' {} +

Clear a setting you did not put there:

git config --unset core.fsmonitor

SWARECO confirmed on 10 September 2026 that after the unset, the same git status no longer ran the program.

Setting up the dev container

The setup is two files under .devcontainer/ (a Dockerfile and a devcontainer.json), the Claude Code CLI installed inside the container, and VS Code's Reopen in Container to attach. A minimal devcontainer.json:

{
  "build": { "dockerfile": "Dockerfile" },
  "postCreateCommand": "curl -fsSL https://claude.ai/install.sh | bash"
}

The Dockerfile carries the project's toolchain (Node and npm, Python, whatever the repository needs) and should run as a non-root user. Four choices matter more than the rest:

  • Use your own container definition. A received repository's .devcontainer/ folder and Dockerfile are files the repository controls, the same way its .git/config is. Keep the sandbox definition outside the untrusted code.
  • Mount only the workspace. Do not mount your home directory, ~/.ssh or cloud credential directories. Anything mounted is within reach of code running inside the container.
  • Record the Claude Code version. 2.1.267 was the current release on 10 September 2026; check what the container actually installed.
  • Rebuild the container when you finish with an unknown codebase, so nothing it wrote outside the workspace carries over.

What the container does not fix

A dev container limits where repository-controlled code runs; it does not limit what that code can do with whatever you hand the container.

  • Bind-mounted SSH keys and credentials. If they are in the container, the helper can read them. The same goes for tokens for MCP servers you configured but don't need for this task. Mount secrets read-only and only for the work that needs them.
  • Open egress. Code that runs inside the container can send what it reads to the network. Restrict outbound traffic to the services the work needs.
  • Host-side git before the container starts. If your editor's source-control integration runs git status when the folder opens on the host, a poisoned .git/config runs on the host before Reopen in Container does anything. Clone inside the container, or run the fsmonitor check first.
  • The bypass flag. --dangerously-skip-permissions does not change GitSpawn, which already runs before any prompt, but it removes the remaining check on everything else the agent does with untrusted code. Don't combine it with unknown repositories.
  • Unpatched agent paths. The Claude Code ultrareview path was unpatched at publication on 2.1.252. The container contains the damage; it does not patch the agent.

Checklist

  1. Upgrade Claude Code and record the installed version.
  2. Clone from the forge inside the container; don't mount a received folder if you can re-clone.
  3. If you must use a received folder, run git config --get core.fsmonitor or the find sweep before anything opens it, and unset what you didn't set.
  4. Use your own devcontainer definition, not one shipped in the untrusted repository.
  5. Mount the workspace only; keep the home directory, SSH keys and credentials out.
  6. Restrict outbound network access.
  7. Don't rely on git config --global core.fsmonitor false or workspace trust.
  8. Ask any vendor whose tool runs git in the background whether it sanitises the config on those calls.
  9. Rebuild the container after working on unknown code.

We build the engineering You build the business

If you are trying to figure out whether SWARECO is the right fit for what you are building, the best way to find out is to talk. Tell us what you have. We will be direct about what we can do and how we would approach it.