CVE-2024-38355: Socket.io Socket.io Has An Unhandled 'error' Vulnerability
MODERATECVE-2024-38355 is a MODERATE (CVSS 7.3) socket.io has an unhandled 'error' vulnerability (CWE-20: Improper Input Validation) affecting Socket.io libraries in the npm ecosystem. The issue involves socket.io has an unhandled 'error' event. Remediation is available by upgrading affected packages to version 2.5.1, 4.6.2.
CVE-2024-38355 at a Glance
Security Impact
CVSS: 7.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L).
How to Fix CVE-2024-38355
To remediate this vulnerability, upgrade all affected Socket.io dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install socket.io@2.5.1
npm install socket.io@4.6.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls socket.io
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-38355, inspect your project dependencies using npm:
npm ls socket.io
Analyze the terminal output to locate any version of Socket.io in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.5.1), your application is affected.
Note: The npm ls socket.io command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Socket.io, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-38355 Affected Socket.io Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
socket.io
|
npm |
< 2.5.1
|
2.5.1
|
|
socket.io
|
npm |
≥ 3.0.0
< 4.6.2
|
4.6.2
|
References
Frequently Asked Questions
What is CVE-2024-38355?
Which Socket.io versions are affected?
What version fixes CVE-2024-38355?
Is socket.io affected?
What is the CVSS score of CVE-2024-38355?
What CWE is associated with CVE-2024-38355?
How can I check npm dependencies for CVE-2024-38355?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-25hc-qcg6-38wj",
"modified" : "2026-09-24T14:45:25Z",
"published" : "2024-06-19T15:04:41Z",
"aliases" : [ "CVE-2024-38355" ],
"summary" : "socket.io has an unhandled 'error' event",
"details" : "### Impact\n\nA specially crafted Socket.IO packet can trigger an uncaught exception on the Socket.IO server, thus killing the Node.js process.\n\n```\nnode:events:502\n throw err; // Unhandled 'error' event\n ^\n\nError [ERR_UNHANDLED_ERROR]: Unhandled error. (undefined)\n at new NodeError (node:internal/errors:405:5)\n at Socket.emit (node:events:500:17)\n at /myapp/node_modules/socket.io/lib/socket.js:531:14\n at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {\n code: 'ERR_UNHANDLED_ERROR',\n context: undefined\n}\n```\n\n### Affected versions\n\n| Version range | Needs minor update? |\n|------------------|------------------------------------------------|\n| `4.6.2...latest` | Nothing to do |\n| `3.0.0...4.6.1` | Please upgrade to `socket.io@4.6.2` (at least) |\n| `2.3.0...2.5.0` | Please upgrade to `socket.io@2.5.1` |\n\n### Patches\n\nThis issue is fixed by https://github.com/socketio/socket.io/commit/15af22fc22bc6030fcead322c106f07640336115, included in `socket.io@4.6.2` (released in May 2023).\n\nThe fix was backported in the 2.x branch today: https://github.com/socketio/socket.io/commit/d30630ba10562bf987f4d2b42440fc41a828119c\n\n### Workarounds\n\nAs a workaround for the affected versions of the `socket.io` package, you can attach a listener for the \"error\" event:\n\n```js\nio.on(\"connection\", (socket) => {\n socket.on(\"error\", () => {\n // ...\n });\n});\n```\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n- Open a discussion [here](https://github.com/socketio/socket.io/discussions)\n\nThanks a lot to [Paul Taylor](https://github.com/Y0ursTruly) for the responsible disclosure.\n\n### References\n\n- https://github.com/socketio/socket.io/commit/15af22fc22bc6030fcead322c106f07640336115\n- https://github.com/socketio/socket.io/commit/d30630ba10562bf987f4d2b42440fc41a828119c",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "socket.io"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.5.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "socket.io"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.0"
}, {
"fixed" : "4.6.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/socketio/socket.io/security/advisories/GHSA-25hc-qcg6-38wj"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-38355"
}, {
"type" : "WEB",
"url" : "https://github.com/socketio/socket.io/commit/15af22fc22bc6030fcead322c106f07640336115"
}, {
"type" : "WEB",
"url" : "https://github.com/socketio/socket.io/commit/d30630ba10562bf987f4d2b42440fc41a828119c"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/socketio/socket.io"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-20", "CWE-754" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-06-19T15:04:41Z",
"nvd_published_at" : "2024-06-19T20:15:11Z"
}
}