CVE-2022-35922: Websocket Rust-WebSocket Memory Allocation Based On Vulnerability
HIGHCVE-2022-35922 is a HIGH (CVSS 7.5) rust-websocket memory allocation based on vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Websocket libraries in the crates.io ecosystem. The issue involves rust-websocket memory allocation based on untrusted length. Remediation is available by upgrading affected packages to version 0.26.5.
CVE-2022-35922 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-35922
To remediate this vulnerability, upgrade all affected 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.
Upgrade websocket to 0.26.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for websocket
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-35922, inspect your project dependencies for Websocket:
inspect dependencies for websocket
Analyze the terminal output to locate any version of Websocket in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.26.5), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In 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-35922 Affected Websocket Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
websocket
|
crates.io |
< 0.26.5
|
0.26.5
|
References
Frequently Asked Questions
What is CVE-2022-35922?
Which Websocket versions are affected?
What version fixes CVE-2022-35922?
Is websocket affected?
What is the CVSS score of CVE-2022-35922?
What CWE is associated with CVE-2022-35922?
How can I check crates.io dependencies for CVE-2022-35922?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-qrjv-rf5q-qpxc",
"modified" : "2022-08-06T05:20:00Z",
"published" : "2022-08-06T05:20:00Z",
"aliases" : [ "CVE-2022-35922" ],
"summary" : "Rust-WebSocket memory allocation based on untrusted length",
"details" : "## Impact\nUntrusted websocket connections can cause an out-of-memory (OOM) process abort in a client or a server.\nThe root cause of the issue is during dataframe parsing.\nAffected versions would allocate a buffer based on the declared dataframe size, which may come from an untrusted source.\nWhen `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.\n\nThis is a security concern for you, if\n- your server application handles untrusted websocket connections\n- OR your client application connects to untrusted websocket servers\n\n## Patches\nThe crashes are fixed in version **0.26.5** by imposing default dataframe size limits.\nAffected users are advised to update to this version.\n\nNote that default memory limits are rather large (100MB dataframes and 200 MB messages), so they can still cause DoS in some environments (i.e. 32-bit). New API has been added to fine tune those limits for specific applications.\n\n### Workarounds\n\n* Migrate your project to another, maintained Websocket library like Tungstenite.\n* Accept only trusted WebSocket traffic.\n* Filter the WebSocket traffic though some kind of proxy that ensures sanity limits on messages.\n* Handle process aborts gracefully and limit process memory using OS tools.\n\n\n## Credits\nThis issue was reported by [Evan Richter](https://github.com/evanrichter) at ForAllSecure and found with [Mayhem](https://forallsecure.com/mayhem-for-code) and [Cargo Fuzz](https://github.com/rust-fuzz/cargo-fuzz).\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" : "crates.io",
"name" : "websocket"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.26.5"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/websockets-rs/rust-websocket/security/advisories/GHSA-qrjv-rf5q-qpxc"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-35922"
}, {
"type" : "WEB",
"url" : "https://github.com/websockets-rs/rust-websocket/commit/cbf6e9983e839d2ecad86de8cd1b3f20ed43390b"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/websockets-rs/rust-websocket"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/4V2EOOU5OLEHVMKAH6BALQXKDKIZRXCI"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HYPNCM4H4OFBIZI6XMJ2DUTS54FT2TWP"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2022-0035.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-119", "CWE-400", "CWE-770" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-08-06T05:20:00Z",
"nvd_published_at" : "2022-08-01T22:15:00Z"
}
}