Sandboxes and the Blast Radius
Permissions decide whether a command asks first. The sandbox decides what a command can reach once it runs. The blast radius is everything the worst command the agent could run would reach: files, credentials, networks, data, money.
You set the blast radius before the first session, and you set it by naming that worst command and making sure the environment cannot carry it far. Relying on the agent not to run it is not a control. Relying on yourself to notice in time is a weak one, as the previous page showed. Taking the reach away holds no matter what the agent decides or what you approve.
Blast Radius, Defined
The blast radius of an environment is the set of things one command could damage or expose from where the agent runs. On a developer laptop it is large. It includes the home directory and every other project in it, every stored credential (the cloud account login, the SSH keys, the token for the package registry), the company network, and any database a configuration file points at.
In a container that has the repository mounted and nothing else, the blast radius is the repository, and the repository has an undo. The agent, the model and the task are identical in both cases. What differs is the answer to "what could go wrong?", and only the environment changed it.
The Worst-Command Exercise
For each place you run the agent, write down the worst commands it could plausibly run there and what each would reach. Do it before the first session, and do it with specific commands, not categories. For a Cragmoor laptop the list starts like this.
| Worst command | How it could happen | Remove the reach |
|---|---|---|
| A force-push to the main branch | Resolving a conflict "cleanly", or an allow rule broad enough to match | No push credentials in the agent's environment; branch protection on the server |
| A migration run against staging | A configuration file in the repository points at staging, and the agent runs the migration tool to fix a failing test | No staging address or credentials anywhere the agent can read |
| The environment file sent to an outside address | A fetched page or a dependency's README tells the agent to (Chapter 12) | No real secrets in the environment; outbound network limited to the registry |
The right-hand column is the point of the exercise. Each fix removes the command's reach instead of relying on the agent not to run it. A deny rule on force-pushes is worth having too, but the stronger control is an environment from which a push cannot authenticate, because then it does not matter how the command was spelled or who approved it.
Containers
The simplest sandbox is a container with the repository mounted and nothing else. The agent runs inside it, so the home directory, the keys and the other projects are not hidden from it; they are simply absent. How containers work is the subject of Docker Deep Dive. The policy here is about what goes in: the code, the toolchain for your language, a local test database that the test command starts, and nothing that authenticates to anything real.
A container is only as good as what you put in it. The most common mistake is mounting the home directory, or the cloud configuration folder, "so the tools work". That gives the container a laptop's blast radius in a smaller box. If a task needs something from outside, give it that one thing, scoped to the task, rather than the directory it lives in.
Make the container part of the repository. A container definition committed alongside the code, describing the toolchain, the test database and nothing else, means every engineer and every agent works in the same environment, and a change to that environment goes through review like any other change. Many editors can open a project directly inside such a definition. Cloud agents build their environments from a similar file, which is one more reason to keep it short and deliberate.
No Production Credentials
The agent's environment holds no credential that reaches production or shared data. Tests use the local database the test command starts, not a shared one. Without a credential, the command fails however it is spelled and whoever approves it, which no rule and no instruction can promise.
Staging is not an exception. At Cragmoor the staging database holds a copy of real member data, refreshed every week, so a staging credential exposes real people's names and bookings. A credential's risk is what it reaches, not what the environment it points at is called. Chapter 12 applies the same rule, least privilege, to the tokens a team gives agents that work on its behalf.
Limited Network
Outbound network access should allow the package registry and the documentation the task needs, and nothing else by default. A network the agent cannot reach is a place it cannot send your code to and cannot fetch instructions from. Both matter: Chapter 12 shows how text the agent fetches can carry instructions, and an open network is how an instruction to send a file somewhere gets carried out.
At Cragmoor the allow-list is short: the package registry for each language the team uses, the documentation site of the main framework, and the shared repository for fetching. Everything else is refused. When a task genuinely needs a new destination, someone adds it on purpose, in a reviewed change, rather than the agent finding out whether it can reach it.
As of 2026 some agents offer a sandbox of their own, with a filesystem boundary and a network allow-list that starts empty. Use it if yours has one, and read what it covers. One widely used design, for example, restricts where commands can write but still lets them read most of the machine by default, including credential files, unless you deny those paths explicitly.
What a Sandbox Does Not Do
A sandbox contains damage. It does not make a change right. A sandboxed agent still writes a wrong diff, and you can still merge it, and then the bug runs in production with production's reach. The refund change, made in the tidiest container imaginable, can still refund the wrong amount to every member.
The sandbox, the permissions, reading and tests are four controls for four different failures. The sandbox bounds what a bad command can damage. Permissions spend your attention where it is needed. Reading the diff, Chapter 6, catches the change that is wrong. Tests, Chapter 8, catch the behaviour that broke. None of them substitutes for another.
Permissions decide which tool calls run without asking. They match the text of a command, and an equivalent command written differently can get round them. Use them to spend your attention well.
The sandbox decides what any command can reach once it runs. It works at the level of the environment and holds whatever the command says. Use it to set the worst case.
- "The agent would never run a destructive command." It runs what its context leads it to. A stale instruction, a misread error or injected text in a fetched page can all lead there, and intent is not a control.
- "My laptop is fine because I approve every command." Approval fatigue and equivalent commands put the laptop's full reach one tired yes away.
- "A container makes the agent safe." A container with your cloud credentials mounted or the network wide open has a laptop's blast radius in a smaller box.
- "Sandboxing is only needed for auto-approve." The sandbox sets the worst case in every mode. With an allow-list, it is what makes "run the tests" safe to allow.
- "Staging is not production, so staging credentials are fine." At Cragmoor staging holds a copy of real member data. A credential's risk is what it reaches, not what the environment is called.
- Write down the worst command for each place you run the agent and what it would reach. Then remove the reach, not just the command.
- Give the agent's environment no credential that reaches production or shared data. What it cannot authenticate, it cannot harm.
- Run unattended or auto-approved sessions only in a container or cloud environment that holds the repository and nothing else.
- Allow outbound network only to the registry and documentation the task needs. Every other destination is a path for data out and instructions in.
Knowledge Check
An agent runs on a laptop where the cloud login is active and a config file in the repository points at staging. What is the blast radius?
- The repository, since the agent was started in its root directory
- The repository, the cloud account, staging data and anything else the account reaches
- Whatever you approve, since every command still asks first in this mode
- The repository and the cloud account, but not staging, which is not production
Which control stops a migration from being run against staging, however the command is spelled?
- A deny rule matching the migration tool's usual command line
- A line in the instructions file saying never to touch staging
- No staging address or credentials in the agent's environment
- A careful reading of the diff after the agent finishes its task
A team runs its agent in a container but mounts the home directory so the developer tools keep working. Why does this fail as a sandbox?
- The mount brings back the credentials and projects the box was meant to remove
- Containers cannot isolate anything, whatever is or is not mounted into them
- Mounting the home directory makes the container far too slow to be useful
- The agent refuses to run inside a container that has a home directory mounted
The agent, fully sandboxed, produces a diff that refunds the wrong amount. Which control catches that?
- The sandbox, since it contains everything the agent does
- The permissions, since the edit should have required approval
- The network allow-list, since it limits what the agent can do
- Reading the diff and tests that assert the refund amount
Why are Cragmoor's staging credentials not safe to give an agent?
- Staging is often down, so the agent's tests would fail at random
- Staging holds a copy of real member data, so the credential reaches it
- Staging credentials also work in production, by company policy
- Staging queries are billed per request, so the agent could run up costs
You got correct