Credentials¶
A sandbox often needs to authenticate somewhere: an agent to its provider, a script to an API, an agent to an MCP server. Docker Sandboxes can keep most secrets out of the sandbox: its proxy writes them into the requests that need them. Some still end up inside. This page lists each kind, what the sandbox can see, and what it can still do with it.
The kinds of credentials¶
| Kind | Set with | What the sandbox holds | Scope and lifetime |
|---|---|---|---|
| Proxied key | KeySpec and Keys in a spec, the keys of an agent task, ProxiedKey with the client |
A placeholder, in the variable the program reads | One sandbox; removed with it; kept across a stop and a start |
| Custom secret | CustomSecret pushed with the client |
Nothing: the program must send the placeholder you chose | One sandbox; removed with it |
| Service credential of a kit | Pushed for one sandbox with the client, or held by the daemon | A placeholder, when the daemon authorizes the kit credential; otherwise the service is withheld | One sandbox, or every sandbox for one the daemon holds |
| Subscription held by the daemon | sbx sign-in, such as /login in Claude Code |
Placeholder tokens | Every sandbox of that kit the daemon serves |
| Variable | env= of a task, a spec or client.create |
The value, in clear | One sandbox |
| Kiro key | KIRO_API_KEY in the environment of the host |
The value, in clear: sbx knows no service for it |
One sandbox |
| Token of an MCP server of the host | Drawn by the launch, one per run | The value, in clear, in DOCKER_SANDBOX_MCP_<NAME>_TOKEN |
One sandbox, one server |
Proxied keys¶
shape: sequence_diagram
H: Host process
D: sandboxd and its proxy
S: Sandbox
A: api.anthropic.com
H -> D: "create, with a placeholder\nin ANTHROPIC_API_KEY"
H -> D: "push the key for the hosts\nof its service"
S -> D: "request to api.anthropic.com,\na placeholder in a header"
D -> A: "the same request, the key\nin place of the placeholder"
A -> S: the answer {style.stroke-dash: 3}
The value of a key travels from your process to the daemon through the
socket and stays there: it is never read back, it is never written in the
sandbox, and the proxy writes it only into the headers of requests to the
hosts the key names, whatever the network rules allow. In Python, the value
of a ProxiedKey stays in the native extension.
The agents of @app.agent read their keys from the environment of the host
process, as their profile names them, and give them to the proxy of the
sandbox of the run. The agents page
lists the variables of each agent.
A key the sandbox cannot read can still be used
Any process in the sandbox can send a request with the placeholder to the hosts of the key, and the proxy writes the key in. A compromised agent can therefore make calls billed to your key, or act with its rights, as long as the sandbox lives. A service on those hosts that echoes request headers would hand the value back. Give a sandbox only the keys it needs, with the narrowest rights its work allows.
Credentials in clear¶
Some values reach the sandbox as they are, readable by every process in it:
- the variables of
env=: a secret belongs in a key, never in a variable; KIRO_API_KEY, for thekiroagent, set at creation and passed to each of its prompts;- the token of an MCP server of the host, which gives access to that server alone, for that run;
- whatever a kit passes through: some kits give the sandbox the real token of a sign-in, see the Docker documentation.
Credentials the daemon holds¶
- Subscriptions. A Claude subscription signed in under
sbxis held by the daemon, which refreshes its tokens; aclaudesandbox created through the socket uses it when noANTHROPIC_API_KEYis given. Which one applies when both exist is not documented here, since it was not measured. - Secrets stored with
sbx secret setlive on the host, in the keychain of the system. Thesbxcommand line pushes them to a sandbox before it runs a command in it. Whether the daemon also injects a stored API key into a sandbox created through the socket was not measured: give fastsandbox the key in the environment instead. - Withheld credentials. The daemon injects the credential of a kit
service only when it authorizes the kit for it; otherwise it names the
service in
withheld, and a run logs a warning. See Withheld credentials.
fastsandbox never reads the secrets stored with sbx secret set. Whoever can
reach the socket of the daemon can create sandboxes that use the credentials
it holds, without seeing their values: see the
security model.
Next¶
- Credentials: proxied keys, custom secrets and service credentials with the client.
- Sandbox specs: the keys of a spec.
- Agents: the keys of an agent task.