Next.js middleware flaw CVE-2025-29927 let a crafted header skip authorisation checks
On 21 March 2025 the Next.js maintainers published advisory GHSA-f82v-jwr5-mffw for CVE-2025-29927, a critical (CVSS 9.1) flaw that let a request carrying the internal x-middleware-subrequest header skip middleware, and with it any authorisation checks performed there. According to Vercel's postmortem, self-hosted applications using next start with output: 'standalone' were affected, while apps on Vercel, Netlify or Cloudflare Workers and static exports were not. Fixes shipped in 12.3.5, 13.5.9, 14.2.25 and 15.2.3, and Datadog Security Labs later reported low-volume scanning that used known exploit header values.
- Next.js
- CVE-2025-29927
- authorisation bypass
- middleware
- Vercel
- JavaScript
What the sources report
- GitHub advisory GHSA-f82v-jwr5-mffw rates CVE-2025-29927 critical with CVSS 9.1 (CWE-285, Improper Authorization); affected ranges start at 11.1.4 and the patched releases are 12.3.5, 13.5.9, 14.2.25 and 15.2.3.
- Next.js skipped middleware when x-middleware-subrequest contained the middleware path, for example middleware or src/middleware; on 15.x the value had to repeat it to reach the recursion limit of 5, as in middleware:middleware:middleware:middleware:middleware (Fastly, Datadog).
- Vercel's postmortem says the issue was reported on 27 February 2025, confirmed by the Next.js team on 14 March, patched in 14.2.25 and 15.2.3 on 17 and 18 March, made public on 21 March, and backported to 13.5.9 and 12.3.5 on 22 and 23 March.
- According to Vercel, deployments on Vercel, Netlify and Cloudflare Workers were not affected because their routing runs in a separate, decoupled system; self-hosted apps using next start with output: 'standalone' were affected, and static exports were ruled out.
- Fastly notes the researchers who reported the flaw also showed it could cause denial of service through cache poisoning.
- Datadog Security Labs (28 March 2025) described observed scanning as generally small in volume, ineffective and poorly targeted, and listed 33 IP addresses it had high confidence in, each seen in at least five distinct environments.
What it means for your organisation
Any self-hosted Next.js app that enforced access control only in middleware could be reached by adding one request header, so real exposure depended on architecture as much as on version. Authorisation should be re-checked where data is read and changed, and edge proxies should strip framework-internal headers from external traffic.
What we check
- Inventory Next.js versions on every self-hosted service and confirm 12.3.5, 13.5.9, 14.2.25, 15.2.3 or later.
- Send requests carrying x-middleware-subrequest values such as middleware, src/middleware, pages/_middleware and the five-fold repeated form to protected routes and confirm access is still denied.
- Confirm the CDN, load balancer or reverse proxy strips x-middleware-subrequest from external requests.
- Review whether route handlers, server actions and API endpoints re-check authorisation instead of relying on middleware alone.
- Search access logs for inbound requests containing the x-middleware-subrequest header.
Sources
- Authorization Bypass in Next.js Middleware (GHSA-f82v-jwr5-mffw) (opens in a new tab) · Vercel (GitHub Security Advisory) · 21 March 2025
- Postmortem on Next.js Middleware bypass (opens in a new tab) · Vercel · 25 March 2025
- Understanding CVE-2025-29927: The Next.js Middleware Authorization Bypass Vulnerability (opens in a new tab) · Datadog Security Labs · 28 March 2025
- CVE-2025-29927: Authorization Bypass in Next.js (opens in a new tab) · Fastly · 26 March 2025