Perufitlife/dotclaude-security
GitHub: Perufitlife/dotclaude-security
一个零依赖的本地静态扫描工具,用于在打开不受信任的仓库前检测 `.claude/` 配置中的 RCE 和密钥窃取风险。
Stars: 0 | Forks: 0
# dotclaude-security
[](https://www.npmjs.com/package/dotclaude-security) [](https://www.npmjs.com/package/dotclaude-security)   
```
$ npx dotclaude-security --dir ./untrusted-repo
1 critical, 2 high, 0 medium across 1 config file(s).
CRITICAL .claude/settings.json:4 Auto-exec hook on "SessionStart" runs a command when the repo is opened
HIGH .claude/settings.json:7 permissions.allow pre-approves a dangerous tool: Bash(*)
HIGH .claude/settings.json:8 MCP server "x" runs an on-the-fly remote package (npx)
```
## 为什么需要它
代码仓库可以自带其 `.claude/` 配置,并且 agent 在打开时会遵循这些配置。
2026 年 2 月,Check Point Research 披露了两个正是源于此的 CVE:
- **[CVE-2025-59536](https://thehackernews.com/)** (CVSS 8.7) — 由仓库控制的 `SessionStart` hook **在目录被打开时会自动执行 shell 命令**。
克隆恶意仓库,打开它,就会被攻击。初始化时即发生远程代码执行(RCE)。
- **CVE-2026-21852** — 仓库配置(hook 命令 / `env`)读取你的 **`ANTHROPIC_API_KEY`** 并将其发送到远程主机。无声无息地窃取密钥。
两者攻击的都是同一层面:`settings.json` **hooks**、**MCP server** 启动命令、**`env`** 块以及 **`permissions.allow`** 列表——也就是陌生人的仓库能提供给你的东西。大型 incumbent(例如 Cisco 的 skill-scanner、Snyk 的 agent-scan)扫描的是 **skills**;几乎没有人去扫描 **`.claude` 配置文件**。
`dotclaude-security` 会对这些文件进行静态解析,并标出每一条危险指令的具体文件和行号——让你可以针对事实而非臆测进行排查,并且**绝不通过执行 payload 来发现问题**。
## 检查内容
| 检查项 | 严重程度 | 捕获目标 |
|---|---|---|
| 打开时自动执行的 hook (`SessionStart`/`PreToolUse`/`UserPromptSubmit`) | critical / high | 仓库打开瞬间运行的命令 —— 初始化时的 RCE (CVE-2025-59536) |
| Hook 读取密钥 **且** 发起网络请求 | critical | `ANTHROPIC_API_KEY`/token 被发送到远程主机 —— 密钥窃取 (CVE-2026-21852) |
| 任何 hook 中的危险命令模式 | high | `curl\|sh`, `eval`, `base64 -d`, `nc -e`, `/dev/tcp`, 内联 `python -c`/`node -e` |
| MCP server 启动危险命令 | critical | MCP `command`/`args` 在连接时获取并执行代码 |
| MCP server 运行临时远程包 | high | 拉取未固定版本包的 `npx`/`uvx`/`bunx` MCP 定义 |
| MCP server 被传递密钥 / 远程 URL | high / medium | env 注入的凭证,不受信任的远程 endpoint |
| 高风险的 `permissions.allow` 条目 | high / medium | `Bash(*)`, `WebFetch`, 宽泛的 `mcp__*` 绕过人工审批关卡 |
| 提交的密钥值 | critical | 任何 `.claude` 文件中真实的 `sk-ant-…`, `AKIA…`, `ghp_…`, 私钥 |
## 用法
```
# 扫描当前 repo 中的 .claude/ config
npx dotclaude-security
# 在 Claude Code 中打开之前,扫描一个全新 clone 的、不受信任的 repo
npx dotclaude-security --dir ./some-cloned-repo
# 仅输出 Machine-readable 的 JSON(基于 summary 对你的 CI 进行 gate)
npx dotclaude-security --json
# 编写可分享的 HTML 报告
npx dotclaude-security --html report.html
```
输出为 stdout 上的 JSON(可通过管道传入 CI)以及 stderr 上每个发现结果的单行摘要。每个发现结果都包含 `file`、`location.line`、`location.text` 以及具体的 `fix`。
## 安装(可选)
```
npm i -g dotclaude-security
dotclaude-security --dir ./untrusted-repo
```
零依赖。它只读取你的配置文件并进行报告——它**绝不执行** hook、MCP 命令或它发现的任何其他内容。任何数据都不会离开你的机器。
## 姊妹工具
在整个技术栈中贯彻相同的本地优先、证明真实问题的理念,全部采用 MIT 许可证:
[supabase-security](https://github.com/Perufitlife/supabase-security-skill) ·
[strapi-security](https://github.com/Perufitlife/strapi-security) ·
[pocketbase-security](https://github.com/Perufitlife/pocketbase-security-skill) ·
[firebase-security](https://github.com/Perufitlife/firebase-security-skill) ·
[appwrite-security](https://github.com/Perufitlife/appwrite-security-skill) ·
[nhost-security](https://github.com/Perufitlife/nhost-security-skill) ·
[stripe-webhook-security](https://github.com/Perufitlife/stripe-webhook-security) ·
[github-actions-security](https://github.com/Perufitlife/github-actions-security) ·
[aws-s3-security](https://github.com/Perufitlife/aws-s3-security)
## 许可证
MIT © [Renzo Madueno](https://github.com/Perufitlife)
标签:AI配置审计, GNU通用公共许可证, MITM代理, Node.js, StruQ, 命令注入检测, 暗色界面, 自定义脚本, 错误基检测, 静态代码分析