Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS0yaHZyLWg2Z3ctcXJ4cM4AAu1N
Cargo extracting malicious crates can fill the file system
The Rust Security Response WG was notified that Cargo did not prevent extracting some malformed packages downloaded from alternate registries. An attacker able to upload packages to an alternate registry could fill the file system when Cargo downloaded the package.
The severity of this vulnerability is "low" for users of alternate registries. Users relying on crates.io are not affected.
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.
Disk space exaustion
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.
Affected versions
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.
Mitigations
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.
Acknowledgements
We want to thank Ori Hollander from JFrog Security Research for responsibly disclosing this to us according to the Rust security policy.
We also want to thank Josh Triplett for developing the fixes, Weihang Lo for developing the tests, and Pietro Albini for writing this advisory. The disclosure was coordinated by Pietro Albini and Josh Stone.
Permalink: https://github.com/advisories/GHSA-2hvr-h6gw-qrxpJSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS0yaHZyLWg2Z3ctcXJ4cM4AAu1N
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: over 2 years ago
Updated: over 1 year ago
CVSS Score: 4.2
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
EPSS Percentage: 0.00088
EPSS Percentile: 0.38941
Identifiers: GHSA-2hvr-h6gw-qrxp, CVE-2022-36114
References:
- https://github.com/rust-lang/cargo/security/advisories/GHSA-2hvr-h6gw-qrxp
- https://nvd.nist.gov/vuln/detail/CVE-2022-36114
- https://github.com/rust-lang/cargo/commit/d1f9553c825f6d7481453be8d58d0e7f117988a7
- https://github.com/rust-lang/cargo/commit/d87d57dbbda61754f4fab0f329a7ac520e062c46
- https://security.gentoo.org/glsa/202210-09
- https://github.com/rust-lang/cargo/commit/2b68d3c07a4a056264dc006ecb9f1354a0679cd3
- https://github.com/advisories/GHSA-2hvr-h6gw-qrxp
Blast Radius: 10.3
Affected Packages
cargo:cargo
Dependent packages: 169Dependent repositories: 280
Downloads: 4,248,447 total
Affected Version Ranges: = 0.66.0, < 0.65.0
Fixed in: 0.67.0, 0.65.0
All affected versions: 0.0.1, 0.4.0, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.8.0, 0.9.0, 0.10.0, 0.11.0, 0.12.0, 0.13.0, 0.14.0, 0.15.0, 0.16.0, 0.17.0, 0.18.0, 0.19.0, 0.20.0, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.24.0, 0.25.0, 0.26.0, 0.27.0, 0.28.0, 0.29.0, 0.30.0, 0.31.0, 0.32.0, 0.33.0, 0.34.0, 0.35.0, 0.36.0, 0.37.0, 0.38.0, 0.39.0, 0.40.0, 0.41.0, 0.42.0, 0.43.0, 0.43.1, 0.44.0, 0.44.1, 0.45.0, 0.45.1, 0.46.0, 0.46.1, 0.47.0, 0.48.0, 0.49.0, 0.50.0, 0.50.1, 0.51.0, 0.52.0, 0.53.0, 0.54.0, 0.55.0, 0.56.0, 0.57.0, 0.58.0, 0.59.0, 0.60.0, 0.61.0, 0.61.1, 0.62.0, 0.63.0, 0.63.1, 0.64.0, 0.66.0
All unaffected versions: 0.65.0, 0.67.0, 0.67.1, 0.68.0, 0.69.0, 0.69.1, 0.70.0, 0.70.1, 0.71.0, 0.72.0, 0.72.1, 0.72.2, 0.73.0, 0.73.1, 0.74.0, 0.75.0, 0.75.1, 0.76.0, 0.77.0, 0.78.0, 0.78.1, 0.79.0, 0.80.0, 0.81.0, 0.82.0, 0.83.0, 0.84.0