Skip to main content

CVE-2022-36114: CWE-400: Uncontrolled Resource Consumption in rust-lang cargo

Medium
Published: Wed Sep 14 2022 (09/14/2022, 00:00:00 UTC)
Source: CVE
Vendor/Project: rust-lang
Product: cargo

Description

Cargo is a package manager for the rust programming language. It was discovered that Cargo did not limit the amount of data extracted from compressed archives. An attacker could upload to an alternate registry a specially crafted package that extracts way more data than its size (also known as a "zip bomb"), exhausting the disk space on the machine using Cargo to download the package. Note that by design Cargo allows code execution at build time, due to build scripts and procedural macros. The vulnerabilities in this advisory allow performing a subset of the possible damage in a harder to track down way. Your dependencies must still be trusted if you want to be protected from attacks, as it's possible to perform the same attacks with build scripts and procedural macros. The vulnerability is present in all versions of Cargo. Rust 1.64, to be released on September 22nd, will include a fix for it. Since the vulnerability is just a more limited way to accomplish what a malicious build scripts or procedural macros can do, we decided not to publish Rust point releases backporting the security fix. Patch files are available for Rust 1.63.0 are available in the wg-security-response repository for people building their own toolchain. We recommend users of alternate registries to excercise care in which package they download, by only including trusted dependencies in their projects. Please note that even with these vulnerabilities fixed, by design Cargo allows arbitrary code execution at build time thanks to build scripts and procedural macros: a malicious dependency will be able to cause damage regardless of these vulnerabilities. crates.io implemented server-side checks to reject these kinds of packages years ago, and there are no packages on crates.io exploiting these vulnerabilities. crates.io users still need to excercise care in choosing their dependencies though, as the same concerns about build scripts and procedural macros apply here.

AI-Powered Analysis

AILast updated: 06/22/2025, 21:49:41 UTC

Technical Analysis

CVE-2022-36114 is a vulnerability in Cargo, the package manager for the Rust programming language, classified under CWE-400: Uncontrolled Resource Consumption. The issue arises because Cargo does not impose limits on the amount of data extracted from compressed archives during package downloads. An attacker can exploit this by uploading a specially crafted package to an alternate registry that behaves like a "zip bomb," where the decompressed data size vastly exceeds the compressed package size. When Cargo downloads and extracts such a package, it can exhaust disk space on the target machine, leading to denial of service conditions. This vulnerability affects all versions of Cargo prior to 0.65.0 and version 0.66.0. The Rust 1.64 release, scheduled for September 22, 2022, includes a fix for this issue, but no backported fixes are provided for earlier Rust point releases, although patch files exist for Rust 1.63.0 for those building custom toolchains. Importantly, Cargo inherently allows code execution at build time through build scripts and procedural macros, which can be leveraged by malicious dependencies to perform arbitrary actions, including resource exhaustion and other attacks. This vulnerability represents a more limited and indirect method of causing damage compared to malicious build scripts but is harder to detect. The official crates.io registry has implemented server-side checks to reject such malicious packages, and no known exploits have been observed in the wild. However, users of alternate registries or those incorporating untrusted dependencies remain at risk. The vulnerability emphasizes the necessity of trusting dependencies and exercising caution when including packages from non-official sources. Overall, this vulnerability is a resource exhaustion attack vector that can cause denial of service by filling disk storage, complicating build processes and potentially impacting continuous integration and deployment pipelines that rely on Cargo.

Potential Impact

For European organizations, the primary impact of CVE-2022-36114 is the risk of denial of service due to disk space exhaustion during Rust package builds. Organizations using Rust and Cargo extensively in software development, especially those relying on alternate or private registries, are at heightened risk. This can disrupt development workflows, continuous integration systems, and automated build environments, leading to operational delays and increased costs. Since Cargo allows code execution at build time, malicious dependencies could also introduce more severe threats beyond resource exhaustion, such as data manipulation or system compromise, if untrusted packages are used. The vulnerability does not directly compromise confidentiality or integrity but can degrade availability of development infrastructure. European sectors with critical software development operations, such as finance, telecommunications, automotive, and defense, could face significant operational impacts if their build environments are disrupted. Additionally, organizations that build Rust-based applications for production deployment may experience cascading effects if compromised builds propagate downstream. The lack of known exploits in the wild reduces immediate risk, but the potential for targeted attacks, especially in supply chain contexts, remains a concern.

Mitigation Recommendations

1. Upgrade Cargo to version 0.65.0 or later, or Rust 1.64 or later, as these versions include fixes addressing this vulnerability. For those using Rust 1.63.0 and building custom toolchains, apply the available patch files from the wg-security-response repository. 2. Restrict usage of alternate registries and only include dependencies from trusted sources. Implement strict vetting and approval processes for any third-party or private registry packages. 3. Employ disk usage monitoring and quotas on build servers and developer machines to detect and prevent excessive resource consumption during package extraction. 4. Use sandboxing or containerization for build environments to isolate and limit the impact of malicious packages, preventing them from exhausting host system resources. 5. Integrate automated scanning tools that analyze package contents and metadata for anomalies indicative of zip bombs or other resource exhaustion payloads before allowing their use. 6. Educate development teams about the risks of including untrusted dependencies and the inherent risks of build scripts and procedural macros executing arbitrary code. 7. For organizations running continuous integration pipelines, implement fail-safes that can abort builds exhibiting abnormal resource usage patterns. 8. Regularly audit dependency trees to identify and remove unnecessary or untrusted packages, minimizing the attack surface. These measures go beyond generic advice by focusing on controlling the source of packages, monitoring resource usage, and isolating build processes to mitigate the specific risks posed by this vulnerability.

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: 682d9845c4522896dcbf3e8e

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

Last enriched: 6/22/2025, 9:49:41 PM

Last updated: 8/9/2025, 11:23:44 AM

Views: 17

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