OpenClaw Guardian
The missing safety layer for AI agents.
Why?
OpenClaw gives agents direct access to shell, files, email, browser, and more.
99% of that is harmless. Guardian catches the 1% that isn't — without slowing
down the rest.
How It Works
Tool Call → Blacklist Matcher (regex rules, 0ms)
↓
No match → Pass instantly (99% of calls)
Warning hit → 1 LLM vote ("did the user ask for this?")
Critical hit → 3 LLM votes (all must confirm user intent)
Two Blacklist Levels
| Level |
LLM Votes |
Latency |
Examples |
| No match |
0 |
~0ms |
Reading files, git, normal ops |
| Warning |
1 |
~1-2s |
rm -rf /tmp/cache, chmod 777, sudo apt |
| Critical |
3 (unanimous) |
~2-4s |
rm -rf ~/, mkfs, dd of=/dev/, shutdown |
What Gets Checked
Only three tool types are inspected:
exec → command string matched against exec blacklist
write / edit → file path canonicalized and matched against path blacklist
- Everything else passes through instantly
LLM Intent Verification
When a blacklist rule matches, Guardian asks a lightweight LLM: "Did the user
explicitly request this?" It reads recent conversation context to prevent
false positives.
- Warning: 1 LLM call. Confirmed → proceed.
- Critical: 3 parallel LLM calls. All 3 must confirm. Any "no" → block.
Auto-discovers a cheap/fast model from your existing OpenClaw provider config
(prefers Haiku). No separate API key needed.
LLM Fallback
- Critical + LLM down → blocked (fail-safe)
- Warning + LLM down → asks user for manual confirmation
Blacklist Rules
Critical (exec)
rm -rf on system paths (excludes /tmp/ and workspace)
mkfs, dd to block devices, redirects to /dev/sd*
- Writes to
/etc/passwd, /etc/shadow, /etc/sudoers
shutdown, reboot, disable SSH
- Bypass:
eval, absolute-path rm, interpreter-based (python -c, node -e)
- Pipe attacks:
curl | sh, wget | bash, base64 -d | sh
- Chain attacks: download +
chmod +x + execute
Warning (exec)
rm -rf on safe paths, sudo, chmod 777, chown root
- Package install/remove, service management
- Crontab mods, SSH/SCP, Docker ops,
kill/killall
Path Rules (write/edit)
- Critical: system auth files, SSH keys, systemd units
- Warning: dotfiles,
/etc/ configs, .env files, authorized_keys
Audit Log
Every blacklist hit logged to ~/.openclaw/guardian-audit.jsonl with SHA-256
hash chain — tamper-evident, each entry covers full content + previous hash.
Installation
openclaw plugins install openclaw-guardian
Or manually:
cd ~/.openclaw/workspace
git clone https://github.com/fatcatMaoFei/openclaw-guardian.git
Token Cost
| Scenario |
% of Ops |
Extra Cost |
| No match |
~99% |
0 |
| Warning |
~0.5-1% |
~500 tokens |
| Critical |
<0.5% |
~1500 tokens |
Prefers cheap models (Haiku, GPT-4o-mini, Gemini Flash).
File Structure
extensions/guardian/
├── index.ts # Entry — registers before_tool_call hook
├── src/
│ ├── blacklist.ts # Two-tier regex rules (critical/warning)
│ ├── llm-voter.ts # LLM intent verification
│ └── audit-log.ts # SHA-256 hash-chain audit logger
├── test/
│ └── blacklist.test.ts # Blacklist rule tests
├── openclaw.plugin.json # Plugin manifest
└── default-policies.json # Enable/disable toggle
License
MIT
1---
2name: openclaw-guardian
3description: >
4 A security layer plugin for OpenClaw that intercepts dangerous tool calls
5 (exec, write, edit) through two-tier regex blacklist rules and LLM-based
6 intent verification. Critical operations require 3/3 unanimous LLM votes,
7 warning-level operations require 1 LLM confirmation. 99% of normal
8 operations pass instantly with zero overhead. Includes bypass/pipe-attack
9 detection, path canonicalization, SHA-256 hash-chain audit logging, and
10 auto-discovers a cheap model from your existing provider config.
11metadata:
12 source: https://skillmd.com/skills/modbender/openclaw-guardian
13---
14
15# OpenClaw Guardian
16
17> The missing safety layer for AI agents.
18
19## Why?
20
21OpenClaw gives agents direct access to shell, files, email, browser, and more.
2299% of that is harmless. Guardian catches the 1% that isn't — without slowing
23down the rest.
24
25## How It Works
26
27```
28Tool Call → Blacklist Matcher (regex rules, 0ms)
29 ↓
30 No match → Pass instantly (99% of calls)
31 Warning hit → 1 LLM vote ("did the user ask for this?")
32 Critical hit → 3 LLM votes (all must confirm user intent)
33```
34
35### Two Blacklist Levels
36
37| Level | LLM Votes | Latency | Examples |
38|-------|-----------|---------|---------|
39| No match | 0 | ~0ms | Reading files, git, normal ops |
40| Warning | 1 | ~1-2s | `rm -rf /tmp/cache`, `chmod 777`, `sudo apt` |
41| Critical | 3 (unanimous) | ~2-4s | `rm -rf ~/`, `mkfs`, `dd of=/dev/`, `shutdown` |
42
43### What Gets Checked
44
45Only three tool types are inspected:
46
47- `exec` → command string matched against exec blacklist
48- `write` / `edit` → file path canonicalized and matched against path blacklist
49- Everything else passes through instantly
50
51### LLM Intent Verification
52
53When a blacklist rule matches, Guardian asks a lightweight LLM: "Did the user
54explicitly request this?" It reads recent conversation context to prevent
55false positives.
56
57- Warning: 1 LLM call. Confirmed → proceed.
58- Critical: 3 parallel LLM calls. All 3 must confirm. Any "no" → block.
59
60Auto-discovers a cheap/fast model from your existing OpenClaw provider config
61(prefers Haiku). No separate API key needed.
62
63### LLM Fallback
64
65- Critical + LLM down → blocked (fail-safe)
66- Warning + LLM down → asks user for manual confirmation
67
68## Blacklist Rules
69
70### Critical (exec)
71- `rm -rf` on system paths (excludes `/tmp/` and workspace)
72- `mkfs`, `dd` to block devices, redirects to `/dev/sd*`
73- Writes to `/etc/passwd`, `/etc/shadow`, `/etc/sudoers`
74- `shutdown`, `reboot`, disable SSH
75- Bypass: `eval`, absolute-path rm, interpreter-based (`python -c`, `node -e`)
76- Pipe attacks: `curl | sh`, `wget | bash`, `base64 -d | sh`
77- Chain attacks: download + `chmod +x` + execute
78
79### Warning (exec)
80- `rm -rf` on safe paths, `sudo`, `chmod 777`, `chown root`
81- Package install/remove, service management
82- Crontab mods, SSH/SCP, Docker ops, `kill`/`killall`
83
84### Path Rules (write/edit)
85- Critical: system auth files, SSH keys, systemd units
86- Warning: dotfiles, `/etc/` configs, `.env` files, `authorized_keys`
87
88## Audit Log
89
90Every blacklist hit logged to `~/.openclaw/guardian-audit.jsonl` with SHA-256
91hash chain — tamper-evident, each entry covers full content + previous hash.
92
93## Installation
94
95```bash
96openclaw plugins install openclaw-guardian
97```
98
99Or manually:
100
101```bash
102cd ~/.openclaw/workspace
103git clone https://github.com/fatcatMaoFei/openclaw-guardian.git
104```
105
106## Token Cost
107
108| Scenario | % of Ops | Extra Cost |
109|----------|----------|------------|
110| No match | ~99% | 0 |
111| Warning | ~0.5-1% | ~500 tokens |
112| Critical | <0.5% | ~1500 tokens |
113
114Prefers cheap models (Haiku, GPT-4o-mini, Gemini Flash).
115
116## File Structure
117
118```
119extensions/guardian/
120├── index.ts # Entry — registers before_tool_call hook
121├── src/
122│ ├── blacklist.ts # Two-tier regex rules (critical/warning)
123│ ├── llm-voter.ts # LLM intent verification
124│ └── audit-log.ts # SHA-256 hash-chain audit logger
125├── test/
126│ └── blacklist.test.ts # Blacklist rule tests
127├── openclaw.plugin.json # Plugin manifest
128└── default-policies.json # Enable/disable toggle
129```
130
131## License
132
133MIT