Secure OpenClaw Agents: Sandbox and Tool Policy Guide
Ever felt like your agent is trapped in a box, or worse, running wild on your host machine when it shouldn’t? Managing permissions and execution environments can be a headache when you are trying to balance security with functionality.
Understanding how OpenClaw handles Sandbox environments, Tool Policy configurations, and Elevated permissions is crucial for building secure and capable agents. These three layers work together to ensure your tools run exactly where and how you want them to.
OpenClaw has three related (but different) controls:
- Sandbox (
agents.defaults.sandbox.*/agents.list[].sandbox.*) decides where tools run (sandbox backend vs host). - Tool policy (
tools.*,tools.sandbox.tools.*,agents.list[].tools.*) decides which tools are available/allowed. - Elevated (
tools.elevated.*,agents.list[].tools.elevated.*) is an exec-only escape hatch to run outside the sandbox when you’re sandboxed (Gateway by default, or Node.js when the exec target is configured to Node.js).
Debug OpenClaw Sandbox settings with the CLI
Section titled “Debug OpenClaw Sandbox settings with the CLI”When your configuration gets complex, you need a fast way to verify what settings are actually in effect. The OpenClaw CLI provides a powerful inspection tool to clear up any confusion about your current environment.
openclaw sandbox explainopenclaw sandbox explain --session agent:main:mainopenclaw sandbox explain --agent workopenclaw sandbox explain --jsonIt prints:
- effective sandbox mode/scope/workspace access
- whether the session is currently sandboxed (main vs non-main)
- effective sandbox tool allow/deny (and whether it came from agent/global/default)
- elevated gates and fix-it key paths
Configure where tools run with OpenClaw Sandbox
Section titled “Configure where tools run with OpenClaw Sandbox”The Sandbox environment is the foundation of your agent’s security, isolating execution to prevent unauthorized host access. Sandboxing is controlled by agents.defaults.sandbox.mode and determines which sessions are restricted.
"off": everything runs on the host."non-main": only non-main sessions are sandboxed (common “surprise” for groups/channels)."all": everything is sandboxed.
See Sandboxing for the full matrix (scope, workspace mounts, images).
Bind mounts (security quick check)
Section titled “Bind mounts (security quick check)”docker.bindspierces the sandbox filesystem: whatever you mount is visible inside the container with the mode you set (:roor:rw).- Default is read-write if you omit the mode; prefer
:rofor source/secrets. scope: "shared"ignores per-agent binds (only global binds apply).- OpenClaw validates bind sources twice: first on the normalized source path, then again after resolving through the deepest existing ancestor. Symlink-parent escapes do not bypass blocked-path or allowed-root checks.
- Non-existent leaf paths are still checked safely. If
/workspace/alias-out/new-fileresolves through a symlinked parent to a blocked path or outside the configured allowed roots, the bind is rejected. - Binding
/var/run/docker.sockeffectively hands host control to the sandbox; only do this intentionally. - Workspace access (
workspaceAccess: "ro"/"rw") is independent of bind modes.
Manage tool access using OpenClaw Tool Policy
Section titled “Manage tool access using OpenClaw Tool Policy”Defining which tools an agent can use is just as important as where those tools are executed. The Tool Policy system in OpenClaw allows you to create strict allowlists or denylists to manage your API surface area.
Two layers matter:
- Tool profile:
tools.profileandagents.list[].tools.profile(base allowlist) - Provider tool profile:
tools.byProvider[provider].profileandagents.list[].tools.byProvider[provider].profile - Global/per-agent tool policy:
tools.allow/tools.denyandagents.list[].tools.allow/agents.list[].tools.deny - Provider tool policy:
tools.byProvider[provider].allow/denyandagents.list[].tools.byProvider[provider].allow/deny - Sandbox tool policy (only applies when sandboxed):
tools.sandbox.tools.allow/tools.sandbox.tools.denyandagents.list[].tools.sandbox.tools.*
Rules of thumb:
denyalways wins.- If
allowis non-empty, everything else is treated as blocked. - Tool policy is the hard stop:
/execcannot override a deniedexectool. /execonly changes session defaults for authorized senders; it does not grant tool access.- Provider tool keys accept either
provider(e.g.google-antigravity) orprovider/model(e.g.openai/gpt-5.4).
Tool groups (shorthands)
Section titled “Tool groups (shorthands)”Tool policies (global, agent, sandbox) support group:* entries that expand to multiple tools:
{ tools: { sandbox: { tools: { allow: ["group:runtime", "group:fs", "group:sessions", "group:memory"], }, }, },}Available groups:
group:runtime:exec,process,code_execution(bashis accepted as an alias forexec)group:fs:read,write,edit,apply_patchgroup:sessions:sessions_list,sessions_history,sessions_send,sessions_spawn,sessions_yield,subagents,session_statusgroup:memory:memory_search,memory_getgroup:web:web_search,x_search,web_fetchgroup:ui:browser,canvasgroup:automation:cron, Gatewaygroup:messaging:messagegroup:nodes:nodesgroup:agents:agents_listgroup:media:image,image_generate,video_generate,ttsgroup:openclaw: all built-in OpenClaw tools (excludes provider plugins)
Run host commands using OpenClaw Elevated mode
Section titled “Run host commands using OpenClaw Elevated mode”Sometimes a sandboxed tool needs to perform an action that requires host-level access without compromising your entire security setup. Elevated mode provides a controlled way to run specific commands outside the container.
Elevated does not grant extra tools; it only affects exec.
- If you’re sandboxed,
/elevated on(orexecwithelevated: true) runs outside the sandbox (approvals may still apply). - Use
/elevated fullto skip exec approvals for the session. - If you’re already running direct, Elevated is effectively a no-op (still gated).
- Elevated is not skill-scoped and does not override tool allow/deny.
- Elevated does not grant arbitrary cross-host overrides from
host=auto; it follows the normal exec target rules and only preserves Node.js when the configured/session target is already Node.js. /execis separate from Elevated. It only adjusts per-session exec defaults for authorized senders.
Gates:
- Enablement:
tools.elevated.enabled(and optionallyagents.list[].tools.elevated.enabled) - Sender allowlists:
tools.elevated.allowFrom.<provider>(and optionallyagents.list[].tools.elevated.allowFrom.<provider>)
See Elevated Mode.
Fix common OpenClaw sandbox jail issues
Section titled “Fix common OpenClaw sandbox jail issues”Running into permission errors or unexpected blocks can be frustrating when you are testing new tools. These common solutions will help you break out of a sandbox jail and get your agent back on track.
”Tool X blocked by sandbox tool policy”
Section titled “”Tool X blocked by sandbox tool policy””Fix-it keys (pick one):
- Disable sandbox:
agents.defaults.sandbox.mode=off(or per-agentagents.list[].sandbox.mode=off) - Allow the tool inside sandbox:
- remove it from
tools.sandbox.tools.deny(or per-agentagents.list[].tools.sandbox.tools.deny) - or add it to
tools.sandbox.tools.allow(or per-agent allow)
“I thought this was main, why is it sandboxed?”
Section titled ““I thought this was main, why is it sandboxed?””In "non-main" mode, group/channel keys are not main. Use the main session key (shown by sandbox explain) or switch mode to "off".
Explore related OpenClaw documentation
Section titled “Explore related OpenClaw documentation”If you need more details on specific configurations or advanced setups, these resources will help you expand your knowledge. You can find deep dives into the technical matrix and per-agent overrides here.
- Sandboxing — full sandbox reference (modes, scopes, backends, images)
- Multi-Agent Sandbox & Tools — per-agent overrides and precedence
- Elevated Mode
OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.