prashanthnataraj/mini-shai-hulud-detector
GitHub: prashanthnataraj/mini-shai-hulud-detector
针对 CVE-2026-45321 的 npm 供应链蠕虫检测工具,帮助在轮换令牌前发现感染。
Stars: 0 | Forks: 0
# Mini Shai-Hulud 检测器
用于检测 Mini Shai-Hulud npm 供应链攻击(CVE-2026-45321,CVSS 9.6)的单命令扫描器。
## 重要提示:在轮换令牌前进行检测
该蠕虫会安装一个持久化守护进程(`gh-token-monitor`),如果检测到凭据被撤销,它会执行 `rm -rf ~`。**在确认守护进程已被移除之前,请不要轮换您的 GitHub PAT 或 npm 令牌。** 先检测 → 移除守护进程 → *然后* 再轮换。
## 使用方法
```
curl -fsSL https://raw.githubusercontent.com/prashanthnataraj/mini-shai-hulud-detector/main/shai-hulud-detector.sh | bash
```
或先下载并检查(建议对任何通过管道传送到 shell 的脚本都这样做):
```
curl -fsSL https://raw.githubusercontent.com/prashanthnataraj/mini-shai-hulud-detector/main/shai-hulud-detector.sh -o shai-hulud-detector.sh
# 阅读它。然后:
bash shai-hulud-detector.sh
```
## 检查内容
| 步骤 | 检查项 |
|------|--------|
| 1 | `package-lock.json` 中是否存在 `@tanstack/setup` 幽灵包 |
| 2 | 已知恶意载荷文件(`router_init.js`、`tanstack_runner.js`) |
| 3 | 载荷的 SHA-256 哈希值是否与已知恶意列表匹配 |
| 4 | `gh-token-monitor` 持久化守护进程(LaunchAgent / systemd / pgrep) |
| 5 | `~/.claude/settings.json` 中是否存在意外的 `PreToolUse` / `PostToolUse` 钩子 |
| 6 | `.github/workflows` 中的 `pull_request_target` 触发器和未固定的 action 引用 |
## 退出代码
| 代码 | 判定 |
|------|------|
| `0` | 干净 — 未发现任何指标 |
| `1` | 可疑 — 需要人工审查 |
| `2` | 已感染 — 请严格按照修复顺序操作(参见脚本输出) |
## 如果已感染的修复顺序
1. 立即断开网络连接。
2. **不要** 运行 `npm install`、`npm uninstall` 或 `git push`。
3. 首先移除守护进程 — 脚本输出会告诉你确切路径。
4. 移除载荷文件。
5. 然后:重新连接并轮换凭据(首先轮换 GitHub PAT)。
6. 重新安装:`rm -rf node_modules && npm install --ignore-scripts`。
## 加固措施(无论扫描结果如何都值得做)
添加到 `.npmrc`:
```
ignore-scripts=true
minimum-release-age=4320
```
将所有 GitHub Actions 固定到完整的提交 SHA,而不是版本标签。
## 关于
在 [Lume AI](https://getlumeai.com) 团队于 2026 年 5 月遭遇一次真实的 CVE-2026-45321 攻击后编写。该脚本是只读的 — 下载后无网络调用,不写入磁盘。运行前请检查源代码。
## 许可证
MIT — 详见 [LICENSE](./LICENSE)。
标签:bash脚本, Cutter, npm, 令牌管理, 包管理器, 子域名枚举, 安全修复, 应用安全, 恶意代码, 系统安全, 统一API, 网络安全, 蠕虫, 钩子监控, 隐私保护, 项目加固