Skip to main content
Process diagram: the exploitation chain behind CVE-2025-29927, where a spoofed middleware header skips the authorization check. Illustration: SecurityXP

CVE-2025-29927: Next.js Middleware Authorization Bypass

· 4 min read · Updated November 20, 2026 · SecurityXP Editorial Desk

Key Facts

  • CVE-2025-29927 is an authorization bypass in Next.js middleware, rated CVSS 9.1 (Critical) and classified as CWE-285.
  • Sending the internal x-middleware-subrequest header makes Next.js skip middleware entirely, including any authentication checks it performs.
  • Fixed releases: 15.2.3, 14.2.25, 13.5.9 and 12.3.5.
  • Self-hosted apps running middleware with next start are affected; apps on Vercel or Netlify, and static exports, are not.
  • If you cannot upgrade, block external requests that carry the x-middleware-subrequest header.

Correction (November 20, 2026): An earlier version of this article described CVE-2025-29927 as a path traversal vulnerability. That was wrong. CVE-2025-29927 is a middleware authorization bypass. The article has been rewritten to describe the flaw accurately.

CVE-2025-29927 is a critical authorization bypass in Next.js, the React framework maintained by Vercel. One request header is enough to make a Next.js server skip its middleware. Applications that use middleware to enforce authentication, such as redirecting signed-out users away from /admin, can be reached without logging in.

The flaw was disclosed on March 21, 2025, in Next.js advisory GHSA-f82v-jwr5-mffw. It carries a CVSS 3.1 score of 9.1 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N) and is classified as CWE-285, Improper Authorization. Researchers Rachid Allam and Yasser Allam are credited with the discovery.

How the bypass works

Next.js middleware runs before a request reaches a page or API route. Middleware can call back into the same application, so Next.js needs a way to stop a request from triggering middleware over and over. It does this with an internal header, x-middleware-subrequest. When a request carries that header with the right value, Next.js treats it as an internal subrequest and forwards it without running middleware again.

The problem is that Next.js did not check where the header came from. An external client could send it, and the server would skip middleware for that request.

The value the server expects depends on the version:

  • Older releases only needed the middleware’s path, such as pages/_middleware or middleware (or src/middleware when the project uses a src directory).
  • Newer releases added a recursion-depth limit. The value has to repeat the middleware name up to that limit (five times), separated by colons.

A request against a newer release looks like this:

GET /admin HTTP/1.1
Host: app.example.com
x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware

If /admin is protected only by a session check in middleware, the response is the admin page.

Impact

The direct impact is an authentication and authorization bypass for anything that relies on middleware alone. Middleware is also used for other security controls, so those are skipped too:

  • Authentication and role checks that redirect or reject unauthorized users.
  • Security headers such as a Content Security Policy that middleware adds to responses.
  • Rewrites and geo or tenant routing that keep users inside their own area of the app.

The researchers also described cache-poisoning and denial-of-service scenarios in setups where a CDN caches the response to a request that bypassed middleware.

Who is affected

According to the Next.js advisory, the flaw affects self-hosted applications that use middleware and run with next start, including output: 'standalone' builds.

These are not affected:

  • applications hosted on Vercel or Netlify;
  • applications deployed as a static export, because middleware does not run.
Release line Fixed in
Next.js 15.x 15.2.3
Next.js 14.x 14.2.25
Next.js 13.x 13.5.9
Next.js 12.x 12.3.5

Versions from 11.1.4 onward are affected until those fixes.

How to fix it

  1. Upgrade. Move to 15.2.3, 14.2.25, 13.5.9 or 12.3.5, or any later release on your line.

  2. If you cannot upgrade yet, block the header at the edge. Legitimate internal subrequests never come from clients, so it is safe to reject or strip x-middleware-subrequest on incoming traffic. In nginx:

    if ($http_x_middleware_subrequest) {
        return 403;
    }

    Many WAF and CDN providers, including Cloudflare, published rules for this header after disclosure.

  3. Do not rely on middleware as the only authorization layer. Check the session again in route handlers, server actions and data-access code. Middleware is a good first filter, but it should not be the only thing standing between an anonymous user and protected data.

How to tell if you were targeted

  • Search proxy, CDN and WAF logs for the header. Any inbound request carrying x-middleware-subrequest is suspicious, because real subrequests are generated inside the server. Many web servers do not log request headers by default, so check the layer that does.
  • Look for successful responses to protected paths with no session. A 200 for /admin or an account page from a client that never authenticated is a strong signal.
  • Review what those requests could reach. If middleware protected API routes, check for data that was read or changed through them.

Timeline

Date Event
March 21, 2025 Advisory GHSA-f82v-jwr5-mffw and CVE-2025-29927 published
March 25, 2025 SecurityXP article first published
November 20, 2026 Article corrected and rewritten (see note above)

Sources

  1. https://github.com/vercel/next.js/security/advisories/GHSA-f82v-jwr5-mffw
  2. https://nvd.nist.gov/vuln/detail/CVE-2025-29927
  3. https://nextjs.org/blog/cve-2025-29927
Tags: Next.js CVE-2025-29927 Middleware Authorization Bypass Vercel

Sources & References

SE SecurityXP Editorial Desk
SecurityXP Editorial Desk Vulnerability Research & News Board

Automated and analyst-reviewed threat intelligence briefings tracking active exploitation campaigns, CVE disclosures, and extortion group activity.

Security Digest

The most important cybersecurity stories, CVE alerts, and threat intelligence — one concise email. Unsubscribe anytime.

Related Articles

Process diagram of the exploitation chain: Unpatched vCenter through Patch released, with the fault at Auth bypass.
Vulnerabilities & Exploits

VMware vCenter Authentication Bypass Exploited as Zero-Day for Over Two Months Before Patch

Broadcom's VMSA-2026-0009 fixes CVE-2026-123890, a vCenter authentication bypass exploited as a zero-day. Affected versions, fixed builds and hunting guidance.

Process diagram of the exploitation chain: Probe gateway through Gateway events, with the fault at Bypass auth.
Vulnerabilities & Exploits

Palo Alto Warns of Exploitation of VPN Bypass Exploits (CVE-2026-0257) in PAN-OS Flaw

"Only a small portion of the probed devices actually established VPN sessions, resulting in gateway-connected events." The company has also released...

Process diagram of the exploitation chain: Auth Bypass 1 through Root RCE, with the fault at Auth Bypass 1.
Vulnerabilities & Exploits

Ubiquiti UniFi OS Auth Bypass Enables Root RCE

Ubiquiti disclosed three critical vulnerabilities in UniFi OS Server on May 21, 2026. Each scores a perfect 10.0 on the CVSS scale.

Process diagram of the exploitation chain: Pre-BIOS hotkeys through Files deleted, with the fault at WinPE menu guess.
Vulnerabilities & Exploits

ELI5: YellowKey (CVE-2026-45585) BitLocker Bypass that survived the Great Global CrowdStrike Outage of 24)

The vulnerability, identified as CVE-2026-45585, has significant implications for organizations using Windows PE, versions 10 and 11, and CrowdStrike, versions 6.0 and later.