Critical Authorization Bypass Vulnerability in Nextjs (CVE-2025-29927)

Listen to this Post

The Next.js team has disclosed a critical authorization bypass vulnerability in Next.js versions before 14.2.25 and 15.2.3. This vulnerability, identified as CVE-2025-29927, allows attackers to bypass authorization by simply passing a specific header to the web server. If authorization is supposed to occur in middleware, it will be bypassed entirely. This issue is trivial to exploit and has been rated as a CVSS 9.1, indicating its high severity.

To help identify and mitigate this vulnerability, a Nuclei template has been created to scan web applications for CVE-2025-29927. The repository for this template can be found here: Nuclei Template for CVE-2025-29927.

For more details on the original research, visit: Next.js and the Corrupt Middleware.

You Should Know:

1. How to Identify the Vulnerability

To check if your Next.js application is vulnerable, you can use the Nuclei template provided. Below are the steps to run the scan:

1. Install Nuclei (if not already installed):

go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest

2. Run the Nuclei Scan:

nuclei -t https://github.com/6mile/nextjs-CVE-2025-29927 -u <your-target-url>

3. Interpret the Results:

  • If the scan returns a positive result, your application is vulnerable.
  • Immediately update your Next.js version to 14.2.25 or 15.2.3.

2. Mitigation Steps

To mitigate this vulnerability, follow these steps:

1. Update Next.js:

Update your Next.js application to the latest patched version:

npm install next@latest

2. Verify Middleware Authorization:

Ensure that your middleware is correctly validating authorization headers. Example middleware code:

import { NextResponse } from 'next/server';

export function middleware(request) {
const authHeader = request.headers.get('authorization');
if (!authHeader || authHeader !== 'valid-token') {
return NextResponse.redirect(new URL('/unauthorized', request.url));
}
return NextResponse.next();
}

3. Test Your Application:

After updating, re-run the Nuclei scan to confirm the vulnerability is resolved.

3. Additional Security Measures