Skip to main content

CVE-2022-35922: CWE-400: Uncontrolled Resource Consumption in websockets-rs rust-websocket

Medium
Published: Mon Aug 01 2022 (08/01/2022, 21:35:11 UTC)
Source: CVE
Vendor/Project: websockets-rs
Product: rust-websocket

Description

Rust-WebSocket is a WebSocket (RFC6455) library written in Rust. In versions prior to 0.26.5 untrusted websocket connections can cause an out-of-memory (OOM) process abort in a client or a server. The root cause of the issue is during dataframe parsing. Affected versions would allocate a buffer based on the declared dataframe size, which may come from an untrusted source. When `Vec::with_capacity` fails to allocate, the default Rust allocator will abort the current process, killing all threads. This affects only sync (non-Tokio) implementation. Async version also does not limit memory, but does not use `with_capacity`, so DoS can happen only when bytes for oversized dataframe or message actually got delivered by the attacker. The crashes are fixed in version 0.26.5 by imposing default dataframe size limits. Affected users are advised to update to this version. Users unable to upgrade are advised to filter websocket traffic externally or to only accept trusted traffic.

AI-Powered Analysis

AILast updated: 06/23/2025, 00:35:35 UTC

Technical Analysis

CVE-2022-35922 is a vulnerability classified under CWE-400 (Uncontrolled Resource Consumption) affecting the Rust-WebSocket library, specifically versions prior to 0.26.5. Rust-WebSocket is a Rust implementation of the WebSocket protocol (RFC6455), used to establish full-duplex communication channels over a single TCP connection. The vulnerability arises in the synchronous (sync) implementation of the library during the parsing of WebSocket data frames. When processing incoming frames, the library allocates a buffer based on the declared size of the frame, which is derived from untrusted input. If an attacker crafts a frame with an excessively large size, the library attempts to allocate a correspondingly large buffer using Rust's Vec::with_capacity method. Should this allocation fail due to insufficient memory, the default Rust allocator triggers a process abort, terminating the entire process and all its threads. This results in a denial-of-service (DoS) condition. The asynchronous (async) implementation, which does not use Vec::with_capacity, does not abort on allocation failure but still lacks memory limits, allowing DoS only if the attacker can deliver the oversized frame bytes. The issue was addressed in version 0.26.5 by imposing default limits on the maximum allowed data frame size, preventing uncontrolled memory allocation. Users running vulnerable versions are advised to upgrade to 0.26.5 or later. If upgrading is not feasible, mitigating controls include filtering WebSocket traffic externally or restricting connections to trusted sources to prevent exploitation. No known exploits have been reported in the wild to date.

Potential Impact

The primary impact of this vulnerability is a denial-of-service condition caused by uncontrolled memory allocation leading to process termination. For European organizations utilizing the Rust-WebSocket library in their synchronous WebSocket servers or clients, this could result in service outages, disrupting real-time communication channels critical for web applications, IoT devices, or internal messaging systems. The abrupt process abort can cause downtime, loss of availability, and potential cascading failures if the WebSocket service is integral to broader application workflows. While confidentiality and integrity are not directly compromised, the availability impact can affect business continuity, especially for sectors relying on real-time data exchange such as finance, telecommunications, and critical infrastructure. The async implementation is less susceptible to immediate crashes but remains vulnerable to resource exhaustion if attackers can deliver large frames, potentially degrading performance or causing slowdowns. Given the reliance on WebSocket communications in modern web applications, this vulnerability could be exploited by attackers to disrupt services, particularly if exposed to untrusted networks or the internet without adequate filtering.

Mitigation Recommendations

1. Immediate upgrade to Rust-WebSocket version 0.26.5 or later, which includes built-in limits on data frame sizes to prevent uncontrolled memory allocation. 2. For organizations unable to upgrade promptly, implement external WebSocket traffic filtering at network or application gateways to block or limit oversized frames and restrict connections to trusted IP addresses or networks. 3. Employ Web Application Firewalls (WAFs) or Intrusion Prevention Systems (IPS) configured to detect and block anomalous WebSocket traffic patterns indicative of oversized frames or resource exhaustion attempts. 4. Monitor WebSocket server logs and system resource usage to detect abnormal memory consumption or frequent process aborts, enabling rapid incident response. 5. Where possible, prefer the asynchronous implementation of Rust-WebSocket with additional custom limits on frame sizes and memory usage to reduce risk. 6. Conduct regular security assessments and code reviews of WebSocket implementations to ensure adherence to best practices for resource management and input validation. 7. Educate development and operations teams about the risks of uncontrolled resource consumption and the importance of applying patches promptly.

Need more detailed analysis?Get Pro

Technical Details

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

Threat ID: 682d9844c4522896dcbf3a49

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

Last enriched: 6/23/2025, 12:35:35 AM

Last updated: 8/17/2025, 12:41:51 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