CVE-2024-38355: Unhandled 'error' event in socket.io
Impact
A specially crafted Socket.IO packet can trigger an uncaught exception on the Socket.IO server, thus killing the Node.js process.
node:events:502 throw err; // Unhandled 'error' event ^
Error [ERRUNHANDLEDERROR]: Unhandled error. (undefined) at new NodeError (node:internal/errors:405:5) at Socket.emit (node:events:500:17) at /myapp/nodemodules/socket.io/lib/socket.js:531:14 at process.processTicksAndRejections (node:internal/process/taskqueues:77:11) { code: 'ERRUNHANDLEDERROR', context: undefined }
Affected versions
| Version range | Needs minor update? | |------------------|------------------------------------------------| | 4.6.2...latest | Nothing to do | | 3.0.0...4.6.1 | Please upgrade to socket.io@4.6.2 (at least) | | 2.3.0...2.5.0 | Please upgrade to socket.io@2.5.1 |
Patches
This issue is fixed by https://github.com/socketio/socket.io/commit/15af22fc22bc6030fcead322c106f07640336115, included in socket.io@4.6.2 (released in May 2023).
The fix was backported in the 2.x branch today: https://github.com/socketio/socket.io/commit/d30630ba10562bf987f4d2b42440fc41a828119c
Workarounds
As a workaround for the affected versions of the socket.io package, you can attach a listener for the "error" event:
js io.on("connection", (socket) => { socket.on("error", () => { // ... }); });
For more information
If you have any questions or comments about this advisory:
- Open a discussion here
Thanks a lot to Paul Taylor for the responsible disclosure.
References
- https://github.com/socketio/socket.io/commit/15af22fc22bc6030fcead322c106f07640336115 - https://github.com/socketio/socket.io/commit/d30630ba10562bf987f4d2b42440fc41a828119c
Other sources
Socket.IO is an open source, real-time, bidirectional, event-based, communication framework. A specially crafted Socket.IO packet can trigger an uncaught exception on the Socket.IO server, thus killing the Node.js process. This issue is fixed by commit 15af22fc22 which has been included in socket.io@4.6.2 (released in May 2023). The fix was backported in the 2.x branch as well with commit d30630ba10. Users are advised to upgrade. Users unable to upgrade may attach a listener for the "error" event to catch these errors.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/socket.ioto a version that resolves this vulnerability.Fixed in 4.6.2 - Upgrade
Upgrade
npm/socket.ioto a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
socket.ioto a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
socket.ioto a version that resolves this vulnerability.Fixed in 4.6.2 - Compensating control
If unable to upgrade, attach a listener for the "error" event on each Socket.IO socket, such as socket.on("error", () => { ... });, to catch the errors and prevent the uncaught exception from killing the Node.js process.
Event History
Frequently Asked Questions
What is the severity of CVE-2024-38355?
CVE-2024-38355 is classified as a vulnerability that can cause a denial of service by crashing the Node.js process.
How do I fix CVE-2024-38355?
To fix CVE-2024-38355, upgrade to Socket.IO version 4.6.2 or newer, or 2.5.1 if using an older version.
What versions of Socket.IO are affected by CVE-2024-38355?
CVE-2024-38355 affects Socket.IO versions from 3.0.0 up to, but not including, 4.6.2, and all versions below 2.5.1.
What kind of attacks can CVE-2024-38355 enable?
CVE-2024-38355 can enable denial of service attacks through specially crafted Socket.IO packets that lead to an uncaught exception.
What are the consequences of not addressing CVE-2024-38355?
Failing to address CVE-2024-38355 could lead to service interruptions due to unexpected crashes of the Node.js server.