SentiClaw — Runtime AI Security for OpenClaw
SentiClaw is a 6-layer security middleware that protects your OpenClaw agent
from prompt injection, identity spoofing, data exfiltration, and runtime abuse.
Install
CODEBLOCK0
Quick Start
Add to your OpenClaw workspace (HEARTBEAT.md or any tool):
CODEBLOCK1
The 6 Layers
| # | Layer | Protects Against |
|---|
| 0 | Identity | Spoofing, unauthorized access, name-claim attacks |
| 1 |
Sanitizer | Prompt injection, jailbreaks, zero-width char attacks |
| 2 |
Outbound Gate | API key leaks, internal IP exposure, system prompt leakage |
| 3 |
Redactor | PII in responses (email, phone, SSN, credit cards) |
| 4 |
Governance | Rate limiting, loop detection, spend caps |
| 5 |
Access Control | Unsafe file paths, private URL access, tool abuse |
Audit Log
All events are logged to SQLite (senticlaw_audit.db):
- -
ALLOWED — clean message passed through - INLINECODE3 — message blocked by policy
- INLINECODE4 — prompt injection detected
- INLINECODE5 — identity spoofing detected
- INLINECODE6 — sensitive data in response blocked
- INLINECODE7 — sender exceeded volume limits
- INLINECODE8 — repeated identical messages
Alert Integration
Wire up instant alerts to any channel OpenClaw supports:
CODEBLOCK2
Any injection or spoofing attempt fires an immediate alert to your channel.
Configuration
CODEBLOCK3
Running Tests
CODEBLOCK4
Built by
PHRAIMWORK LLC · MIT License
SentiClaw — OpenClaw 运行时 AI 安全防护
SentiClaw 是一个 6 层安全中间件,保护您的 OpenClaw 代理免受提示注入、身份欺骗、数据泄露和运行时滥用。
安装
bash
npx clawhub@latest install senticlaw
pip install ./skills/senticlaw
快速入门
添加到您的 OpenClaw 工作区(HEARTBEAT.md 或任何工具):
python
from senticlaw import SentiClaw
sc = SentiClaw(config={
ownerids: {discord: [YOURDISCORDUSERID]},
trustedsenders: {discord: [YOURDISCORDUSERID]},
})
检查入站消息
result = sc.check
inbound(text, senderid=sender
id, channel=discord, sessionid=session_id)
if not result.allowed:
return result.block_message
在此运行您的代理逻辑...
response = agent.respond(result.text)
检查出站响应
safe = sc.check
outbound(response, sessionid=session_id)
return safe.response
6 层防护
| # | 层 | 防护对象 |
|---|
| 0 | 身份 | 欺骗、未授权访问、名称声明攻击 |
| 1 |
净化器 | 提示注入、越狱、零宽字符攻击 |
| 2 |
出站网关 | API 密钥泄露、内部 IP 暴露、系统提示泄露 |
| 3 |
编辑器 | 响应中的个人身份信息(电子邮件、电话、社会安全号码、信用卡) |
| 4 |
治理 | 速率限制、循环检测、消费上限 |
| 5 |
访问控制 | 不安全文件路径、私有 URL 访问、工具滥用 |
审计日志
所有事件均记录到 SQLite(senticlaw_audit.db):
- - ALLOWED — 干净消息通过
- BLOCKED — 消息被策略阻止
- INJECTIONATTEMPT — 检测到提示注入
- SPOOFINGATTEMPT — 检测到身份欺骗
- OUTBOUNDBLOCKED — 响应中的敏感数据被阻止
- RATELIMITED — 发送者超出数量限制
- LOOP_DETECTED — 重复的相同消息
告警集成
将即时告警连接到 OpenClaw 支持的任何频道:
python
sc = SentiClaw(config={
ownerids: {discord: [YOURID]},
alert_channel: discord, # discord | telegram | slack | whatsapp
alertchannelid: YOURCHANNELORCHATID,
})
任何注入或欺骗尝试都会立即向您的频道发送告警。
配置
python
from senticlaw import SentiClaw, SentiClawConfig
config = SentiClawConfig(
ownerids={discord: [YOURID]},
trustedsenders={discord: [YOURID]},
blockunknownsenders=False,
redact_pii=True,
redact_secrets=True,
redaction_mode=mask, # mask | remove | tokenize
spendcapdaily_usd=10.0,
maxmessagesper_hour=100,
loop_threshold=3,
outboundblockapi_keys=True,
outboundblockfile_paths=True,
alertchannelid=, # 用于告警的 Discord 频道 ID
auditdbpath=senticlaw_audit.db,
)
运行测试
bash
cd skills/senticlaw
python tests/run_tests.py
由
PHRAIMWORK LLC 构建 · MIT 许可证