Skip to main content

CVE-2022-39386: CWE-248: Uncaught Exception in fastify fastify-websocket

Medium
Published: Tue Nov 08 2022 (11/08/2022, 00:00:00 UTC)
Source: CVE
Vendor/Project: fastify
Product: fastify-websocket

Description

@fastify/websocket provides WebSocket support for Fastify. Any application using @fastify/websocket could crash if a specific, malformed packet is sent. All versions of fastify-websocket are also impacted. That module is deprecated, so it will not be patched. This has been patched in version 7.1.1 (fastify v4) and version 5.0.1 (fastify v3). There are currently no known workarounds. However, it should be possible to attach the error handler manually. The recommended path is upgrading to the patched versions.

AI-Powered Analysis

AILast updated: 06/22/2025, 14:22:13 UTC

Technical Analysis

CVE-2022-39386 is a medium-severity vulnerability affecting the @fastify/websocket module, which provides WebSocket support for the Fastify web framework. The vulnerability arises from an uncaught exception (CWE-248) triggered when the module processes a specific malformed WebSocket packet. This unhandled exception can cause the entire Fastify application to crash, resulting in a denial of service (DoS). The issue affects all versions of the deprecated @fastify/websocket module, as well as certain versions of Fastify v3 and v4 that include this module. Specifically, affected versions include >=5.0.0 and <5.0.1, >=6.0.0 and <7.1.1, and versions <=4.3.0. The vulnerability was patched in Fastify v4.7.1 and Fastify v3.5.1 (note: the provided data states 7.1.1 and 5.0.1, which likely correspond to module versions). Since the @fastify/websocket module is deprecated and will not receive patches, the recommended mitigation is to upgrade to the patched Fastify versions that include a fixed websocket module. No known exploits are currently reported in the wild. There are no official workarounds, but it is possible to manually attach an error handler to catch the exception and prevent the crash. The vulnerability primarily impacts the availability of applications using the affected websocket module, as the uncaught exception leads to application termination. Exploitation requires sending a specially crafted malformed WebSocket packet, which does not require authentication but does require the application to expose a WebSocket endpoint using the vulnerable module. User interaction is not needed beyond the network-level WebSocket connection. This vulnerability highlights the risk of relying on deprecated modules and the importance of timely upgrades to patched versions.

Potential Impact

For European organizations, the primary impact of CVE-2022-39386 is the potential for denial of service on web applications using Fastify with the vulnerable websocket module. This can disrupt business operations, degrade service availability, and potentially cause financial and reputational damage. Organizations that rely on real-time communication features via WebSockets, such as financial services, e-commerce platforms, and telecommunications providers, may experience service interruptions. The vulnerability does not directly compromise confidentiality or integrity but can indirectly affect trust and operational continuity. Since the vulnerability can be triggered remotely without authentication, it increases the attack surface for external threat actors. European organizations with public-facing Fastify-based applications are at risk, especially if they have not upgraded to patched versions or implemented error handling. The lack of known exploits reduces immediate risk, but the ease of triggering the crash means opportunistic attackers could cause disruptions. Additionally, critical infrastructure sectors that use Fastify for WebSocket communication may face increased operational risk. The impact is more pronounced in sectors with stringent availability requirements, such as healthcare, finance, and government services.

Mitigation Recommendations

1. Upgrade all Fastify applications to the latest patched versions: Fastify v4.7.1 or later and Fastify v3.5.1 or later, which include fixes for the websocket module vulnerability. Avoid using the deprecated @fastify/websocket module. 2. If immediate upgrade is not feasible, implement manual error handling for the websocket connections to catch and handle exceptions gracefully, preventing application crashes. 3. Conduct an inventory of all applications using Fastify and identify those exposing WebSocket endpoints with the vulnerable module. 4. Employ Web Application Firewalls (WAFs) or network-level filtering to detect and block malformed WebSocket packets that could trigger the vulnerability. 5. Monitor application logs and network traffic for unusual WebSocket connection attempts or malformed packets indicative of exploitation attempts. 6. Integrate vulnerability scanning and dependency management tools in the CI/CD pipeline to detect usage of deprecated or vulnerable Fastify modules. 7. Educate development teams about the risks of using deprecated modules and the importance of timely patching and secure coding practices. 8. For critical services, consider implementing redundancy and failover mechanisms to minimize downtime in case of application crashes.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-09-02T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9846c4522896dcbf4a03

Added to database: 5/21/2025, 9:09:26 AM

Last enriched: 6/22/2025, 2:22:13 PM

Last updated: 8/11/2025, 3:27:04 PM

Views: 14

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats