← 返回
安全合规 中文

ClawSafe

Multi-layer security detector for AI agents. Blocks prompt injection, jailbreak, XSS, SQL injection, API key leaks, supply chain attacks, and deployment vuln...
多层安全检测器,保护AI代理,阻止提示注入、越狱、XSS、SQL注入、API密钥泄露、供应链攻击及部署漏洞。
silvertime
安全合规 clawhub v1.1.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 616
下载
💾 11
安装
1
版本
#latest

概述

clawSafe 🛡️

> Enterprise-grade security detector for AI agents

Overview

clawSafe is a comprehensive security middleware that intercepts and blocks malicious input before it reaches your AI agent. Built with defense-in-depth philosophy.

Features

5-Layer Protection

LayerThreatsRules
-----------------------
LLM LayerPrompt Injection, Jailbreak, Prompt Leaking, Encoding Attacks44
Web LayerSQL Injection, XSS, CSRF, SSRF32
API LayerKey Exposure, Rate Limiting, Auth Bypass19
Supply ChainDangerous Dependencies, Remote Code Execution8
Deploy LayerEnvironment Leaks, Debug Info Disclosure10

Total: 113+ detection rules

Quick Start

Installation

# Via ClawHub
clawhub install clawSafe

# Manual
cp -r clawSafe ~/.openclaw/workspace/skills/

Basic Usage

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
}

Return Format

{
  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
}

Configuration

config.json

{
  "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"
  }
}

whitelist.json

{
  "keywords": ["trusted-keyword"],
  "users": ["user-id-1"],
  "sessions": ["session-id-1"]
}

Detection Rules

LLM Layer

Prompt Injection Patterns:

  • ignore previous instructions
  • disregard your guidelines
  • forget all rules
  • act as if you have no restrictions

Jailbreak Patterns:

  • DAN mode
  • developer mode
  • roleplay as

Encoding Bypass:

  • Base64 encoded commands
  • Hex encoding
  • Unicode homoglyphs

Web Layer

  • SQL Injection: '; DROP TABLE users; --
  • XSS:
  • CSRF: Token manipulation
  • SSRF: Internal URL access

API Layer

  • API Key exposure: sk-1234567890
  • JWT tokens
  • Bearer tokens
  • Basic auth credentials

Testing

# Run all tests
node test.js

# Interactive mode
node test-interactive.js

# Demo
node detector.js

Integration

OpenClaw Hook

To integrate with OpenClaw, add to your gateway config:

// gateway.config.js
module.exports = {
  middleware: ['clawSafe'],
  clawSafe: {
    enabled: true,
    strictMode: false
  }
};

Performance

  • Latency: < 5ms per scan
  • Memory: ~50KB
  • Rules: 113+ (JSON-based, lazy load)

License

MIT

Changelog

v1.0.0

  • Initial release
  • 5-layer protection
  • 113+ detection rules

版本历史

共 1 个版本

  • v1.1.0 当前
    2026-03-29 20:15 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,210 📥 266,142
security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,697
security-compliance

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 89 📥 30,584