
CVE-2025-29927 Proof of Concept
This repository demonstrates the CVE-2025-29927 vulnerability in Next.js where the internal header x-middleware-subrequest can be used to bypass middleware checks like authentication.
Next.js uses an internal header x-middleware-subrequest to prevent recursive requests from triggering infinite loops. The security vulnerability shows it's possible to skip running Middleware, which could allow requests to bypass critical checks—such as authorization cookie validation—before reaching routes.
npm installnpm run buildnode .next/standalone/server.jsnode exploit-test.jsThe exploit adds the x-middleware-subrequest: middleware header to bypass Next.js middleware authentication checks.
The middleware in this demo app redirects unauthenticated users away from protected routes, but with the exploit header, this check can be bypassed.
Update to one of the following patched versions: