Caixa-git/tanstack-shield
GitHub: Caixa-git/tanstack-shield
针对CVE-2026-45321 TanStack npm供应链攻击的一键式只读扫描器,帮助开发团队快速判断项目是否引入了已知恶意包版本。
Stars: 0 | Forks: 0
# 🛡️ tanstack-shield
**针对 CVE-2026-45321 / GHSA-g7cv-rxg3-hmpx 的一键供应链攻击扫描器**
用于检测在 2026 年 5 月 11 日感染了 42 个 `@tanstack/*` npm 包(84 个恶意版本)的“Mini Shai-Hulud”蠕虫。
```
# 一行命令 — 扫描你的项目
curl -fsSL https://raw.githubusercontent.com/Caixa-git/tanstack-shield/main/tanstack-shield.sh | bash
# 扫描特定目录
curl -fsSL https://raw.githubusercontent.com/Caixa-git/tanstack-shield/main/tanstack-shield.sh | bash -s -- /path/to/project
# 下载并直接使用
git clone https://github.com/Caixa-git/tanstack-shield.git
cd tanstack-shield
python3 tanstack-shield.py .
```
## 背景
在 **2026 年 5 月 11 日**,一名攻击者串联利用了三个已知的漏洞类型——`pull_request_target` (Pwn Request) 配置错误、GitHub Actions 缓存投毒,以及 OIDC token 内存提取——在 TanStack 受信任的 npm 身份下,向 **42 个 `@tanstack/*` 包**发布了 **84 个恶意版本**。
该恶意软件窃取凭据(GitHub token、npm token、SSH 密钥、AWS/GCP/Kubernetes/Vault),通过 Session messenger 将其外泄,并自我传播到受害者维护的其他包中。
同样的攻击活动还波及了 **Mistral AI** (npm + PyPI)、**UiPath** (65 个包)、**OpenSearch** (npm 每周 130 万次下载),以及总计 **170 多个 npm 包**和 2 个 PyPI 包。
- **CVE:** CVE-2026-45321
- **安全公告:** [GHSA-g7cv-rxg3-hmpx](https://github.com/advisories/GHSA-g7cv-rxg3-hmpx)
- **事后分析:** [tanstack.com/blog/npm-supply-chain-compromise-postmortem](https://tanstack.com/blog/npm-supply-chain-compromise-postmortem)
- **攻击者:** TeamPCP ("Mini Shai-Hulud" 蠕虫)
- **StepSecurity 分析:** [stepsecurity.io/blog/mini-shai-hulud](https://www.stepsecurity.io/blog/mini-shai-hulud-is-back-a-self-spreading-supply-chain-attack-hits-the-npm-ecosystem)
## 功能说明
只读扫描器,用于检查您的项目中是否存在以下情况:
| 检查项 | 文件 | 结果 |
|------|-------|--------|
| npm lockfile | `package-lock.json`、`npm-shrinkwrap.json` | 🔴 精确匹配恶意版本 |
| pnpm lockfile | `pnpm-lock.yaml` | 🔴 精确匹配恶意版本 |
| yarn lockfile | `yarn.lock` | 🔴 精确匹配恶意版本 |
| 清单依赖项 | `package.json`(根目录 + 工作区) | 🟡 包存在警告 |
| 恶意软件指纹 | `@tanstack/setup` 在 optionalDependencies 中 | 🔴 确认的恶意软件 |
| 可疑 git 依赖 | `github:tanstack/router#` | 🔴 确认的恶意软件 |
| 生命周期脚本 | 带有 `bun` + `router_init` 的 `prepare` | 🔴 确认的恶意软件 |
| node_modules | `node_modules/@tanstack/*`(后备方案) | 🔴 精确匹配版本 |
**注意:** Lockfile 仅在项目根目录进行扫描。如果您使用的是在子目录中包含 lockfile 的 monorepo(例如 `packages/web/package-lock.json`),请在每个工作区内运行扫描器,或者从存在顶级 lockfile 的 monorepo 根目录运行。
## 输出结果
- 🔴 **严重 (CRITICAL)** — 检测到恶意软件。请遵循修复指南(自动打印)。
- 🟡 **警告 (WARNING)** — 在 package.json 中发现了 `@tanstack/*`。请检查您的 lockfile。
- 🟢 **安全 (SAFE)** — 未检测到已知的恶意包。
⚠️ **关键提示:此恶意软件是凭据窃取程序,而不是破坏计算机的病毒。**
如果检测到 🔴:
- 您的文件和系统**未受破坏**
- 但是从该机器可访问的凭据可能已被**窃取**
- **立即**轮换 GitHub token、npm token、SSH 密钥和云凭据
## JSON 输出
```
curl -fsSL https://raw.githubusercontent.com/Caixa-git/tanstack-shield/main/tanstack-shield.sh | bash -s -- --json
```
## 安全性
此工具是**只读的**。它永远不会在您的系统上创建、修改或删除文件。
## 环境要求
- Python 3.8+
- curl(用于单行命令模式)
## 许可证
MIT
标签:CI/CD安全, CVE-2026-45321, GitHub Actions, GraphQL安全矩阵, Llama, npm安全, Python, Shell脚本, T1195.002, TanStack, 供应链攻击, 依赖安全, 安全扫描器, 库, 应急响应, 应用安全, 无后门, 网络安全, 自动笔记, 蠕虫病毒, 隐私保护