On March 21 the maintainers of Next.js, one of the most widely used web frameworks on the internet, published a critical advisory: CVE-2025-29927. If an application relied on Next.js middleware to decide who was allowed to see a page, an outside request carrying one particular internal header could cause that middleware not to run at all. No password guessing, no stolen session. The login check simply did not happen.
It is patched, and the fix is a version bump. We are writing about it anyway, because the bug is a near-perfect example of the most common finding in our application tests, and because the way it played out says something useful about how framework risk reaches companies that never consciously chose a framework.
What happened, briefly
Next.js uses an internal header to mark requests the framework generates for itself, so that middleware does not end up calling itself in a loop. The server did not distinguish between that header arriving from inside the application and arriving from the internet. Supplied from outside, it convinced the framework the request had already been handled, and the middleware was skipped.
The specifics that matter for triage:
- Affected: self-hosted applications, typically run with
next startand the standalone output mode, on versions before 12.3.5, 13.5.9, 14.2.25 and 15.2.3, that enforce authorization in middleware. The advisory rates it 9.1. - Not affected: applications hosted on Vercel or Netlify, whose platforms route requests separately, and static exports, which do not run middleware at all.
- Fixed: in those four releases, with the 12.x and 13.x backports arriving within days of the advisory.
- Workaround: if you cannot upgrade, block or strip the
x-middleware-subrequestheader at your proxy before requests reach the application.
Vercel's postmortem, published on March 25, sets out the timeline plainly: the report arrived on February 27, reached the Next.js team on March 14, was patched for current versions on March 17 and 18, and became public on March 21. The company says it is changing how it triages reports and coordinates with hosting partners. Credit to the researchers who reported it privately, and to Vercel for writing down the slow part instead of skipping it.
The bug class we find every month
Strip away the framework and you get a finding we write up, in one form or another, in a large share of our web application engagements: authorization enforced in exactly one place, upstream of the thing it protects.
It shows up as:
- A gateway that checks login, in front of services that trust anything reaching them. Find a second route to the backend, such as an old hostname, a health-check port or a load balancer reachable from a partner network, and the check is gone.
- A header that means "trusted". Internal identity headers, "already authenticated" flags, client-address headers used for allowlisting. If the edge does not remove them from inbound traffic, the internet can set them.
- Front-end route guards. The page will not render for a logged-out user, but the API behind it answers anyone who asks.
CVE-2025-29927 is the framework-level version of the second pattern. Developers who put authentication in middleware were following a convenient, widely documented path. The flaw was not that they were careless. It was that one layer carried all the weight.
Why the deployment model mattered
The odd feature of this advisory is that identical code was vulnerable or safe depending on where it ran. Managed platforms handle routing separately and were not exposed. Self-hosted deployments behind an ordinary reverse proxy were.
That is uncomfortable for mid-market organizations, because a lot of self-hosted Next.js was not built by the security team or even the IT team. It is the customer portal an agency delivered two years ago, the booking front end a contractor deployed on a cloud VM, the internal dashboard a developer stood up and left running. Nobody on staff today may know it is Next.js, which version it runs, or that its access control lives in a single middleware file.
In the interest of transparency: this website is a self-hosted Next.js application. We checked our own version before anyone else's, then added a header strip at our proxy as belt and braces after upgrading. That took under an hour. Establishing which client applications were exposed took considerably longer, almost entirely because of the inventory problem above.
What to do this week
Inventory. Ask every internal team, and every agency you have paid for web work, which framework and version each application uses. Search your repositories and deployment manifests for a next dependency. Do not forget staging environments; they are often internet-facing and usually older than production.
Upgrade. Move to 12.3.5, 13.5.9, 14.2.25, 15.2.3 or, better, the newest patch on your release line, since a smaller related fix followed on March 24. This is a dependency bump, not a migration. Version 11 gets no fix; the header strip is the only option there, and the upgrade is overdue.
Strip the header at the edge regardless. Configure your reverse proxy or load balancer to drop that internal header from inbound requests. If you sit behind a cloud WAF, check whether your provider offers a rule, and run it in log-only mode first. Cloudflare switched its emergency rule to opt-in shortly after release because it was breaking requests on sites that use third-party authentication middleware, which is a fair illustration of why blanket edge fixes deserve a test.
Look back. Search proxy and application logs for inbound requests carrying that header since the advisory, and earlier if your retention allows. Datadog reported relatively limited, poorly targeted scanning in the first week. Do not count on that lasting; the flaw is trivial to check for at scale.
Move the decision next to the data. The durable fix is architectural. Keep middleware for convenience, such as redirects and coarse gating, but re-check authorization in the route handler or data access layer, on every request, for every protected resource. Then a bypass in one layer is an embarrassment rather than a breach.
The plain version
Every authorization check carries an assumption about what reaches it. This one assumed the framework would always run its own middleware, and one header made that untrue. The question worth asking of every application you own is not "do we check login?" but "if this one check vanished tomorrow, what would still say no?"
If the answer is nothing, you have a login page, not access control.
Sources
- Authorization Bypass in Next.js Middleware (GHSA-f82v-jwr5-mffw) — GitHub Security Advisory, March 2025
- Postmortem on Next.js Middleware bypass — Vercel, March 2025
- Understanding CVE-2025-29927: The Next.js Middleware Authorization Bypass Vulnerability — Datadog Security Labs, March 2025
- New Managed WAF rule for Next.js CVE-2025-29927 — Cloudflare, March 2025






