Skip to content
Access control Write-up Intermediate

Hack Next.js with this Exploit

A header used internally by Next.js middleware could be supplied by an attacker to make the middleware skip its checks, allowing access to protected routes such as admin pages. The same flaw could also bypass middleware-set security headers and enable cache-poisoning denial of service on sites with a cache.

medium.com

Published on medium.com

This zero day exploit for Next.js middleware, CVE-2025–29927 is incredible. Its severity score is 9.1/10, and was only patched about 10 days after the vuln was accepted by the Vercel team (primary maintainers for the Next.js package).

David Merian, 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 request header intended only for internal sub-requests, so an external request carrying that header was treated as already handled and skipped.

Impact

An attacker could bypass middleware-based authentication and authorisation to reach protected pages, bypass middleware-set CSP and cookies, and potentially cause cache-poisoning denial of service where a cache or CDN is present.

What the attacker needed

Target runs a vulnerable Next.js version; site uses middleware for auth or headers

The fix

The issue was fixed in Next.js 15.2.3 and 14.2.25, and for older versions a workaround is to block external requests carrying the internal sub-request header.

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. Its 'middleware' is a checkpoint that runs before a page is shown, often used to check whether someone is logged in. The bug meant a visitor could add a special header to their request that told the checkpoint to skip itself, so protected pages could be reached without logging in.

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.