Am I affected by the Next.js middleware bypass (CVE-2025-29927)?
You are affected if you self-host Next.js between 11.1.4 and 15.2.2 and rely on middleware for authorization. A request with the x-middleware-subrequest header could skip middleware entirely. Upgrade to a fixed version, or strip that header at your proxy.
What is CVE-2025-29927?
It is an authorization bypass in Next.js middleware. Next.js uses an internal header called x-middleware-subrequest to stop middleware from calling itself in a loop. If a request from the outside carried that header, Next.js could skip the middleware. Any login check, role check or redirect that lived only in middleware would not run.
Which versions are affected?
Self-hosted Next.js from 11.1.4 through 15.2.2, when the app uses middleware for authorization. The fixed versions are:
- 12.3.5
- 13.5.9
- 14.2.25
- 15.2.3
Are Vercel and Netlify apps affected?
No. Apps hosted on Vercel or Netlify were not affected. Static exports were not affected either, because they have no middleware at runtime. The risk is for apps you run yourself with next start, in a container or on a VM.
How do I check my version?
npx next --version
# or
npm ls nextIf the version is inside the affected range and you self-host, check whether your middleware.ts protects anything. If it does, upgrade.
How do I fix it?
- Upgrade to the fixed release for your line, or to a current version. For example,
npm install next@14.2.25if you are on 14.x. - Redeploy and confirm the version in the running app.
- Check the data behind your protected routes. Add an auth check where the data is read, not only in middleware.
Moving to a newer major version is also a good idea. Versions 13.x and 14.x no longer get security fixes, so the next bug will not be patched for you.
What if I cannot upgrade today?
Strip the header from incoming requests at your reverse proxy or CDN, so it never reaches Next.js. In nginx, an empty value stops the header from being passed on:
location / {
proxy_set_header x-middleware-subrequest "";
proxy_pass http://localhost:3000;
}Treat this as a stopgap. Upgrade as soon as you can. Our free scan also reports your Next.js version and known advisories. The deep scan in the $6 full report tests the middleware bypass on sites you own.
Check your app
The free scan reads only what a browser downloads and takes under a minute. For a person to review your code, there is a human audit.