2026-01-08 21:49:26 +01:00
|
|
|
|
---
|
|
|
|
|
|
summary: "How Clawdbot sandboxing works: modes, scopes, workspace access, and images"
|
|
|
|
|
|
title: Sandboxing
|
2026-01-09 12:44:23 +00:00
|
|
|
|
read_when: "You want a dedicated explanation of sandboxing or need to tune agents.defaults.sandbox."
|
2026-01-08 21:49:26 +01:00
|
|
|
|
status: active
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
# Sandboxing
|
|
|
|
|
|
|
|
|
|
|
|
Clawdbot can run **tools inside Docker containers** to reduce blast radius.
|
2026-01-09 12:44:23 +00:00
|
|
|
|
This is **optional** and controlled by configuration (`agents.defaults.sandbox` or
|
|
|
|
|
|
`agents.list[].sandbox`). If sandboxing is off, tools run on the host.
|
2026-01-08 21:51:21 +01:00
|
|
|
|
The Gateway stays on the host; tool execution runs in an isolated sandbox
|
|
|
|
|
|
when enabled.
|
2026-01-08 21:49:26 +01:00
|
|
|
|
|
|
|
|
|
|
This is not a perfect security boundary, but it materially limits filesystem
|
|
|
|
|
|
and process access when the model does something dumb.
|
|
|
|
|
|
|
|
|
|
|
|
## What gets sandboxed
|
|
|
|
|
|
- Tool execution (`bash`, `read`, `write`, `edit`, `process`, etc.).
|
2026-01-09 12:44:23 +00:00
|
|
|
|
- Optional sandboxed browser (`agents.defaults.sandbox.browser`).
|
2026-01-10 02:06:05 +00:00
|
|
|
|
- By default, the sandbox browser auto-starts (ensures CDP is reachable) when the browser tool needs it.
|
|
|
|
|
|
Configure via `agents.defaults.sandbox.browser.autoStart` and `agents.defaults.sandbox.browser.autoStartTimeoutMs`.
|
2026-01-11 01:24:02 +01:00
|
|
|
|
- `agents.defaults.sandbox.browser.allowHostControl` lets sandboxed sessions target the host browser explicitly.
|
2026-01-11 01:52:23 +01:00
|
|
|
|
- Optional allowlists gate `target: "custom"`: `allowedControlUrls`, `allowedControlHosts`, `allowedControlPorts`.
|
2026-01-08 21:49:26 +01:00
|
|
|
|
|
|
|
|
|
|
Not sandboxed:
|
|
|
|
|
|
- The Gateway process itself.
|
2026-01-09 12:44:23 +00:00
|
|
|
|
- Any tool explicitly allowed to run on the host (e.g. `tools.elevated`).
|
2026-01-08 22:57:08 +01:00
|
|
|
|
- **Elevated bash runs on the host and bypasses sandboxing.**
|
2026-01-09 12:44:23 +00:00
|
|
|
|
- If sandboxing is off, `tools.elevated` does not change execution (already on host). See [Elevated Mode](/tools/elevated).
|
2026-01-08 21:49:26 +01:00
|
|
|
|
|
|
|
|
|
|
## Modes
|
2026-01-09 12:44:23 +00:00
|
|
|
|
`agents.defaults.sandbox.mode` controls **when** sandboxing is used:
|
2026-01-08 21:49:26 +01:00
|
|
|
|
- `"off"`: no sandboxing.
|
|
|
|
|
|
- `"non-main"`: sandbox only **non-main** sessions (default if you want normal chats on host).
|
|
|
|
|
|
- `"all"`: every session runs in a sandbox.
|
2026-01-09 03:23:36 +01:00
|
|
|
|
Note: `"non-main"` is based on `session.mainKey` (default `"main"`), not agent id.
|
|
|
|
|
|
Group/channel sessions use their own keys, so they count as non-main and will be sandboxed.
|
2026-01-08 21:49:26 +01:00
|
|
|
|
|
|
|
|
|
|
## Scope
|
2026-01-09 12:44:23 +00:00
|
|
|
|
`agents.defaults.sandbox.scope` controls **how many containers** are created:
|
2026-01-08 21:49:26 +01:00
|
|
|
|
- `"session"` (default): one container per session.
|
|
|
|
|
|
- `"agent"`: one container per agent.
|
|
|
|
|
|
- `"shared"`: one container shared by all sandboxed sessions.
|
|
|
|
|
|
|
|
|
|
|
|
## Workspace access
|
2026-01-09 12:44:23 +00:00
|
|
|
|
`agents.defaults.sandbox.workspaceAccess` controls **what the sandbox can see**:
|
2026-01-08 21:49:26 +01:00
|
|
|
|
- `"none"` (default): tools see a sandbox workspace under `~/.clawdbot/sandboxes`.
|
|
|
|
|
|
- `"ro"`: mounts the agent workspace read-only at `/agent` (disables `write`/`edit`).
|
|
|
|
|
|
- `"rw"`: mounts the agent workspace read/write at `/workspace`.
|
|
|
|
|
|
|
|
|
|
|
|
Inbound media is copied into the active sandbox workspace (`media/inbound/*`).
|
2026-01-09 00:30:51 +01:00
|
|
|
|
Skills note: the `read` tool is sandbox-rooted. With `workspaceAccess: "none"`,
|
|
|
|
|
|
Clawdbot mirrors eligible skills into the sandbox workspace (`.../skills`) so
|
|
|
|
|
|
they can be read. With `"rw"`, workspace skills are readable from
|
|
|
|
|
|
`/workspace/skills`.
|
2026-01-08 21:49:26 +01:00
|
|
|
|
|
|
|
|
|
|
## Images + setup
|
|
|
|
|
|
Default image: `clawdbot-sandbox:bookworm-slim`
|
|
|
|
|
|
|
|
|
|
|
|
Build it once:
|
|
|
|
|
|
```bash
|
|
|
|
|
|
scripts/sandbox-setup.sh
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Sandboxed browser image:
|
|
|
|
|
|
```bash
|
|
|
|
|
|
scripts/sandbox-browser-setup.sh
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
By default, sandbox containers run with **no network**.
|
2026-01-09 12:44:23 +00:00
|
|
|
|
Override with `agents.defaults.sandbox.docker.network`.
|
2026-01-08 21:49:26 +01:00
|
|
|
|
|
|
|
|
|
|
Docker installs and the containerized gateway live here:
|
|
|
|
|
|
[Docker](/install/docker)
|
|
|
|
|
|
|
|
|
|
|
|
## Tool policy + escape hatches
|
|
|
|
|
|
Tool allow/deny policies still apply before sandbox rules. If a tool is denied
|
|
|
|
|
|
globally or per-agent, sandboxing doesn’t bring it back.
|
|
|
|
|
|
|
2026-01-09 12:44:23 +00:00
|
|
|
|
`tools.elevated` is an explicit escape hatch that runs `bash` on the host.
|
2026-01-10 20:28:34 +01:00
|
|
|
|
|
|
|
|
|
|
Debugging:
|
|
|
|
|
|
- Use `clawdbot sandbox explain` to inspect effective sandbox mode, tool policy, and fix-it config keys.
|
|
|
|
|
|
- See [Sandbox vs Tool Policy vs Elevated](/gateway/sandbox-vs-tool-policy-vs-elevated) for the “why is this blocked?” mental model.
|
2026-01-08 21:49:26 +01:00
|
|
|
|
Keep it locked down.
|
|
|
|
|
|
|
|
|
|
|
|
## Multi-agent overrides
|
|
|
|
|
|
Each agent can override sandbox + tools:
|
2026-01-09 12:44:23 +00:00
|
|
|
|
`agents.list[].sandbox` and `agents.list[].tools` (plus `agents.list[].tools.sandbox.tools` for sandbox tool policy).
|
2026-01-08 21:49:26 +01:00
|
|
|
|
See [Multi-Agent Sandbox & Tools](/multi-agent-sandbox-tools) for precedence.
|
|
|
|
|
|
|
|
|
|
|
|
## Minimal enable example
|
|
|
|
|
|
```json5
|
|
|
|
|
|
{
|
2026-01-09 12:44:23 +00:00
|
|
|
|
agents: {
|
|
|
|
|
|
defaults: {
|
|
|
|
|
|
sandbox: {
|
|
|
|
|
|
mode: "non-main",
|
|
|
|
|
|
scope: "session",
|
|
|
|
|
|
workspaceAccess: "none"
|
|
|
|
|
|
}
|
2026-01-08 21:49:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Related docs
|
2026-01-09 12:44:23 +00:00
|
|
|
|
- [Sandbox Configuration](/gateway/configuration#agentsdefaults-sandbox)
|
2026-01-08 21:49:26 +01:00
|
|
|
|
- [Multi-Agent Sandbox & Tools](/multi-agent-sandbox-tools)
|
|
|
|
|
|
- [Security](/gateway/security)
|