SecPod

Learn Search

Search across all Learn content

← Back to Security Research
Next Blunder: Next.js Users Urged to Patch Critical Security Flaw

Next Blunder: Next.js Users Urged to Patch Critical Security Flaw

A severe vulnerability tracked as CVE-2025-29927, with a CVSS score of 9.1, has been identified in the Next.js React framework. If exploited, it could result in an authentication bypass under specific conditions.

Mar 24, 2025By Santosh Sethuraman4 min read

A severe vulnerability tracked as CVE-2025-29927, with a CVSS score of 9.1, has been identified in the Next.js React framework. If exploited, it could result in an authentication bypass under specific conditions.

Next.js is a framework based on React that enables fast and scalable web application development. It supports server-side rendering (SSR), static site generation (SSG), and API routes. Created by Vercel, it provides automatic code splitting, image optimization, and built-in routing, rendering it perfect for contemporary web development with enhanced performance and SEO advantages.

Technical Details

As a comprehensive framework, Next.js includes built-in middleware that is key in authorization checks. It verifies session cookies and grants users the necessary permissions, ensuring access to specific paths remains protected under the required conditions.

The runMiddleware function in Next.js middleware checks the header’s value to determine whether middleware should be applied. If the correct value is added to this header, the request can bypass intermediary checks, overriding security rules. To exploit this, we need to identify the correct middlewareInfo.name. But how do we find it?

Surprisingly, middlewareInfo.name is highly predictable. To make an educated guess, we first must understand how middleware was configured in older versions.

Older Versions (Before Next.js 12.2)

Before version 12.2, middleware files had to be named _middleware.ts and placed inside the pages folder since the page router was the only available routing mechanism. Knowing this, we can construct a header that bypasses authorization checks entirely:

plaintext
middleware-subrequest: pages/_middleware

If the middleware is used in nested paths, it runs top-to-bottom. We have two additional possibilities for the middlewareInfo to access a path protected by middleware. name value. These values, when passed in the x-middleware-subrequest Header, also allow authorization bypass:

plaintext
middleware-subrequest: pages/dashboard/_middleware

or

plaintext
middleware-subrequest: pages/dashboard/panel/_middleware

Next.js 12.2 and Later

Starting with version 12.2, middleware files no longer require an underscore in their name, nor do they need to be placed inside the pages folder. This simplifies the exploitation process. However, newer versions introduce the option to create a /src directory. Taking both scenarios into account, the header should look like one of the following:

plaintext
middleware-subrequest: middleware

or

plaintext
middleware-subrequest: src/middleware

Recent Versions and MAX_RECURSION_DEPTH

In more recent versions, an additional factor comes into play: MAX_RECURSION_DEPTH, which is set to 5 by default. Since there are only two possible filenames (middleware or src/middleware), we can construct a header that takes advantage of this recursion limit:

plaintext
middleware-subrequest: middleware:middleware:middleware:middleware:middleware

or

plaintext
middleware-subrequest: src/middleware:src/middleware:src/middleware:src/middleware:src/middleware

Final Exploitation Step

If we try to access a middleware-protected endpoint without using the correct header value or valid credentials, the request will return a 404 Not Found error. However, if we include the appropriate header in our request, we can bypass authentication and gain access.

Impact

The impact of this vulnerability is highly severe. They grant attackers full system access, which could allow them to obtain or modify sensitive data. The risk is further heightened by the attack’s low complexity.

Products Affected

The vulnerability impacts all Next.js versions before 15.2.3, 14.2.25, 13.5.9. and versions above 11.1.4 before 13.5.6.

Solution and Mitigation

For Next.js 14.x, this issue is fixed in 14.2.25. For Next.js 15.x, this issue is fixed in 15.2.3. For Next.js versions 11.1.4 through 13.5.6, we recommend consulting the workaround below.

Workaround

If updating to a secure version is not an option, we recommend blocking external user requests that include the x-middleware-subrequest header from reaching your Next.js application.

Instantly Fix Risks with SanerNow Patch Management

SanerNow patch management is a continuous, automated, and integrated software that instantly fixes risks exploited in the wild. The software supports major operating systems like Windows, Linux, and macOS, as well as 550+ third-party applications.

It also allows you to set up a safe testing area to test patches before deploying them in a primary production environment. SanerNow patch management additionally supports a patch rollback feature in case of patch failure or a system malfunction.

Experience the fastest and most accurate patching software here.

Featured Posts

Open Root-Level RCE Flaw in Cisco Nexus 9000 Series Switches Exposes Networks to Complete Compromise — CVE-2026-20212
Root-Level RCE Flaw in Cisco Nexus 9000 Series Switches Exposes Networks to Complete Compromise — CVE-2026-20212

CVE Research

Root-Level RCE Flaw in Cisco Nexus 9000 Series Switches Exposes Networks to Complete Compromise — CVE-2026-20212

CVE-2026-20212 is a critical vulnerability in Cisco Nexus 9000 Series Switches that use Silicon One ASICs. It allows an unauthenticated remote attacker to execute code with root privileges by sending crafted input to TCP ports 43210 and 43211, which are reachable in the default Layer 3 VRF. Exploitation can also crash the S1HAL process and force a device reload. This article covers how the vulnerability works, the affected product identifiers, its potential impact, available workarounds, and how to identify fixed software using the Cisco Software Checker.

Sep 4, 2026

Open SonicWall SMA 1000 Under Active Attack: Two Zero-Days Enable SSRF and Remote Code Execution
SonicWall SMA 1000 Under Active Attack: Two Zero-Days Enable SSRF and Remote Code Execution

CVE Research

SonicWall SMA 1000 Under Active Attack: Two Zero-Days Enable SSRF and Remote Code Execution

Sep 3, 2026

Open Introducing SecPod VEX Studio: Guided Vulnerability Exploitability Assessment for Open-Source Maintainers
Secpod_VEX_Studio For Open-Source Vulnerability Management

CVE Research

Introducing SecPod VEX Studio: Guided Vulnerability Exploitability Assessment for Open-Source Maintainers

A human-guided path from SBOM and vulnerability data to reviewable OpenVEX statements

Sep 2, 2026

Open Inside the PaperCut Zero-Day Attack Chain: Auth Bypass to Code Execution
Inside the PaperCut Zero-Day Attack Chain: Auth Bypass to Code Execution

CVE Research

Inside the PaperCut Zero-Day Attack Chain: Auth Bypass to Code Execution

Sep 1, 2026