What a sandbox contains
Act a showed an agent with a broad token and nothing around it. This page explains what a sandbox has to contain so that something can decide on the security engineer’s behalf: the files the agent sees, its network, its secrets, its tools, and a record of every decision. After it you will know which part of Box does which job, so that the hands-on pages that follow read as one design rather than a list of settings.
Text description of the diagram
Stage 2 of 5.
Pieces in the picture:
- the macOS keychain, which holds the three secrets; the developer reads them into shell variables
- the developer's terminal
- Claude Code, the agent
- the contained filesystem view: only the paths the profile grants exist for the agent (new at this stage)
- the box CLI and Box Core, which build the box and run its trusted process (new at this stage)
- stand-in secrets: the agent gets placeholders, the real values stay in the trusted process (new at this stage)
- the egress gateway, which every network request from the box goes through (new at this stage)
- the Anthropic API
- Cloudflare's MCP server
- the Cloudflare API
- the sample app: the Worker box-poc-workshop with its D1 database, KV namespace and Workers Logs; the logs and the database hold attendee names and email addresses
- Boundaries: the box, agent's sandbox, trusted process.
New in the picture: the box around Claude Code. Inside it, Claude Code runs in the agent’s sandbox and sees a contained view of the filesystem. Beside it, outside every sandbox, runs Box’s trusted process: the box CLI and Box Core, the stand-in secrets, and the egress gateway that every network request goes through. The MCP broker, the policy engine and the records join the picture in MCP through the broker.
A box is a boundary around one workload
Section titled “A box is a boundary around one workload”In Box’s own words a box is the whole boundary around one workload: the processes it runs, here Claude Code. It has three kinds of part:
- The agent’s sandbox. The agent process runs here under operating-system enforcement. It may execute only its configured command, programs its profile names, and the small programs that connect it to Box.
- A sandbox per local tool or MCP server. Each starts only after the policy permits it, with its own file grants. You meet one in Part 5.
- The trusted process. Box’s own code, outside every sandbox. It holds the policy engine, the egress gateway, the MCP broker, the real secrets, and the certificate authority the gateway uses.
The agent can never reach the trusted process’s files. Box always refuses a request to the run’s own folder, its box.toml and its policy.dw, whatever the policy says.
Five things a box contains
Section titled “Five things a box contains”The filesystem view
Section titled “The filesystem view”On the agent’s own system calls the operating system enforces the grants of the run: only the paths the profile grants, plus a runtime minimum Box adds (system libraries, /dev/null and the like), exist for the agent. Everything else gives operation not permitted.
You will see this on the next page. The first time Claude Code runs in a box, Box prints a startup report like this one (measured on this build, abridged):
strands-box: [agent] runs ~/.local/share/claude/versions/2.1.330 with no policy decision over these paths: (no filesystem entry) exec ~/.local/share/claude/versions/2.1.330 (command, implicit)strands-box: [agent] runtime minimum, added by Core: read /usr/share/icu ... /System/Library ... /dev/null ... enter ~/leaderboard-ops (workspace, entry only)Two details matter for the story. First, such a refusal is the sandbox’s, not the policy’s: an operation not permitted from the sandbox leaves no row in the run’s history. Second, Box’s own shell and Python ask the policy for each file operation, but the agent’s own file tools, and tools such as git, open files through their grants only; the policy never sees those.
The network, through the egress gateway
Section titled “The network, through the egress gateway”The sandbox blocks direct network access. Box sets HTTPS_PROXY and HTTP_PROXY for the agent, so its traffic goes to the egress gateway in the trusted process. The gateway terminates each connection with the box’s own certificate authority, which Box hands the agent as SSL_CERT_FILE and NODE_EXTRA_CA_CERTS. Then it asks the policy for a decision: net:connect for each connection, http:request for each request, with host, method and path.
The gateway has no allow-list of its own. Every yes comes from the policy, and when no rule permits a request, it is refused (“default deny”). Until Part 3 the rules are the ones Box writes from your profile; Policy basics shows how a rule is built and how decisions combine.
Secrets, as stand-ins
Section titled “Secrets, as stand-ins”A profile binds a credential to destinations. The real value stays in the trusted process. The agent, and every tool and MCP server in the box, gets a stand-in in the same variable: a prefix plus 64 random hex characters (the prefix is strands_box_ unless the profile sets one, such as sk-ant- for the Anthropic key). On a permitted request to the bound destination, the gateway replaces the stand-in with the real value.
Measured on this build, with dummy real values, the agent’s environment held:
ANTHROPIC_API_KEY=sk-ant-<64 hex>CLOUDFLARE_API_TOKEN=strands_box_<64 hex>HTTPS_PROXY=http://127.0.0.1:<port>NODE_USE_ENV_PROXY=1SSL_CERT_FILE=<BOX_HOME>/r/b-<id>/box/trust/cert.pemPATH=<BOX_HOME>/r/b-<id>/box/bin:/usr/bin:/binOne limit, stated in Box’s docs: every process in a box can use every credential route, because the gateway cannot tell which process sent a request.
Tools, through the broker
Section titled “Tools, through the broker”Local tools and local MCP servers do not run in the agent’s sandbox. The agent runs a small stand-in program with the tool’s name (an “alias”, in box/bin on its PATH), which forwards the request to the MCP broker in the trusted process. The broker asks the policy to start the server (shell:spawn), starts it in its own sandbox, and decides each MCP request as mcp:call. A remote MCP server such as Cloudflare’s is reached through the gateway instead, which asks the same mcp:call question when the host matches a server the profile declares.
The record of every decision
Section titled “The record of every decision”Every effective decision, permit or deny, is written by the trusted process to a file the workload cannot reach: records.jsonl in the run’s folder, in OpenTelemetry’s JSON format. A separate history store holds the same decisions for box runs history. The records are diagnostic: Box’s docs say they are not tamper-evident.
The box CLI and Box Core
Section titled “The box CLI and Box Core”Box is two products in one repository. This workshop uses the first and never calls the second directly.
| The box CLI | Box Core | |
|---|---|---|
| Program | box |
strands-box |
| What it reads | A profile (profile.toml), plus packs and starters |
box.toml and policy.dw |
| Its job | Resolves the profile for the current folder, writes the run’s box.toml and policy.dw, starts Core, keeps run folders |
Builds the sandboxes, runs the trusted process, decides each request, records each decision |
The CLI links Core as a library, so box run is all you type. When you want to see what Core will be given, box profile show <profile> --full prints the generated box.toml and policy.dw, and each run folder keeps the same two files. The rule from Box’s own guide: change the profile’s source files, never the generated run files.
Core’s own documentation also calls its program box (a Core binary in a downloaded folder, run with --config box.toml). That is not the CLI, and not what the workshop uses. The CLI’s guide is in docs/cli/ of the repository; Core’s is in docs/user/.
How containment works on macOS
Section titled “How containment works on macOS”As Box’s design notes describe it: on macOS the operating-system sandbox is Seatbelt. For each process Box builds a Seatbelt profile from that process’s settings, then starts a small launcher, strands-box-contain-trampoline. The trampoline applies the profile with sandbox_init() and then becomes the target program, so every child process inherits the same sandbox. If applying the profile fails, Box refuses to start the program: it fails closed.
The trampoline ships beside box in the workshop’s build. One effect seen on this machine: a project under /tmp (/private/tmp) failed containment with grant is too broad to be authorized, which is why the workshop’s folders live in your home. Which file under /private/tmp triggers it was not found out.
The box gives you three places where a decision can happen and be recorded: the gateway for every network request, the broker for every local tool and MCP server, and Box’s own shell for commands. The secrets you care about never enter the agent’s sandbox; the agent holds stand-ins that work only through the gateway, only to the hosts they are bound to. What the box does not give you: decisions on the agent’s own file reads inside its grants (the grants are the control there), and any view of what a remote server does after a permitted call.
The agent still starts in your project folder and still reaches the model and the services it needs, but only those you name in the profile. Every missing piece shows up as an error: a folder Claude Code cannot open, a host the gateway refuses. The next pages are a sequence of exactly those errors, each fixed by one setting, so you learn what Claude Code actually needs.
What to remember
Section titled “What to remember”- A box is the agent’s sandbox, a sandbox per local tool or MCP server, and a trusted process outside them.
- The agent sees only the paths it is granted; its network goes through the egress gateway; it holds stand-ins, never the real secrets.
- Tools and MCP servers go through the broker or the gateway, which ask the policy and record each decision.
- The box CLI turns your profile into the
box.tomlandpolicy.dwthat Box Core enforces. - On macOS, Seatbelt enforces the sandbox through a trampoline, and Box fails closed when it cannot apply it.
Read moreHow Box works (CLI)Box docs
Read moreArchitecture: sandboxes and the trusted processBox docs
Read moreSecurity: what each tier governsBox docs
Read moreHow Box keeps credentials out of the boxBox docs
Read moreEgress and credentialsBox docs
Read moreHow Box enforces restrictions on macOSBox docs
Read moreTelemetry and recordsBox docs
Read moreLimitations: what a box does not protectBox docs