Skip to content
Access control Write-up Intermediate

Critical Next.js Vulnerability (CVE-2025–29927) Allows Middleware Bypass — Patch Now!

A critical vulnerability in Next.js allows attackers to bypass middleware authorization checks by manipulating an internal header, potentially granting unauthorized access to protected routes. The flaw affects self-hosted applications using middleware, and patched versions have been released.

Jordilla Follow

Published on osyrisvm.medium.com

A critical security vulnerability, designated as CVE-2025–29927, has been identified in Next.js, a widely used React framework for building web applications. This flaw allows attackers to bypass middleware authorization checks, potentially granting unauthorized access to sensitive areas within applications.

Jordilla, on osyrisvm.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

The vulnerability arises because the internal header used to prevent recursive requests can be manipulated to skip middleware execution.

Impact

Attackers could bypass authorization checks and gain unauthorized access to sensitive areas within applications, but only self-hosted apps using middleware are affected; those on Vercel, Netlify, or static exports are not.

What the attacker needed

Self-hosted Next.js app; uses middleware; deployed with next start; output: 'standalone'

The fix

The vulnerability was fixed by updating Next.js to patched versions (15.2.3, 14.2.25, 13.5.9, 12.3.5); if updating is not possible, block external requests containing the x-middleware-subrequest 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 tool for building websites. It has a security feature called middleware that checks if you're allowed to see certain pages. This bug lets attackers trick the system into skipping those checks, so they can see pages they shouldn't. It's like a guard who can be fooled into letting you into a restricted area.

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.

More by Jordilla

View all

5 more disclosed reports, best first.

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.