Skip to content
Access control Write-up Beginner

How One Header Broke Next.js Auth — CVE-2025–29927

Next.js middleware-based authorization checks could be bypassed by sending a crafted internal header, allowing an attacker to reach protected pages without logging in. The author demonstrates this on two lab applications, reaching a protected events page and a hidden create endpoint.

medium.com

Published on medium.com

This vulnerability allows attackers to bypass middleware-based authorization checks by exploiting improper validation of the internal x-middleware-subrequest header. By injecting this header into HTTP requests, malicious actors can circumvent middleware logic responsible for critical tasks like authentication and…

#$ubh@nk@r, 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 trusted a client-supplied internal header (x-middleware-subrequest) without validating that it originated from the framework itself, so requests could skip the authorization logic.

Impact

An attacker could bypass middleware authorization and access protected pages and endpoints without authenticating, potentially exposing sensitive content.

What the attacker needed

Target runs a vulnerable Next.js version; authorization enforced only in middleware

The fix

The vulnerability was fixed in later Next.js releases (12.3.5, 13.5.9, 14.2.25 and 15.2.3), so upgrading resolves it.

How it was found

  1. Identify the Next.js version of the target application.
  2. Send a request to a protected page with the internal middleware header added.
  3. Observe the response change from a redirect to a successful page load, indicating the login was bypassed.
  4. Browse to other protected paths such as the events page to read disclosed content.
  5. Inspect JavaScript files to find additional endpoints such as the create page.
  6. Request the newly found endpoint to retrieve further protected content.

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 framework for building websites. It can run a 'middleware' check before showing a page, like a guard at a door. The bug meant a request could carry a special internal header that made the guard think the request was already checked, so it let the visitor through without a login.

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.