Install, configure, and manage the AI-Warden prompt injection protection plugin for OpenClaw. Publisher: AI-Warden (ai-warden.io). Source: github.com/ai-ward...
Prompt injection protection for OpenClaw agents. 5 security shields + contamination lockdown.
Each step is a separate command. Run them one at a time and verify output before proceeding.
bash
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak && echo "BACKUP OK"
Verify: Output is BACKUP OK.
bash
mkdir -p ~/.openclaw/extensions/ai-warden
bash
echo '{"private":true}' > ~/.openclaw/extensions/ai-warden/package.json
Verify: No errors.
bash
cd ~/.openclaw/extensions/ai-warden && npm install openclaw-ai-warden@2.4.0
Verify: No errors and no audit warnings. Inspect the installed package before proceeding:
bash
ls node_modules/openclaw-ai-warden/
bash
cat node_modules/openclaw-ai-warden/package.json | grep -E '"name"|"version"'
Confirm the package name is openclaw-ai-warden and version is 2.4.0.
Provenance check — verify the package matches the upstream source:
bash
npm info openclaw-ai-warden repository.url
Expected: https://github.com/ai-warden/openclaw-plugin
bash
npm info openclaw-ai-warden dist.shasum
Compare the shasum with what npm installed:
bash
cat node_modules/openclaw-ai-warden/package.json | grep _shasum
OpenClaw loads plugins from the extension directory root, not from node_modules.
bash
cd ~/.openclaw/extensions/ai-warden
bash
cp node_modules/openclaw-ai-warden/index.ts .
bash
cp node_modules/openclaw-ai-warden/openclaw.plugin.json .
bash
cp -r node_modules/openclaw-ai-warden/src .
bash
grep VERSION index.ts | head -1
Verify: Output shows const VERSION = followed by the version number.
This patches openclaw.json to register the plugin. It preserves all existing config (channels, model, gateway settings).
bash
node -e "
const fs = require('fs');
const p = process.env.HOME + '/.openclaw/openclaw.json';
const cfg = JSON.parse(fs.readFileSync(p, 'utf8'));
if (!cfg.plugins) cfg.plugins = {};
cfg.plugins.enabled = true;
if (!cfg.plugins.entries) cfg.plugins.entries = {};
cfg.plugins.entries['ai-warden'] = {
enabled: true,
config: {
layers: { content: 'block', channel: 'warn', preLlm: 'off', toolArgs: 'block', subagents: 'block', output: 'off' },
sensitivity: 'balanced'
}
};
fs.writeFileSync(p, JSON.stringify(cfg, null, 2));
console.log('CONFIG OK');
"
Verify: Output is CONFIG OK.
Note: This registers the plugin via plugins.entries only. If you use plugins.allow in your config to restrict which plugins can load, you must add "ai-warden" to that list yourself. If you don't use plugins.allow, no action is needed — the plugin loads automatically from plugins.entries.
For online detection (98.9% accuracy vs ~60% offline), add your API key.
Option A — Environment variable (recommended, key not stored in config file):
Set AI_WARDEN_API_KEY in your shell profile or systemd service:
bash
# For systemd (e.g., OpenClaw gateway service):
# Add to your service override: Environment=AI_WARDEN_API_KEY=your_key_here
# For shell:
export AI_WARDEN_API_KEY=your_key_here
Option B — Config file (simpler, key stored in openclaw.json):
bash
node -e "
const fs = require('fs');
const p = process.env.HOME + '/.openclaw/openclaw.json';
const cfg = JSON.parse(fs.readFileSync(p, 'utf8'));
cfg.plugins.entries['ai-warden'].config.apiKey = 'YOUR_API_KEY_HERE';
fs.writeFileSync(p, JSON.stringify(cfg, null, 2));
// Restrict file permissions (config contains API key)
fs.chmodSync(p, 0o600);
console.log('API KEY ADDED (file permissions set to 600)');
"
Replace YOUR_API_KEY_HERE with your actual key from ai-warden.io/signup.
Verify: Output is API KEY ADDED (file permissions set to 600).
text
openclaw gateway restart
After restart, check logs or send /warden command. Expected output:
text
🛡️ AI-Warden v2.4.0 ready (mode: api|offline, layers: X/6)
mode: api = online detection (98.9% accuracy)mode: offline = local-only detection (~60% accuracy)If something breaks, restore config:
bash
cp ~/.openclaw/openclaw.json.bak ~/.openclaw/openclaw.json && openclaw gateway restart
edit tool on openclaw.json — JSON whitespace matching is fragileconfig.patch with nested objects — it often fails with format errorscp step — OpenClaw loads from the extension directory, not node_modulesplugins.allow, remember to add "ai-warden" to the list — otherwise the plugin won't loadbash
cd ~/.openclaw/extensions/ai-warden
bash
npm install openclaw-ai-warden@2.4.0
bash
cp node_modules/openclaw-ai-warden/index.ts .
bash
cp -r node_modules/openclaw-ai-warden/src .
bash
openclaw gateway restart
ShieldProtects againstDefaultMechanismFile Shield 🔴Poisoned files & web pagesblockScans tool results, injects warning, triggers contamination lockdown on CRITICALChat Shield 🔴Injections in user messageswarnScans inbound messages, warns LLMSystem Shield ⬛Full context manipulationoffScans all messages (expensive, use sparingly)Tool Shield 🔴Malicious tool argumentsblockBlocks tool execution if arguments contain injectionAgent Shield 🔴Sub-agent attack chainsblockScans task text of spawned sub-agents
When File Shield detects a CRITICAL threat (score >500), the session is flagged as contaminated. All dangerous tools ( exec, write, edit, message, sessions_send, sessions_spawn, tts) are blocked for the rest of the session. This prevents attack payloads from executing even if the injection bypasses the LLM warning.
text
/warden → status overview with all shields
/warden stats → scan/block counts
/warden shield file block → set File Shield to block mode
/warden shield chat warn → set Chat Shield to warn mode
/warden reset → reset statistics
ModeAccuracyLatencyCostOffline (no key)~60%<1msFreeAPI (Smart Cascade)98.9%~3ms avgFree tier: 5K calls/month
Get API key: ai-warden.io/signup
openclaw.plugin.json missing from extension dir. Re-run Step 3.plugins.allow, ensure all your channel plugins (e.g. telegram) are also listed there alongside ai-warden.warn (default) instead of block.cp ~/.openclaw/openclaw.json.bak ~/.openclaw/openclaw.jsonjournalctl -u openclaw-gateway -n 20 for actual error..openclaw/workspace/ and .openclaw/agents/ paths.