
This repository contains a proof of concept for CVE-2025-29927 vulnerability in Next.js, where the internal header x-middleware-subrequest can be exploited to bypass middleware checks such as authentication.
🧪 This project was tested with Next.js v13.4.19.
git clone https://github.com/goncalocsousa1/CVE-2025-29927.git
cd CVE-2025-29927
npm install
npm run dev
http://localhost:3000
The application demonstrates a simple authentication system with a protected route that can be bypassed using the CVE-2025-29927 vulnerability. Here's how it works:
Home Page (/)
auth-token)Protected Page (/protected)
auth-token cookieMiddleware Protection
auth-token cookie/protected/* routes, redirects to home pageVulnerability Demonstration
x-middleware-subrequest header can be exploitedauth-token cookie, attackers can access protected routesThis application includes a protected route at /protected that normally requires authentication. However, by using the header x-middleware-subrequest: middleware in a request like curl -H "x-middleware-subrequest: middleware" http://localhost:3000/protected, you can bypass the authentication check.
You can also reproduce this behavior using Burp Suite by intercepting the request and manually adding the header.
To try this with Burp Suite, open the Proxy tab and go to the Intercept sub-tab. Make sure Intercept is On, then click on Open Browser and navigate to the protected route: http://localhost:3000/protected

Burp Suite will capture the request to the protected route. From there, add the following header: x-middleware-subrequest: middleware (highlighted in the screenshot above). Finally, forward the request and access the protected route.

Update to one of the following patched versions: