Next.js 幾乎每月發布安全修補:現在該用哪個版本(2026 年 11 月)
更新於 · Bologu 團隊
Next.js 是 AI 工具最常選用的框架之一,v0、Bolt、Cursor 都是。2026 年幾乎每個月都有新的 Next.js 漏洞公布,其中好幾個嚴重到外人不必登入就能在伺服器上執行程式碼。 部署後就沒再更新的網站,即使程式碼完全沒動,風險也會越來越高。
重點整理:現在該用哪個版本
- Next.js 16:至少
16.4.5(2026 年 11 月 3 日發布)。 - Next.js 15:至少
15.5.29;不過依 Next.js 的政策,15 版的兩年維護期已於 2026 年 10 月 21 日屆滿,請規劃升級到 16。 - Next.js 14 及更舊版本:已不再提供安全修補,請升級。
今年發布了哪些修補
自 2026 年 7 月 13 日起,Next.js 團隊改為依事先公告的時程發布安全修補,大約每月一次,緊急問題另行發布:
- 7 月 21 日:9 個漏洞,包括繞過 middleware、Server Actions 的 SSRF 與阻斷服務(修正於 16.2.11 / 15.5.21)。
- 8 月 25 日:2 個可在未登入狀態下遠端執行程式碼的重大漏洞,其中一個影響架在 Windows 上的伺服器(修正於 16.3.3 / 15.5.24)。
- 9 月 22 日:
ImageResponse(產生分享預覽圖的功能)的重大漏洞。若網站把網址中的值放進圖片,外人就能在伺服器上執行程式碼(16.2.0–16.3.5,修正於 16.3.6)。 - 10 月 14 日:2 個重大漏洞:一個在 Linux 上處理 SVG 檔時的圖片最佳化功能(來自
sharp函式庫),一個在use cache功能(修正於 16.4.1 / 15.5.28)。 - 11 月 3 日:7 個漏洞,最嚴重的會讓依客戶區分使用
use cache的網站,把某位客戶的快取資料顯示給另一位客戶(修正於 16.4.5 / 15.5.29)。
許多漏洞只影響使用特定功能或架設方式的網站,但逐一確認是否受影響,比直接更新還花時間。有些漏洞(例如 10 月的 use cache 漏洞),Next.js 團隊建議即使沒用到相關寫法也要立即更新。
不要只依賴 npm audit
ImageResponse 漏洞公布時,The Hacker News 測試發現 npm audit 尚未標示受影響的版本,也還沒有 CVE 紀錄。資料庫的更新會比修補慢,請直接拿實際安裝的版本與上面的清單比對。
檢查並更新
npm ls next sharp
# then, for Next.js 16:
npm install next@latest
# or, if you must stay on 15 for now:
npm install [email protected]- 在專案資料夾執行
npm ls next sharp查看實際安裝的版本,sharp應為 0.35.5 以上。 - 更新後也要提交 lockfile。
- 重新建置並部署。只在 GitHub 修正並不夠,在重新部署前,正式網站仍執行舊版本。
- 追蹤 nextjs.org/blog/security,團隊大約會在發布前一週公告。
給 AI 的提示詞
Upgrade Next.js in this project to the latest 16.x release (at least 16.4.5).
1. Read the official upgrade guide for any breaking changes between our version and 16.x
and apply them.
2. Make sure the installed sharp version is 0.35.5 or later (npm ls sharp).
3. Commit the updated lockfile, and make the build use npm ci.
4. Run the build and tests, and list anything that changed behaviour.
Do not change anything unrelated to the upgrade.讓 Bologu 幫你檢查
網站掃描(免費)會讀取網頁傳給瀏覽器的 Next.js 與其他函式庫版本,並與 OSV.dev 漏洞資料庫比對。若無法從網頁讀出版本,GitHub 程式碼檢查可從 lockfile 讀取實際版本。(Bologu 使用同類型的資料庫,因此和 npm audit 一樣,可能比 Next.js 的公告慢。)
資料來源
- Next.js: November 2026 Security Release
- Next.js: Security Update for Upstream Vulnerabilities (Oct 14, 2026)
- The Hacker News: Critical Next.js ImageResponse flaw (Sep 2026)
- Netlify: Two critical Next.js vulnerabilities (Aug 25, 2026)
- Next.js: Security release program (Jul 13, 2026)
- Next.js Support Policy
