Least-privilege workspace for agent skills
A least-privilege workspace for agent skills means each skill runs in an agent that can see only the files, tools and secrets that skill needs. In most OpenClaw setups the opposite is true: one agent, one workspace, every installed skill visible, the full tool set allowed, and API keys sitting in the same folder as the agent's memory. This guide walks through the controls OpenClaw already ships, in the order we would apply them, and is honest about where each one stops.
It is a companion to Sandboxing OpenClaw skills in Docker, which covers container mode, binds and network. Here the focus is everything around the container: which agent a skill belongs to, which skills that agent can see, which tools it may call, and what lives in its folder.
Why the default workspace is not a boundary
The OpenClaw agent workspace docs put it plainly: the workspace is the agent's default working directory, "not a hard sandbox." Relative paths resolve inside it, but absolute paths can still reach elsewhere on the host unless sandboxing is on. The same folder holds AGENTS.md, SOUL.md, USER.md, daily memory files and the skills/ directory, and workspace skills have the highest load precedence.
So a skill in a default single-agent setup can usually:
- read the agent's memory and persona files, which are loaded into every session;
- write to those same files, which shapes every later session;
- call any tool the agent can call, including
exec; - read whatever the agent's process can read on the host.
Snyk's ToxicSkills study reported 76 confirmed malicious payloads in 3,984 skills it scanned, and Koi's ClawHavoc report described 341 malicious skills. Most installed skills are not malicious. Least privilege is about making the bad one you miss less costly.
The five controls and what each one limits
OpenClaw separates these controls on purpose. Mixing them up is the most common reason a setup looks locked down and is not.
| Control | Config | What it limits | What it does not limit |
|---|---|---|---|
| Separate agent and workspace | agents.entries.<id>.workspace | Which memory, persona and workspace skills a session sees | Host files reachable by absolute path |
| Skill allowlist | agents.entries.<id>.skills | Which skills appear in that agent's prompt and commands | What a shell can do; the docs say it "is not a host shell authorization boundary" |
| Tool policy | tools.allow / tools.deny, per agent | Which tools the model can call at all | Anything an allowed exec shell does |
| Sandbox | agents.entries.<id>.sandbox | Which files and network tool calls can reach | Elevated tools, the main session under non-main, human-run steps |
| Secret scope | skills.entries.<name>.env / apiKey | Which turns get which keys | Secrets you leave in files the agent can read |
The multi-agent sandbox and tools page adds the rule that makes this work: each layer can only restrict further, and deny always wins. A later layer cannot grant back a tool an earlier layer denied.
Step 1: Put untrusted skills in their own agent
Start by splitting your agents by trust, not by convenience. A personal agent with your real workspace and memory is one agent. A "try new skills" agent with an empty workspace is another.
Give each agent an explicit workspace path. The workspace docs note that in a multi-agent roster, entries without workspace get a derived default, and that naming a shared root does not assign it to an agent. Being explicit removes the guesswork. Never reuse agentDir across agents: the same docs page says auth is stored per agent, and secondary agents can read through to the main agent's auth profiles when they have none of their own. If the trial agent should not use your model credentials, give it its own profile.
Then route only the conversations you intend to that agent with bindings, and check with openclaw agents list --bindings.
Step 2: Allowlist skills per agent
Skill location and skill visibility are separate. The skills docs describe the allowlist rules:
- Omit
agents.defaults.skillsand every agent sees every eligible skill. - A non-empty
agents.entries.<id>.skillslist is the final set. It does not merge with defaults. skills: []exposes no skills to that agent.
That last point is useful for an agent that only handles chat. A practical pattern is a short shared baseline in agents.defaults.skills, a replacement list for agents that need more, and an empty list for agents that should not run skills at all.
To switch off a skill everywhere instead, skills.entries.<name>.enabled: false disables it even when it is bundled or installed.
Step 3: Deny tools the skill does not need
Tool policy decides what the model can call. The docs give read-only and communication-only examples; the idea is simple:
- A summarizer or search skill needs
readand maybemessage. Denyexec,process,write,edit,apply_patchandbrowser. - A coding skill needs
writeandexec. Give it a separate agent with a sandbox, not your main agent. - MCP tools use the same policy surface as
server__toolnames, so you can allowdocs__read_docsand denydocs__delete_*.
One caveat from the docs deserves repeating: denying file tools while allowing exec does not make an agent read-only, because a shell can write wherever its filesystem allows. For a read-only agent, deny exec and process, or pair shell access with sandbox workspaceAccess: "ro" or "none".
Ironheights IH-CFG-007 flags dangerous tool permissions in the OpenClaw config, such as exec security set to full, exec approvals off, or elevated tools enabled, and IH-CFG-009 flags sandbox mode off while tools can act. Both are read from the config file by npx ironheights audit-config, which is offline and read-only.
Step 4: Keep secrets and private memory out of reach
A workspace with no secrets in it is a workspace a leaky skill cannot leak secrets from. The workspace docs suggest a .gitignore for .env, .key, .pem and secrets*, and say to keep anything under ~/.openclaw/ out of the workspace repo. Go one step further and keep those files out of the workspace folder entirely.
Three more habits:
- Scope skill secrets.
skills.entries.<name>.envandapiKeyare injected into the host process for that agent's turn, not into the sandbox. Prefer a SecretRef over a plaintext value; Ironheights IH-CFG-005 flags plaintext secrets in the OpenClaw config. - Keep long-term memory private. The docs say
MEMORY.mdshould only load in the main, private session, not shared or group contexts. A trial agent does not need your memory. - Watch child processes. A skill script that runs a subprocess with your full environment hands every exported token to it. IH-EXEC-005 flags that pattern in skill files, and IH-CRED-001 flags reads of sensitive paths like
~/.sshor cloud credential folders.
Where your agent leaks credentials lists the places keys tend to end up.
Step 5: Write down what each skill may reach
Least privilege only holds if someone notices when it widens. Ironheights can turn the intended scope into a file you review in pull requests:
npx ironheights threatmodel init
npx ironheights threatmodel check --fail-on-uncovered
init writes ironheights.threatmodel.yml from the skills and MCP servers in a repo. check fails when a skill or MCP server reaches outside it: hosts, paths, environment variables, tokens or shell. In CI, threatmodel diff --base main reports only what a change adds. Pair it with a normal scan of each new skill, npx ironheights scan ./path/to/skill, or paste the files into the browser scanner.
A starting config
This combines the documented patterns: a personal agent, plus a trial agent with no shared memory, a short skill list and no shell.
{
agents: {
ownership: "explicit",
defaults: {
systemAgent: { agentId: "main" },
skills: ["github"],
},
entries: {
main: { workspace: "~/.openclaw/workspace" },
trial: {
workspace: "~/.openclaw/workspace-trial",
skills: ["new-skill-under-review"],
sandbox: { mode: "all", scope: "session", workspaceAccess: "none" },
tools: {
allow: ["read", "message"],
deny: ["exec", "process", "write", "edit", "apply_patch", "browser", "gateway"],
},
},
},
},
}
Then confirm what is actually in effect: openclaw agents list --bindings, openclaw sandbox explain --agent trial, openclaw security audit, and npx ironheights audit-config.
Checklist
- [ ] Untrusted or new skills run in a separate agent with its own explicit workspace.
- [ ] No two agents share an
agentDir. - [ ]
agents.defaults.skillsis set, and each agent's list is as short as it can be. - [ ] Agents that do not need a shell deny
execandprocess. - [ ] No
.env, key or token files live inside any workspace. - [ ]
MEMORY.mdloads only in the private main session. - [ ] Skill secrets use SecretRefs, not plaintext.
- [ ] Extra skill directories are deliberate; IH-CFG-008 flags them.
- [ ] A threat model file exists and
threatmodel checkruns in CI.
Where this stops, and what Ironheights cannot catch
Least privilege limits the damage of a skill you trusted by mistake. It does not tell you a skill is safe, and it has gaps:
- The main agent. Most people keep one fully privileged agent. Skills that reach it reach everything.
- Allowed tools. If a skill legitimately needs
execand network, it can misuse both. Tool policy cannot judge intent. - Prompt injection. A restricted agent can still be talked into doing the wrong thing with the data and tools it has.
- Human-run steps. A skill that convinces you to paste a command into your own terminal bypasses all of this.
Ironheights reads files and config. It cannot see runtime-only behavior, novel obfuscation its rules do not match, or instructions a skill fetches later. audit-config reads the config file, not the live Gateway. The full list is on our limitations page, and public incidents we track are on the tracker. Our benchmark measures the content rules on test corpora; it does not test these OpenClaw settings. Where OpenClaw's own controls are better: a sandbox and a deny list work on behavior no rule anticipated. Where a scan is better: it can stop a skill before any agent sees it, and it says why.
If you want the scan, config audit and threat model check in one local CLI, Ironheights is on npm.
FAQ
Is the OpenClaw workspace a security boundary?
No. The docs describe it as the default working directory, not a hard sandbox. Absolute paths can reach the rest of the host unless sandboxing is enabled, so treat it as a place for memory and instructions, not as isolation.
Does a skill allowlist stop a skill from running shell commands?
No. The allowlist controls which skills an agent sees. If that agent can call exec, restrict the shell separately with tool policy, a sandbox, OS-user isolation or per-resource credentials.
How many agents do I need for least privilege?
Usually two to start: a private main agent and a restricted agent for new or untrusted skills. Add more when a skill needs a capability, such as a shell or network, that the others should not have.
Can Ironheights enforce these limits at runtime?
Its scans and audit-config are static checks of files and config. They report problems; they do not enforce policy inside OpenClaw. Use OpenClaw's tool policy and sandbox for enforcement, and Ironheights to review skills and catch config drift.
Sources
- Agent workspace, OpenClaw documentation.
- Skills, OpenClaw documentation.
- Multi-agent sandbox and tools, OpenClaw documentation.
- Sandboxing, OpenClaw documentation.
- Security CLI, OpenClaw documentation.
- ToxicSkills: malicious AI agent skills on ClawHub, Snyk.
- ClawHavoc: 341 Malicious Clawed Skills Found by the Bot They Were Targeting, Koi Security.
- Ironheights README, GitHub.
- ironheights on npm, npm.