XiaoYiWeio/deepsafe-scan
GitHub: XiaoYiWeio/deepsafe-scan
OpenClaw 生态的全栈预检安全扫描器,融合配置审计、代码分析、敏感信息检测与模型行为探测于一体。
Stars: 0 | Forks: 0
# deepsafe-scan
OpenClaw 安全扫描器技能 — 由 [DeepSafe](https://github.com/XiaoYiWeio/DeepSafe) 提供支持。
跨 **4 个模块**的全功能预检安全审计,具备 **LLM 增强的语义分析**和**基于指纹的缓存**。
## 模块
| 模块 | 扫描内容 | 需要 Gateway |
|--------|--------------|:---:|
| **Posture** | `openclaw.json` — auth, network, TLS, sandbox, plugin permissions | No |
| **Skill** | Installed skills & MCP — 15+ pattern analyzers + LLM semantic audit | LLM audit only |
| **Memory** | Sessions & stored data — 27+ secret patterns, 9 PII patterns, injection | No |
| **Model** | Behavioral safety — 4 probes (persuasion, sandbagging, deception, HaluEval) | Yes |
## 安装
```
clawhub install deepsafe-scan
```
或手动安装:
```
cp -r deepsafe-skill ~/.openclaw/workspace/skills/deepsafe-scan
```
## 使用
安装完成后,只需询问您的 OpenClaw agent:
### CLI 使用
```
# 完整扫描(全部 4 个模块,model probes 和 LLM 需要 gateway)
python3 scripts/scan.py \
--openclaw-root ~/.openclaw \
--gateway-url http://127.0.0.1:PORT \
--gateway-token YOUR_TOKEN \
--format html \
--output report.html
# 仅静态扫描(无需 gateway)
python3 scripts/scan.py \
--openclaw-root ~/.openclaw \
--modules posture,skill,memory \
--no-llm \
--format markdown
# 仅 Quick model 探测
python3 scripts/scan.py \
--modules model \
--profile quick \
--gateway-url http://127.0.0.1:PORT \
--gateway-token TOKEN
```
### Flags
| Flag | Default | Description |
|------|---------|-------------|
| `--openclaw-root` | `~/.openclaw` | Path to OpenClaw root |
| `--modules` | `posture,skill,memory,model` | Comma-separated modules |
| `--format` | `json` | Output format: `json`, `markdown`, `html` |
| `--output` | stdout | Write report to file |
| `--profile` | `quick` | Probe profile: `quick`, `standard`, `full` |
| `--gateway-url` | – | Gateway URL for LLM & model probes |
| `--gateway-token` | – | Gateway auth token (or `$OPENCLAW_GATEWAY_TOKEN`) |
| `--ttl-days` | `7` | Cache TTL in days |
| `--no-cache` | false | Skip cache |
| `--no-llm` | false | Skip LLM-enhanced analysis |
| `--debug` | false | Verbose debug output |
## 检测内容
### Posture Checks
- Gateway auth 缺失
- 网络暴露(绑定 0.0.0.0)
- 明文 API key
- 无 TLS 的 HTTP
- 缺少 sandbox
- 危险的 plugin 权限
- 日志记录已禁用
### Skill 分析器 (15+)
- 隐藏 Unicode / 零宽字符
- Prompt injection 模式
- 危险 runtime(eval, exec, spawn)
- Base64/hex 编码的 payload
- 敏感文件访问
- 嵌入式 secret
- System prompt 提取
- Command injection
- 数据窃取模式
- 破坏性操作
- 未经确认的自动执行
- 过度的 shell 权限
- 写入 + 网络 组合
- LLM 语义审计(社会工程学,隐式数据窃取)
### Secret 模式 (27+)
OpenAI, GitHub, AWS, Azure, GCP, Slack, Stripe, Twilio, SendGrid, JWT, SSH keys, Anthropic, Hugging Face 等。
### PII 模式 (9)
Email, phone, SSN, credit cards, passport, IP addresses, driver's license, date of birth, street addresses。
### Model 安全探测 (4)
- **Persuasion**:多轮操纵成功率
- **Sandbagging**:策略性能力隐藏(SBS metric)
- **Deception**:推理-行为不一致(DTR metric)
- **HaluEval**:HaluEval 检测准确率
## 评分
- 每个模块:`max(1, 100 - deductions)` — 至少 1 分
- 扣分:CRITICAL=-10, HIGH=-5, MEDIUM=-2, LOW=-1
- 每个模块的贡献值:`floor(score / 4)` (1–25)
- **总分 = 4 个贡献值之和** (4–100)
## 依赖
**零外部依赖。** 仅使用 Python 3 标准库:
- `re`, `json`, `os`, `pathlib` 用于扫描
- `urllib.request` 用于 LLM/Gateway API 调用
- `subprocess` 用于运行 model probe 脚本
- `hashlib` 用于缓存指纹
- `concurrent.futures`(在 probes 中)用于并行执行
## 项目结构
```
deepsafe-skill/
├── SKILL.md # Skill definition for OpenClaw
├── README.md
├── data/ # Bundled probe datasets
│ ├── manipulation_persuasion_topics.json
│ ├── sandbagging-samples-all.jsonl
│ ├── deceptionbench.json
│ ├── halueval_samples.json
│ └── qa_evaluation_instruction.txt
└── scripts/
├── scan.py # Main scanner (posture + skill + memory + LLM + cache + reports)
└── probes/
├── persuasion_probe.py # Persuasion & manipulation probe
├── sandbagging_probe.py # Strategic capability hiding probe
├── deception_probe.py # Deception tendency probe
└── halueval_probe.py # Hallucination detection probe
```
## 许可证
MIT
标签:CISA项目, DeepSafe, DevSecOps, DNS 反向解析, MCP安全, OpenClaw, PII识别, Prompt注入, Python, TypeScript, 上游代理, 会话安全, 大模型安全, 安全扫描, 安全插件, 对抗攻击, 敏感信息检测, 无后门, 时序注入, 权限管理, 模型越狱, 网络安全, 聊天机器人, 行为探测, 隐私保护, 零依赖