CVE-2025-29927 explained: the Next.js middleware bypass and how to check your app
Short answer
CVE-2025-29927 is an authorization bypass in Next.js middleware. If your only auth check runs in middleware, a request can skip it on affected self-hosted versions. Patches are 15.2.3, 14.2.25, 13.5.9, and 12.3.5. Next.js 11 has no patch; block the internal header at the proxy until you upgrade. Apps on Vercel or Netlify, and static exports, are not affected. Check your lockfile version and move authorization into the route or database. Do not probe production with an exploit request.
Last updated · Sekrd Research
- CVE-2025-29927, published March 2025. Authorization bypass if the check lives in Next.js middleware.
- Affected: Next.js >= 11.1.4 and < 12.3.5, >= 13.0.0 and < 13.5.9, >= 14.0.0 and < 14.2.25, >= 15.0.0 and < 15.2.3. Source: the Next.js GitHub advisory GHSA-f82v-jwr5-mffw.
- Not affected: applications hosted on Vercel or Netlify, and static exports (middleware does not run).
- The workaround in the advisory, if you cannot upgrade: prevent external requests that contain the
x-middleware-subrequestheader from reaching Next.js.
What the bug actually is
Next.js middleware runs before a route and is where a lot of generated apps put “redirect to login if there is no cookie.” The framework uses an internal header, x-middleware-subrequest, so that a middleware rewrite does not loop forever. On the affected versions, a request that arrives from the outside with that header set can be treated as an internal subrequest, and middleware does not run. The route then executes with no login redirect.
That matters only when middleware was the thing protecting the route. A Server Action, route handler, or Row Level Security policy that checks the user again still refuses. A page that assumed “middleware already ran” does not.
This page does not include a request that triggers the skip. The header name is public because it is the mitigation: strip it at your reverse proxy. The value that makes a given version skip middleware is an exploit, and you do not need it to find out whether you are affected.
How to check, without an exploit
- Read the installed version from the lockfile, not from a
Serverheader or a guess about the homepage.
npm ls next
You are in the advisory’s range if the version is at least 11.1.4 and below 12.3.5, or 13.x below 13.5.9, or 14.x below 14.2.25, or 15.x below 15.2.3. Later majors are outside this CVE. Confirm against the advisory if you are on a canary.
- See where auth lives. Open
middleware.ts. If it is the only place that checks a session for/dashboard,/admin, or/settings, the CVE is enough to reach those routes on a vulnerable self-hosted deploy. Search route handlers and Server Actions for the same session check. If it is missing, add it. That fix remains correct after you upgrade. - Know your host. The Next.js advisory says deployments on Vercel are protected, and the disclosure notes Netlify is not affected. A Docker container, a VPS, or
output: 'standalone'behind your own proxy is the deployment this CVE describes. v0 apps on Vercel are covered from the hosting side; the same app moved to a VPS is not. More context: securing a v0 app. - Upgrade. 15.2.3, 14.2.25, 13.5.9, or 12.3.5, or any later release in that line. There is no patched 11.x release. Until you can move off Next.js 11, the advisory’s workaround is to drop external requests that contain
x-middleware-subrequestbefore they reach the process. - Optional confirmation belongs in a scanner that already refuses to report a maybe. Sekrd’s deep scan reports CVE-2025-29927 only when the site looks like Next.js, a path is actually behind an auth redirect or a 401/403, and that same path then returns the application rather than a login page, a locale redirect, or a WAF block. A homepage that returns 200 is not a finding. The check does not guess a version from HTML. It is off on a free scan. Details are in the November 2026 scanner update.
What to change in the code either way
Generated apps from v0, Cursor, and similar tools like middleware because it is one file. Keep the redirect for UX. Also call your auth helper at the start of every handler that returns private data, and keep Supabase RLS or Firebase rules on so a skipped middleware returns empty data instead of someone else’s rows. The database half is the RLS checklist.
If you want the version check and the behavior check in one place, start with a free scan for everything the bundle shows, and use a deep scan for the middleware probe. Pricing is on /pricing.
Frequently asked questions
What is CVE-2025-29927?
An authorization bypass in Next.js middleware, advisory GHSA-f82v-jwr5-mffw. On affected self-hosted versions, requests can skip middleware, so login checks that exist only in middleware do not run. Patched versions are 12.3.5, 13.5.9, 14.2.25, and 15.2.3.
Is my Vercel app affected by CVE-2025-29927?
Next.js says deployments hosted on Vercel are automatically protected, and Netlify deployments are not affected. Self-hosted next start or standalone output is affected until you upgrade or strip the x-middleware-subrequest header at the proxy.
How do I check for CVE-2025-29927 without exploiting it?
Run npm ls next and compare to the patched versions in the Next.js advisory. If you are below the patch and middleware is your only auth check, upgrade and also enforce auth in the route handler or with database policies. Do not send a bypass request to production to test it.
Sources
Don't ship until you're sekrd
Run a free scan to find the vulnerabilities your AI missed.
Scan Your App Free