Sandboxing OpenClaw skills in Docker
A skill is instructions plus, often, a few scripts. When the agent follows those instructions, the work happens through tool calls: exec, read, write, edit. Sandboxing OpenClaw skills in Docker moves those tool calls into a container, so a bad instruction meets a small, disposable filesystem instead of your home directory. This guide walks through the settings that matter, based on the official OpenClaw sandboxing docs, shows a config you can start from, and is plain about what a sandbox does not fix. Ironheights appears as one layer, a pre-install scan and a config check, not as the sandbox itself. Its limits are on the limitations page.
What a sandbox changes for a skill
The OpenClaw docs describe the model in one line: the Gateway process always stays on the host, and only tool execution moves into the sandbox when it is enabled. The docs also say directly that this is "not a perfect security boundary", but that it materially limits filesystem and process access.
According to What gets sandboxed, tool execution such as exec, ls, read, write, edit, apply_patch and process runs inside the sandbox, along with the optional sandboxed browser. The Gateway process and any tool allowed out through tools.elevated do not.
That maps neatly onto the shapes of skill attacks we have written about:
| Skill technique | Without a sandbox | With a Docker sandbox on defaults |
|---|---|---|
Reads ~/.ssh or a browser profile | Host files are readable with your user's rights | The container sees its own workspace, not your home directory |
| Downloads and runs a second stage | Runs on the host | Default network: "none" blocks the download |
| Writes a persistence entry | Lands in your real startup paths | Lands in a container that can be recreated |
| Sends collected data out | Any host network path | No egress unless you turn networking on |
| Asks you to paste a command in your own terminal | Runs on the host | Also runs on the host. The sandbox never sees it |
The last row is the important one. A sandbox governs what the agent's tools do. A fake prerequisite that convinces a person to run something in their own shell, the pattern in anatomy of a prerequisite attack, is outside it.
The three settings: mode, scope, backend
Modes, scope, and backend lists three independent keys under agents.defaults.sandbox:
| Setting | Values | Default | What to choose for untrusted skills |
|---|---|---|---|
mode | off, non-main, all | off | all if any session can run a third-party skill; non-main at minimum |
scope | agent, session, shared | agent | session for the cleanest separation between conversations |
backend | docker, podman, ssh, openshell, crabbox | docker | docker or podman for a local box |
Two details from the docs are easy to miss:
non-mainsandboxes every session except the agent's main session,agent:<agentId>:main. If you mostly talk to your agent in its main session,non-mainleaves exactly that session on the host. Group and channel sessions always count as non-main.- With
scope: "session",/newand/resetreset the conversation, not the container or its sandbox workspace. To start clean, runopenclaw sandbox recreatewith the session key fromopenclaw sandbox list.
shared puts every sandboxed session in one container and ignores per-agent Docker overrides. That is convenient and the opposite of what you want when one session may run a skill you have not reviewed.
Workspace access decides what a skill can see
workspaceAccess controls how much of the agent workspace the container gets. From Workspace access:
| Value | What the sandbox sees | Trade-off |
|---|---|---|
none (default) | An isolated workspace under ~/.openclaw/sandboxes; the agent workspace is not exposed | Safest; tools cannot edit your real project |
ro | The agent workspace read-only at /agent; write, edit and apply_patch are disabled | Skills can read, not change, your files |
rw | The agent workspace read and write at /workspace | Needed for coding work, and exposes everything in it |
Skills themselves are handled separately. With none, OpenClaw mirrors eligible skills into the sandbox workspace as read-only instruction roots. With rw, workspace skills are readable from /workspace/skills and managed, bundled or plugin skills are materialized into a read-only path. A skill running in the sandbox can read its own instructions but cannot rewrite the mirrored copy, which closes one route for a skill to change itself between turns. It does not stop edits to the original files on the host, so keep checking those with ironheights verify, covered in Pinning and verifying OpenClaw skill versions.
If you use rw, assume a skill can read every file in that workspace. Keep .env files, exported tokens and SSH keys out of it. Where your agent leaks credentials lists the usual places they end up.
Binds: the part people widen by accident
Extra host folders go in through docker.binds in host:container:mode form. The bind docs are blunt: binds bypass the sandbox filesystem and expose host paths with whatever mode you set.
OpenClaw blocks the worst sources by default. The docs list system paths such as /etc, /proc and /root, Docker socket directories, and common credential roots including ~/.aws, ~/.config, ~/.docker, ~/.gnupg, ~/.npm and ~/.ssh. Sources outside the workspace roots are blocked unless you turn on a documented opt-in whose name starts with dangerously, and the docs say that opt-in does not lift the credential or socket blocks.
Bind checklist:
- [ ] Every bind is the smallest folder the task needs, not a parent like your home directory.
- [ ] Binds are
:rounless the skill must write there. - [ ] No
dangerously*flag is set without a written reason. - [ ] After any change,
openclaw sandbox recreate --agent <name>so the old mounts are gone. - [ ]
openclaw sandbox explain --agent <name>shows the mounts you expect.
The same caution applies to MCP servers outside the sandbox. Ironheights IH-MCP-003 flags an MCP server given a broad filesystem root, which is the MCP version of an oversized bind.
Network, image and setup
The Docker backend defaults are network: "none", readOnlyRoot: true, capDrop: ["ALL"] and the image openclaw-sandbox:trixie-slim. The docs add that containers start with an init process and no-new-privileges. Those defaults are good. Most of the work is not undoing them.
Networking is the setting most likely to be turned on for convenience. A skill that fetches web pages or installs packages will fail with no network, and the quick fix is docker.network set to a bridge. Do that per agent, not in defaults, so only the agent that needs egress gets it. Once egress is on, data the sandbox can read can also leave. Ironheights IH-NET-002 flags possible exfiltration patterns in skill files before install. It cannot see traffic at runtime.
The images and setup page notes that system package installs are image provisioning, not normal sandbox-turn behavior, and that with no network, a read-only root and a non-root user, an in-turn system package install should fail. Build a custom image with the tools your skills need instead of granting network so a skill can install them on the fly. That also means a skill's install step, the one that runs curl into a shell in this teardown, fails loudly instead of quietly working.
Secrets need one more note. The OpenClaw skills docs say skills.entries.<name>.env and apiKey are injected into the host process for that agent turn, not into the sandbox. A skill that needs an API key inside the container needs it passed some other way, and whatever you pass is readable by everything in that container.
A starting config
This combines the documented defaults with session scope and read-only workspace access. Adjust workspaceAccess per agent if one agent genuinely needs to write.
{
agents: {
defaults: {
sandbox: {
mode: "all",
backend: "docker",
scope: "session",
workspaceAccess: "ro",
docker: {
readOnlyRoot: true,
network: "none",
capDrop: ["ALL"],
},
},
},
},
}
Then check what is actually in effect, rather than what you meant to write:
openclaw sandbox explainto see the effective mode, workspace, mounts and tool policy.openclaw security audit, which the security CLI docs describe as OpenClaw's own config and exposure check.npx ironheights audit-configto compare your config against Ironheights' published config rules.openclaw sandbox listafter a few sessions, to confirm containers are being created per session.
Where the sandbox stops
The sandbox is a blast-radius control. Be specific about what is outside it:
- Elevated tools.
tools.elevatedrunsexecoutside the sandbox by design. Ironheights IH-CFG-007 flags elevated tools enabled, and IH-CFG-009 flags sandbox mode off while host exec, elevated tools or an open room are on. - Tool policy comes first. The docs say allow and deny policy applies before sandbox rules. A sandbox does not bring back a denied tool, and it does not restrict a tool you allowed to run on the host.
- The main session under
non-main. It stays on the host. - Prompt injection. A sandboxed agent can still be told to do the wrong thing with the data it can see. IH-INJ-001 and IH-INJ-003 flag override and safeguard-weakening wording in skill text, and fixed rules miss rephrasings.
- Human-run steps. Anything a skill convinces you to run yourself.
- Remote backends. For SSH and OpenShell, the docs say shell execution relies on the remote host's policy, and
workspaceAccessalone does not make remote paths read-only.
How a scan fits next to the sandbox
A sandbox limits damage after a skill runs. A pre-install scan decides whether it runs at all. They answer different questions, and neither covers the other.
| Question | Sandbox | Pre-install scan |
|---|---|---|
| Can this skill read my SSH keys? | Not on defaults | Flags the path in the text with IH-CRED-001 |
| Does it pipe remote content into a shell? | Fails with no network | Flags it with IH-EXEC-001 |
| Will it behave differently at runtime than its text suggests? | Contains some of it | Cannot tell |
| Is my config actually sandboxed? | sandbox explain shows it | audit-config reads the file, not the live runtime |
Where the sandbox is better: it works on behavior no rule anticipated, including novel obfuscation and payloads fetched later. Where a scan is better: it stops a skill before any session sees it, and it reports why. Run npx ironheights scan ./path/to/skill or paste a skill into the browser scanner, then run what passes inside the sandbox. Our benchmark measured the content rules on a test corpus; it did not test sandbox behavior. Public incidents we follow are on the tracker, and research like Snyk's ToxicSkills study shows why reviewing what you install still matters.
If you want the scan and config check in one local tool, Ironheights is on npm and ClawHub.
FAQ
Is OpenClaw sandboxing on by default?
No. The OpenClaw docs list agents.defaults.sandbox.mode with a default of off. Set it to all or non-main to move tool execution into a container. Sessions whose operator role requires a sandbox run sandboxed even when the agent mode is off.
Can a sandboxed skill still read my SSH keys?
Not on default settings. With workspaceAccess: "none" the container sees an isolated workspace, and OpenClaw blocks binds from credential roots such as ~/.ssh and ~/.aws by default. Copying keys into the workspace, or running the skill through elevated tools, undoes that.
Should I give the sandbox network access?
Only to the agent that needs it, set per agent rather than in defaults. The Docker backend defaults to no network, which blocks second-stage downloads and outbound data. With egress on, anything the container can read can be sent out.
Does a sandbox replace scanning skills before install?
No. A sandbox limits what tool calls can touch after a skill runs, and it does not cover commands a person runs in their own terminal. A scan flags risky text before install but cannot see runtime behavior. Use both.
Sources
- Sandboxing, OpenClaw documentation.
- Modes, scope, and backend, OpenClaw documentation.
- What gets sandboxed, OpenClaw documentation.
- Workspace access, OpenClaw documentation.
- Multiple folders for one agent: bind security, OpenClaw documentation.
- Docker backend, OpenClaw documentation.
- Images and setup, OpenClaw documentation.
- Skills, OpenClaw documentation.
- Security CLI, OpenClaw documentation.
- ToxicSkills: malicious AI agent skills on ClawHub, Snyk.
- Ironheights README, GitHub.
- ironheights on npm, npm.