verify_react_vulnerability.py)这是一个简单、独立的 Python 脚本,旨在帮助你快速判断你的项目是否受到严重的 React2Shell 漏洞(也称为 CVE-2025-55182)的影响。
它执行两级检查:
package.json 文件中是否存在已知存在漏洞的 React 和 Next.js 版本。package.json:在脚本运行的目录中查找 package.json 文件。react 和 next 的确切版本。npm install 命令,用于更新到安全版本。"use server""use client"createSafeActionClientregisterServerReferencereact-server-dom-webpackpython3 --version 来检查。pip install packaging
确保 verify_react_vulnerability.py 脚本位于项目的根目录(即与 package.json 相同的目录)。
打开终端并运行命令:
python3 verify_react_vulnerability.py
如果发现存在漏洞的库版本,脚本会立即停止并报告该问题:
--- Step 1: Checking versions in package.json ---
❌ VULNERABLE: Found React version 19.0.1.
...
-------------------------------------------------
❌ SUMMARY: Your project is VULNERABLE based on dependency versions.
Please update the following dependencies immediately.
--- Recommended Fixes ---
npm install [email protected] [email protected]
...
-------------------------------------------------
如果依赖项安全,脚本会提议进行深度扫描。
--- Step 1: Checking versions in package.json ---
✅ OK: Found React version 18.3.1. Not in a known vulnerable range.
...
-------------------------------------------------
✅ INFO: Your project's dependencies do not seem to be affected by React2Shell.
However, vulnerable features might be in use if code was copy-pasted or 'vendored'.
Do you want to perform a comprehensive deep code scan? (y/n): y
如果深度扫描发现相关迹象,它将提供一份详细报告:
--- Step 2: Performing Comprehensive Deep Code Scan ---
Searching for patterns related to React Server Components...
⚠️ WARNING: Deep scan found indicators of React Server Component usage.
This does not guarantee a vulnerability, but warrants a manual review.
Ensure your framework versions are fully patched.
- Found pattern '"use server"':
Reason: Indicates a file contains React Server Actions, the primary feature associated with the vulnerability.
In files: ['src/actions/auth.ts']
- Found pattern '"use client"':
Reason: Indicates a Client Component, which may import and use Server Actions from other files.
In files: ['src/components/LoginButton.tsx', 'src/components/ThemeSwitcher.tsx']
-------------------------------------------------
如果深度扫描未发现任何内容,它将确认你的项目可能是安全的:
--- Step 2: Performing Comprehensive Deep Code Scan ---
Searching for patterns related to React Server Components...
✅ OK: The comprehensive deep scan did not find any indicators of RSC usage.
-------------------------------------------------