Security middleware for OpenClaw skills. Provides permission manifests, runtime enforcement, and audit logging.
The problem: Skills are code from the internet. Like npm packages, they can do anything once installed. ClawGuard adds a permission layer so skills must declare what they need, and you can enforce those limits.
# Install
npm install -g clawguard
# Initialize permissions for a skill
clawguard init ./my-skill
# Validate a skill's permissions
clawguard validate ./my-skill
# Check status
clawguard status- Skills include a
permissions.jsondeclaring what they need - ClawGuard validates the manifest at install time
- At runtime, ClawGuard checks actions against declared permissions
- Violations are blocked (or warned/logged, depending on mode)
Create permissions.json in your skill directory:
{
"version": "1.0",
"skill": {
"name": "my-cool-skill",
"version": "1.0.0",
"description": "Does cool things"
},
"permissions": {
"filesystem": {
"read": ["./data/**", "${WORKSPACE}/config.json"],
"write": ["./output/**"],
"delete": []
},
"network": {
"outbound": ["api.example.com", "*.github.com"],
"inbound": false,
"ports": []
},
"exec": {
"allowed": true,
"commands": ["git", "npm run"],
"shell": false
},
"env": {
"read": ["HOME", "PATH", "API_KEY"],
"write": []
},
"openclaw": {
"sessions": false,
"cron": false,
"messages": true,
"browser": false,
"nodes": false
}
},
"rationale": {
"filesystem": "Reads config, writes results to output/",
"network": "Calls example.com API, fetches from GitHub",
"exec": "Uses git for version control"
}
}ClawGuard supports four modes, configurable globally or per-skill:
| Mode | Behavior |
|---|---|
enforce |
Block disallowed actions (default) |
warn |
Log warning, allow action |
audit |
Silent logging only |
disabled |
ClawGuard is completely off |
# Set global mode
clawguard mode warn
# Set mode for specific skill
clawguard skill-mode untrusted-skill enforce
# Trust a skill (bypasses all checks)
clawguard trust my-trusted-skill# Override mode
CLAWGUARD_MODE=warn
# Disable entirely
CLAWGUARD_DISABLED=true
# Emergency: block ALL skill actions
CLAWGUARD_KILL_SWITCH=trueIf something goes wrong, enable the kill switch to block ALL skill actions immediately:
clawguard kill-switch on # Block everything
clawguard kill-switch off # Resume normal operationEvery permission check is logged to ~/.config/clawguard/audit.log:
# View recent logs
clawguard audit --tail 100
# Verify log integrity (tamper detection)
clawguard audit --verifyLogs are append-only with hash chaining for tamper evidence.
import { Guard, getConfig } from 'clawguard';
// Create guard for a skill
const guard = new Guard('./path/to/skill');
// Check permissions (throws ClawGuardError if blocked)
guard.guardFileRead('/some/path');
guard.guardNetworkOutbound('https://api.example.com');
guard.guardExec('git status');
guard.guardOpenClaw('messages');
// Check without throwing
const result = guard.checkFileWrite('/some/path');
if (!result.allowed) {
console.log('Denied:', result.reason);
}
// Config management
const config = getConfig();
config.setMode('warn');
config.trustSkill('known-good-skill');
config.enableKillSwitch(); // Emergency stopread: Glob patterns for readable pathswrite: Glob patterns for writable pathsdelete: Glob patterns for deletable paths (high risk)
Variables: ${WORKSPACE}, ${HOME}
outbound: Allowed hosts (api.example.com,*.github.com,*)inbound: Whether the skill can listen on portsports: Specific ports allowed for inbound
allowed: Whether process spawning is permittedcommands: Allowed command prefixes (git,npm run)shell: Whether shell operators (|,&&,;) are allowed
read: Environment variables the skill can readwrite: Environment variables the skill can modify
sessions: Interact with other sessionscron: Create/modify cron jobsmessages: Send messages to channelsbrowser: Use browser automationnodes: Interact with paired nodes
ClawGuard is defense-in-depth, not a sandbox. A malicious skill could potentially bypass checks if it's sophisticated enough. Use ClawGuard as one layer of protection, not your only one.
Audit your skills. The permission manifest tells you what a skill claims to need. Review the actual code too.
Start with enforce mode. Only relax to warn or audit for debugging, then switch back.
Treat shell: true as dangerous. Shell execution allows arbitrary command chaining.
clawguard validate <skill-dir> Validate permissions.json
clawguard init <skill-dir> Create template permissions.json
clawguard audit [--tail N] View audit logs
clawguard audit --verify Verify log integrity
clawguard config Show configuration
clawguard config --reset Reset to defaults
clawguard trust <skill> Bypass checks for skill
clawguard untrust <skill> Remove from trusted
clawguard mode <mode> Set global mode
clawguard skill-mode <skill> <mode> Set skill-specific mode
clawguard kill-switch [on|off] Emergency stop
clawguard status Show current status
Issues and PRs welcome at https://github.com/newtro/ClawGuard
MIT