Skip to content
Access control Write-up Intermediate

How Hackers Exploit CVE-2025–29927 in Next.js Like a Pro

Next.js middleware could be bypassed by sending a crafted header, allowing attackers to reach protected routes without authentication. The article demonstrates how to identify vulnerable instances and exploit the flaw to access admin dashboards.

medium.com

Published on medium.com

CVE-2025–29927 is a critical vulnerability found in Next.js, the open-source web framework by Vercel that powers React based applications. It allows attackers to bypass middleware authorization, gaining access to protected resources without proper authentication.

𝙇𝙤𝙨𝙩𝙨𝙚𝙘, 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 failed to properly validate or strip the x-middleware-subrequest header, allowing an attacker to trick the server into thinking the request was an internal subrequest and skip authorization checks.

Impact

Attackers could gain unauthorized access to protected resources, potentially leading to data exposure, privilege escalation, or full application compromise.

What the attacker needed

Target runs a vulnerable Next.js version; Protected endpoint relies on middleware for auth

The fix

Upgrade Next.js to a patched version (15.2.3, 14.2.25, 13.5.9, or 12.3.5) as recommended in the official security advisory.

How it was found

  1. Identify if the target uses Next.js and check its version using tools like Wappalyzer or response headers.
  2. Locate a protected endpoint such as an admin dashboard and confirm it redirects to login.
  3. Send a request to the protected endpoint with a crafted x-middleware-subrequest header to bypass authentication.
  4. For mass hunting, search Shodan for the x-middleware-rewrite header to find potentially vulnerable hosts.
  5. Extract domains or IPs from Shodan results and run a Nuclei template to scan for the vulnerability.

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. Middleware is a checkpoint that checks if you are allowed in before showing a page. This bug let someone skip that checkpoint by adding a special header to their request, so they could see pages meant only for logged-in users.

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.