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

Goal: 1000 CNY · Raised: 1310 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
CVE-2025-29927 Exploit Checker
Readme
# Next.js Middleware Bypass Checker

Herramienta automatizada en Bash para detectar aplicaciones Next.js vulnerables al **bypass de middleware** (CVE-2025-29927), según la investigación de Zhero Web Security.


## Requisitos

- `bash`
- [`whatweb`](https://github.com/urbanadventurer/WhatWeb)
- `curl`

Instálalos en Debian/Ubuntu con:

```bash
sudo apt install whatweb curl
```

---

## Uso

### Escanear una sola URL

```bash
./CVE-2025-29927.sh -u https://example.com
```

### Escanear múltiples URLs

Crea un archivo `urls.txt` con una URL por línea:

```txt
https://target1.com
https://target2.com
```

Ejecuta:

```bash
./nextjs_bypass_checker_v2.sh -l urls.txt
```

---

## Qué hace el script

1. **Identificación de Next.js**
   - Usa `whatweb` para detectar la tecnología.
   - Intenta leer `/_next/static/BUILD_ID` y `_buildManifest.js`.

2. **Detección de Middleware**
   - Verifica si el servidor responde con cabeceras típicas del middleware de Next.js.
     - `X-Middleware-Rewrite`
     - `X-Middleware-Set-Cookie`

3. **Prueba de bypass**
   - Se realiza una solicitud sin `x-middleware-subrequest` y se detectan cabeceras.
   - Luego se repite la solicitud usando los vectores conocidos con el header.
   - Si las cabeceras desaparecen, el middleware fue **bypasseado exitosamente**.

---

## Salida esperada

```bash
[*] Analizando: https://victima.com
[+] WhatWeb:
    -> Detectado: Next.js[12.2.0]
[+] BUILD_ID: 3fjd92hf8
[+] Versión detectada: 12.2.0
[+] Middleware activo (cabeceras detectadas):
    X-Middleware-Rewrite: /not-found/locale=en
[+] Probando exploits:
    -> x-middleware-subrequest: middleware -> ✅ BYPASS EXITOSO (cabeceras desaparecieron)
    -> x-middleware-subrequest: src/middleware -> ❌ Middleware no evadido
[*] Finalizado: https://victima.com
```

---

## Disclaimer

**Este script es para fines educativos y de auditoría autorizada.** No lo utilices contra objetivos sin consentimiento. El uso indebido puede constituir una actividad ilegal.

---

## Autor

- Roy Campos Vasquez — [@RoyCampos](https://github.com/RoyCampos)

Basado en la investigación de: [Zhero Web Security](https://zhero-web-sec.github.io/research-and-things/nextjs-and-the-corrupt-middleware)
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 →