Skip to content
Access control Write-up Intermediate

The CVE-2025–29927 with Next.Js framework with 9.1 CRITICAL Sco

Next.js middleware could be bypassed by sending a crafted x-middleware-subrequest header, allowing attackers to skip authentication and access protected pages. The vulnerability affects versions from 11.1.4 up to 13.5.6, and also newer versions like 15.1.7.

Prashant kamkar Follow

Published on medium.com

On 23 March 2025, security researcher Rachid published a blog post covering the critical security vulnerability in the Next.js app, which has a 9.1 base critical score. The following Next.js version is vulnerable to this attack if you are using it, upgrade it.

Prashant kamkar, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, the middleware incorrectly trusts a client-supplied header (x-middleware-subrequest) to decide whether to run, allowing an attacker to skip security checks by setting that header to the middleware's name.

Impact

An attacker could bypass authentication to access protected pages, ignore security headers like CSP, and potentially cause denial of service via cache poisoning.

What the attacker needed

Next.js app using middleware for auth; Attacker can send HTTP requests

The fix

The vulnerability was fixed in Next.js 15.2.3 and 14.2.25; users should upgrade and avoid relying solely on middleware for authentication.

How it was found

  1. Identify the middleware name used in the target Next.js application (e.g., 'middleware' or 'src/middleware').
  2. Send a request to a protected page with the x-middleware-subrequest header set to the middleware name.
  3. For newer versions, repeat the middleware name five times separated by colons in the header value.
  4. Observe that the request bypasses the middleware and reaches the protected page.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Next.js is a tool for building websites. It has a 'middleware' feature that acts like a security guard, checking requests before they reach a page. This bug lets an attacker trick the guard into ignoring the request by adding a special header, so they can reach pages they shouldn't, like an admin dashboard.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.