Multi-layer security detector for AI agents. Blocks prompt injection, jailbreak, XSS, SQL injection, API key leaks, supply chain attacks, and deployment vuln...
Enterprise-grade security detector for AI agents
clawSafe is a comprehensive security middleware that intercepts and blocks malicious input before it reaches your AI agent. Built with defense-in-depth philosophy.
| Layer | Threats | Rules |
|---|---|---|
| LLM Layer | Prompt Injection, Jailbreak, Prompt Leaking, Encoding Attacks | 44 |
| Web Layer | SQL Injection, XSS, CSRF, SSRF | 32 |
| API Layer | Key Exposure, Rate Limiting, Auth Bypass | 19 |
| Supply Chain | Dangerous Dependencies, Remote Code Execution | 8 |
| Deploy Layer | Environment Leaks, Debug Info Disclosure | 10 |
Total: 113+ detection rules
# Via ClawHub
clawhub install clawSafe
# Manual
cp -r clawSafe ~/.openclaw/workspace/skills/
const Detector = require('./detector');
const detector = new Detector();
// Scan user input
const result = detector.scan('Ignore previous instructions');
if (!result.safe) {
console.log('Blocked:', result.threats);
// Handle blocked input
}
{
safe: boolean; // true if input is safe
threats: Array<{
type: string; // threat category
pattern: string; // matched pattern ID
severity: string; // critical|high|medium|low
confidence: number; // 0-1
description: string;
}>;
confidence: number; // overall confidence 0-1
layersScanned: string[]; // layers that were checked
}
{
"enabled": true,
"logLevel": "info",
"layers": {
"llm": {
"enabled": true,
"rules": ["injection", "jailbreak", "prompt_leak", "encoding"]
},
"web": {
"enabled": true,
"rules": ["sql_injection", "xss", "csrf", "ssrf"]
},
"api": {
"enabled": true,
"rules": ["key_exposure", "rate_limit", "auth"]
},
"supply_chain": {
"enabled": true,
"rules": ["deps"]
},
"deploy": {
"enabled": true,
"rules": ["env_leak", "debug_info"]
}
},
"detection": {
"confidenceThreshold": 0.6,
"minMatchCount": 1
},
"actions": {
"onThreatDetected": "block",
"onUncertain": "log"
}
}
{
"keywords": ["trusted-keyword"],
"users": ["user-id-1"],
"sessions": ["session-id-1"]
}
Prompt Injection Patterns:
ignore previous instructionsdisregard your guidelinesforget all rulesact as if you have no restrictionsJailbreak Patterns:
DAN modedeveloper moderoleplay asEncoding Bypass:
'; DROP TABLE users; --<script>alert(1)</script>sk-1234567890# Run all tests
node test.js
# Interactive mode
node test-interactive.js
# Demo
node detector.js
To integrate with OpenClaw, add to your gateway config:
// gateway.config.js
module.exports = {
middleware: ['clawSafe'],
clawSafe: {
enabled: true,
strictMode: false
}
};
MIT
ZIP package — ready to use