How to sandbox an AI coding agent before opening an untrusted repo

Quick answer

Do not point an AI coding agent at an unknown GitHub repo and ask it to "get this running" from your normal shell. Treat the repo, its docs, its package scripts, its error messages, and its MCP configuration as untrusted input.

Use this safer default:

Clone into a disposable folder
-> scan docs, scripts, hooks, dependencies, and MCP config before agent use
-> start the agent with no secrets and narrow permissions
-> run setup only inside a sandbox or VM
-> allow network access only when you know why it is needed
-> verify the diff and runtime behavior before trusting the result

This is not paranoia. Mozilla's 0DIN team recently showed a clean-looking repo that could lead an agentic coding tool into running a reverse shell through ordinary setup recovery. The payload was not visible in the repo because it was fetched later from a DNS TXT record. Static review alone would not have seen it.

Who this is for

This guide is for indie developers and small teams using Codex, Claude Code, Cursor, Cline, Copilot, Gemini CLI, or another agentic coding tool to inspect unknown repos, templates, demos, job-take-home projects, open-source examples, or MCP servers.

If you only use an agent inside your own repo, this still matters when the agent reads issue text, copied logs, package READMEs, generated docs, or remote tool output. Prompt injection is not limited to chat. It can arrive through any text the agent reads before it decides what command to run.

Pair this with the npm package vetting workflow for dependency checks and the AGENTS.md setup guide for durable project rules.

What changed and why now

AI coding agents now routinely read files, execute shell commands, edit code, start browsers, call MCP tools, and connect to developer services. That power is the point, but it also changes the threat model.

Three recent signals make this a search-worthy workflow:

The practical conclusion is simple: do not rely on the agent's helpfulness as a safety boundary. Give it a smaller box.

The 20-minute untrusted-repo workflow

1. Clone without running anything

Start with a disposable directory. Do not open the repo from a folder that contains your normal .env, cloud config, SSH material, browser profile, or work secrets.

mkdir -p ~/tmp/agent-intake
cd ~/tmp/agent-intake
git clone --depth 1 <repo-url>
cd <repo>

At this stage, avoid npm install, pip install, curl | sh, make setup, docker compose up, or "let the agent initialize it." First inspect.

2. Scan the surfaces the agent will read

Use fast text search before giving the repo to the agent:

find . -maxdepth 3 -type f \
  \( -name "*.md" -o -name "package.json" -o -name "pyproject.toml" -o -name "requirements.txt" -o -name "Dockerfile" -o -name "*.yml" -o -name "*.yaml" \)

rg -n "curl|wget|bash|sh |base64|eval|exec|python -c|node -e|postinstall|preinstall|prepare|mcpServers|permissions|token|secret|OPENAI|ANTHROPIC|GITHUB"

The goal is not to prove safety. The goal is to find obvious trust jumps before the agent treats them as normal project context.

3. Check package scripts and lifecycle hooks

For JavaScript projects, inspect package metadata before install:

npm pkg get scripts dependencies devDependencies optionalDependencies

If the repo uses npm lifecycle hooks such as preinstall, install, postinstall, or prepare, read them before executing. If a package manager wants to run a build script from an unknown dependency, pause and inspect the package first.

For Python, check pyproject.toml, setup.py, requirements.txt, and any command the README asks you to run. For Rust, check build.rs. For Go, check generator commands and shell scripts. For Docker, read the Dockerfile before assuming the container is safe.

4. Start the agent with a narrow prompt

Ask for analysis before execution:

You are inspecting an untrusted repository.
Do not run install, setup, build, network, package-manager, shell-pipe, or MCP commands yet.
First report:
- suspicious setup instructions;
- package lifecycle scripts;
- files that mention secrets, tokens, or external endpoints;
- commands the README asks a new developer to run;
- the smallest safe next step.

If the agent cannot explain what it wants to run and why, do not approve the command.

5. Run setup only inside an isolation boundary

Use the isolation level that matches the risk:

Repo type Safer boundary
Unknown demo, job task, or template Disposable VM or container with no host secrets
Known open-source project with active maintainers Container or restricted shell, then normal local setup after review
Repo that asks for cloud tokens Test account, scoped token, and separate billing/project
Repo that configures MCP servers Disable by default; review server source and permissions first
Repo that needs browser login Disposable browser profile and test account

Network isolation matters. A sandbox with your full environment variables and outbound network is not much of a sandbox.

6. Make the agent prove the result

After any setup or code change, require durable evidence:

This is where GitHub's agent security validation helps, but it should be a backstop, not the first line of defense.

Decision tree

Is the repo from a trusted codebase you already maintain?
  -> Normal agent workflow, with existing project rules.

Is it unknown but does not need install or network?
  -> Read-only agent review first.

Does it need install, setup, Docker, MCP, browser login, or cloud tokens?
  -> Sandbox or VM first.

Does setup ask for broad credentials, persistent agents, shell pipes, or unknown MCP servers?
  -> Stop and replace with a scoped test environment.

Common mistakes

FAQ

Is this only a Claude Code problem?

No. The 0DIN proof of concept used Claude Code as the demonstration target, but the pattern applies to any tool that lets an LLM read untrusted context and then run commands with developer permissions.

Are permission prompts enough?

They help, but they are not enough by themselves. Prompt fatigue is real, and a dangerous chain can be split across several ordinary-looking steps. Review the effect of the command, not just whether each step looks familiar.

Should I block all network access?

Block network access for first inspection. Re-enable it only when the repo's setup path is understood and the environment has no valuable secrets. If setup genuinely needs network access, use a disposable token and record which endpoint is expected.

What should I internal-link from this page?

If the risk is dependency intake, use the npm package vetting checklist. If the risk is project rules, use the AGENTS.md guide. If the risk appears during browser debugging, use the Chrome DevTools MCP workflow.

Sources