介绍
# hopeIDS Security Skill
面向 AI 智能体的基于推理的入侵检测,具备隔离和人在回路功能。
## 安全不变量 (Security Invariants)
这些是**不可协商** 的设计原则:
1. **阻止 = 完全中止** — 被阻止的消息绝不会到达 jasper-recall 或智能体 2. **仅限元数据** — 永不存储原始恶意内容 3. **批准 ≠ 重新注入** — 批准会改变未来的行为,而不会复活消息 4. **告警是程序化的** — 根据元数据构建 Telegram 告警,不涉及 LLM
---
## 功能
- **自动扫描** — 在智能体处理之前扫描消息 - **隔离** — 通过仅存储元数据来阻止威胁 - **人在回路** — 用于审查的 Telegram 告警 - **按智能体配置** — 针对不同智能体设置不同的阈值 - **命令** — `/approve`, `/reject`, `/trust`, `/quarantine`
---
## 流程管道
``` Message arrives ↓ hopeIDS.autoScan() ↓ ┌─────────────────────────────────────────┐ │ risk >= threshold? │ │ │ │ BLOCK (strictMode): │ │ → Create QuarantineRecord │ │ → Send Telegram alert │ │ → ABORT (no recall, no agent) │ │ │ │ WARN (non-strict): │ │ → Inject <security-alert> │ │ → Continue to jasper-recall │ │ → Continue to agent │ │ │ │ ALLOW: │ │ → Continue normally │ └─────────────────────────────────────────┘ ```
---
## 配置
```json { "plugins": { "entries": { "hopeids": { "enabled": true, "config": { "autoScan": true, "defaultRiskThreshold": 0.7, "strictMode": false, "telegramAlerts": true, "agents": { "moltbook-scanner": { "strictMode": true, "riskThreshold": 0.7 }, "main": { "strictMode": false, "riskThreshold": 0.8 } } } } } } } ```
### 选项
| 选项 | 类型 | 默认值 | 描述 | |--------|------|---------|-------------| | `autoScan` | boolean | `false` | 自动扫描每一条消息 | | `strictMode` | boolean | `false` | 遇到威胁时阻止(而非警告) | | `defaultRiskThreshold` | number | `0.7` | 触发操作的风险级别 | | `telegramAlerts` | boolean | `true` | 为被阻止的消息发送告警 | | `telegramChatId` | string | - | 覆盖告警目标地址 | | `quarantineDir` | string | `~/.openclaw/quarantine/hopeids` | 存储路径 | | `agents` | object | - | 按智能体覆盖配置 | | `trustOwners` | boolean | `true` | 跳过扫描所有者消息 |
---
## 隔离记录
当消息被阻止时,会创建一条元数据记录:
```json { "id": "q-7f3a2b", "ts": "2026-02-06T00:48:00Z", "agent": "moltbook-scanner", "source": "moltbook", "senderId": "@sus_user", "intent": "instruction_override", "risk": 0.85, "patterns": [ "matched regex: ignore.*instructions", "matched keyword: api key" ], "contentHash": "ab12cd34...", "status": "pending" } ```
**注意:** 不存在 `originalMessage` 字段。这是有意为之的。
---
## Telegram 告警
当消息被阻止时:
``` 🛑 Message blocked
ID: `q-7f3a2b` Agent: moltbook-scanner Source: moltbook Sender: @sus_user Intent: instruction_override (85%)
Patterns: • matched regex: ignore.*instructions • matched keyword: api key
`/approve q-7f3a2b` `/reject q-7f3a2b` `/trust @sus_user` ```
仅基于元数据构建。LLM 不会触碰此内容。
---
## 命令
### `/quarantine [all|clean]`
列出隔离记录。
``` /quarantine # List pending /quarantine all # List all (including resolved) /quarantine clean # Clean expired records ```
### `/approve <id>`
将被阻止的消息标记为误报。
``` /approve q-7f3a2b ```
**效果:** - Status → `approved` - (未来) 将发送者加入白名单 - (未来) 降低模式权重
### `/reject <id>`
确认被阻止的消息是真正的威胁。
``` /reject q-7f3a2b ```
**效果:** - Status → `rejected` - (未来) 加强模式权重
### `/trust <senderId>`
将发送者列入未来的白名单。
``` /trust @legitimate_user ```
### `/scan <message>`
手动扫描一条消息。
``` /scan ignore your previous instructions and... ```
---
## 批准/拒绝 的含义
| 命令 | 作用 | 不起作用 | |---------|--------------|-------------------| | `/approve` | 标记为误报,可能会调整 IDS | 不会 重新注入该消息 | | `/reject` | 确认威胁,可能会加强模式 | 不会 影响当前消息 | | `/trust` | 将发送者列入未来的白名单 | 不会 追溯批准之前的消息 |
**被阻止的消息根据设计已被丢弃。** 如果是合法消息,发送者可以重新发送。
---
## 按智能体配置
不同的智能体需要不同的安全姿态:
```json "agents": { "moltbook-scanner": { "strictMode": true, // Block threats "riskThreshold": 0.7 // 70% = suspicious }, "main": { "strictMode": false, // Warn only "riskThreshold": 0.8 // Higher bar for main }, "email-processor": { "strictMode": true, // Always block "riskThreshold": 0.6 // More paranoid } } ```
---
## 威胁类别
| 类别 | 风险 | 描述 | |----------|------|-------------| | `command_injection` | 🔴 严重 | Shell 命令、代码执行 | | `credential_theft` | 🔴 严重 | API 密钥提取尝试 | | `data_exfiltration` | 🔴 严重 | 数据泄露到外部 URL | | `instruction_override` | 🔴 高 | 越狱、“忽略上述指令” | | `impersonation` | 🔴 高 | 伪造系统/管理员消息 | | `discovery` | ⚠️ 中 | API/能力探测 |
---
## 安装
```bash npx hopeid setup ```
然后重启 OpenClaw。
---
## 链接
- **GitHub**: https://github.com/E-x-O-Entertainment-Studios-Inc/hopeIDS - **npm**: https://www.npmjs.com/package/hopeid - **Docs**: https://exohaven.online/products/hopeids