用一条命令、零依赖地检查 Next.js 项目是否受 2026 年 10 月 14 日 Next.js 安全公告 影响:
sharp 在 Image Optimization API 中处理 SVG 时的远程代码执行(严重)use cache 函数中的远程代码执行(严重,Next.js 16)它读取 node_modules 中实际安装的版本(npm、pnpm 或 yarn 的目录布局,包括嵌套副本),而不是 package.json 中的版本范围,并扫描源码中的 "use cache"、"use server" 和 next/image。
需要 Node.js 18 或更高版本。安装依赖包后,在项目根目录运行:
curl -O https://raw.githubusercontent.com/AmanSin001/next-security-check/main/next-security-check.mjs
node next-security-check.mjs # current folder
node next-security-check.mjs ./my-app # or a path
echo $? # 0 = nothing to do, 1 = action needed
一个真实安装了 Next.js 16.3.0、使用 Server Actions 和 next/image 的环境:
Next.js security check (October 14, 2026 advisories)
next: 16.3.0
sharp: 0.35.3
features: App Router yes, "use cache" no, Server Actions yes, next/image yes
FIX CVE-2026-96889 Image Optimization RCE with SVG (critical)
your app uses next/image. sharp 0.35.3 installed; needs 0.35.5+.
Fix: next 16.4.1, or sharp 0.35.5+ for every copy
FIX GHSA-673q-mjm6-r5xr use cache RCE (critical, Next.js 16)
no "use cache" found; Vercel still says upgrade
Fix: next 16.4.1
FIX GHSA-p3m5-59mp-jv5r Server Actions denial of service (high)
your code has "use server"
Fix: next 16.4.1
ok GHSA-xqc2-xf4c-x3h3 React Server Components packages (critical)
not installed directly (Next.js bundles its own)
Action needed: upgrade, reinstall, rebuild and redeploy.
Next.js 15.5.28 仍然接受 sharp ^0.34.3,而 0.34 系列没有修复版本。如果 sharp 出现在你自己的 package.json 中,或被锁定在 lockfile 里,升级 Next.js 并不会替换它。检查器会标记此问题,并建议执行 npm install sharp@^0.35.5。
| 系列 | 修复版本 |
|---|---|
| Next.js 16 | 16.4.1 |
| Next.js 15 | 15.5.28 |
| sharp | 0.35.5 或更高 |
| react-server-dom-* | 19.0.9, 19.1.10, 19.2.9, 19.3.1 |
node --test next-security-check.test.mjs
共八个用例,包括 pnpm 的 .pnpm 布局、符号链接、15.x 的 sharp 陷阱以及 Pages Router 应用。
app、src、pages、components 和 lib。构建时生成的代码或位于其他包中的代码不会被发现。如有疑问,请升级。MIT。需要为你打补丁?CodeWares。