CVE-2022-39386: @fastify/websocket Fastify/websocket Vulnerable To Uncaught Exception Vulnerability
HIGHCVE-2022-39386 is a HIGH (CVSS 7.5) fastify/websocket vulnerable to uncaught exception vulnerability (CWE-248: Uncaught Exception) affecting @fastify/websocket libraries in the npm ecosystem. The issue involves fastify/websocket vulnerable to uncaught exception via crash on malformed packet. Remediation is available by upgrading affected packages to version 5.0.1, 7.1.1.
CVE-2022-39386 at a Glance
Security Impact
CVSS: 7.5
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:N/I:N/A:H).
How to Fix CVE-2022-39386
To remediate this vulnerability, upgrade all affected @fastify/websocket 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 @fastify/websocket@5.0.1
npm install @fastify/websocket@7.1.1
npm install fastify-websocket@Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @fastify/websocket
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-39386, inspect your project dependencies using npm:
npm ls @fastify/websocket
Analyze the terminal output to locate any version of @fastify/websocket in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.0.1), your application is affected.
Note: The npm ls @fastify/websocket 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-248: Uncaught Exception, where an exception is thrown from a function, but it is not caught. In @fastify/websocket, 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-2022-39386 Affected @fastify/websocket Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@fastify/websocket
|
npm |
≥ 5.0.0
< 5.0.1
|
5.0.1
|
|
@fastify/websocket
|
npm |
≥ 6.0.0
< 7.1.1
|
7.1.1
|
|
fastify-websocket
|
npm |
≤ 4.3.0
|
|
References
Frequently Asked Questions
What is CVE-2022-39386?
Which @fastify/websocket versions are affected?
What version fixes CVE-2022-39386?
Is @fastify/websocket affected?
Is fastify-websocket affected?
What is the CVSS score of CVE-2022-39386?
What CWE is associated with CVE-2022-39386?
How can I check npm dependencies for CVE-2022-39386?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-4pcg-wr6c-h9cq",
"modified" : "2022-11-07T21:13:57Z",
"published" : "2022-11-07T21:13:57Z",
"aliases" : [ "CVE-2022-39386" ],
"summary" : "fastify/websocket vulnerable to uncaught exception via crash on malformed packet",
"details" : "### Impact\n\nAny application using @fastify/websocket could crash if a specific, malformed packet is sent. \n\nAll versions of fastify-websocket are also impacted. That module is deprecated, so it will not be patched.\n\n### Patches\n\nThis has been patched in v7.1.1 (fastify v4) and v5.0.1 (fastify v3).\n\n### Workarounds\n\nNo known workaround is available. However, it should be possible to attach the error handler manually.\nThe recommended path is upgrading to the patched versions.\n\n## Credits\n\n[marcolanaro](https://github.com/marcolanaro) for finding and patching this vulnerability\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in [@fastify/websocket](https://github.com/fastify/fastify-websocket)\n* Email us at [hello@matteocollina.com](mailto:hello@matteocollina.com)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@fastify/websocket"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.0.0"
}, {
"fixed" : "5.0.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@fastify/websocket"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "6.0.0"
}, {
"fixed" : "7.1.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "fastify-websocket"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "4.3.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-websocket/security/advisories/GHSA-4pcg-wr6c-h9cq"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-39386"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-websocket/pull/228"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-websocket/commit/7e8c41a51c101c3d5ce88caee4f71d9c29eb2863"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-websocket/commit/c24adeb3efd57a18b2f287c35d029e88b5a47194"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fastify/fastify-websocket"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-websocket/releases/tag/v5.0.1"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-websocket/releases/tag/v7.1.1"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-248" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-11-07T21:13:57Z",
"nvd_published_at" : "2022-11-08T22:15:00Z"
}
}