CVE-2022-36113
CVE-2022-36113 is a medium-severity vulnerability in Rust-lang Cargo with a CVSS 3.x base score of 4.6. It is not currently listed as actively exploited by CISA, and its EPSS exploit-prediction score is low. The underlying weakness is classified as CWE-59.
Key facts
- Severity: Medium (CVSS 3.x base score 4.6)
- EPSS exploit prediction: 1% (59th percentile)
- Actively exploited: Not listed in CISA KEV
- Weakness: CWE-59
- Affected product: Rust-lang Cargo
- Published:
- Last modified:
Description
Cargo is a package manager for the rust programming language. After a package is downloaded, Cargo extracts its source code in the ~/.cargo folder on disk, making it available to the Rust projects it builds. To record when an extraction is successful, Cargo writes "ok" to the .cargo-ok file at the root of the extracted source code once it extracted all the files. It was discovered that Cargo allowed packages to contain a .cargo-ok symbolic link, which Cargo would extract. Then, when Cargo attempted to write "ok" into .cargo-ok, it would actually replace the first two bytes of the file the symlink pointed to with ok. This would allow an attacker to corrupt one file on the machine using Cargo to extract 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. Mitigations We recommend users of alternate registries to exercise 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 exercise care in choosing their dependencies though, as remote code execution is allowed by design there as well.
Frequently asked questions
- What is CVE-2022-36113?
- Cargo is a package manager for the rust programming language. After a package is downloaded, Cargo extracts its source code in the ~/.cargo folder on disk, making it available to the Rust projects it builds. To record when an extraction is successful, Cargo writes "ok" to the .cargo-ok file at the root of the extracted source code once it extracted all the files. It was discovered that Cargo allowed packages to contain a .cargo-ok symbolic link, which Cargo would extract. Then, when Cargo attempted to write "ok" into .cargo-ok, it would actually replace the first two bytes of the file the symlink pointed to with ok. This would allow an attacker to corrupt one file on the machine using Cargo to extract 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. Mitigations We recommend users of alternate registries to exercise 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 exercise care in choosing their dependencies though, as remote code execution is allowed by design there as well.
- How severe is CVE-2022-36113?
- CVE-2022-36113 has a CVSS 3.x base score of 4.6, rated medium severity. It is exploitable over network with high attack complexity, requires low privileges and user interaction. Impact on confidentiality is low, integrity low, and availability low.
- Is CVE-2022-36113 being actively exploited?
- It is not currently listed in CISA's KEV catalog. Its EPSS exploit-prediction score is 1% (59th percentile), an estimate of the probability of exploitation in the next 30 days.
- What products are affected by CVE-2022-36113?
- CVE-2022-36113 affects Rust-lang Cargo. See the affected-products list for the exact vulnerable versions.
- How do I fix CVE-2022-36113?
- Review the linked vendor and NVD advisories for patched versions and mitigations, then upgrade or apply the recommended workaround.
- When was CVE-2022-36113 published?
- CVE-2022-36113 was published on 2022-09-14 and last updated on 2026-06-17.
References
- https://github.com/rust-lang/cargo/commit/97b80919e404b0768ea31ae329c3b4da54bed05a
- https://github.com/rust-lang/cargo/security/advisories/GHSA-rfj2-q3h3-hm5j
Affected products (1)
- cpe:2.3:a:rust-lang:cargo:*:*:*:*:*:rust:*:*
More vulnerabilities in Rust-lang Cargo
- CVE-2023-38497 — High (CVSS 7.9): Cargo downloads the Rust project’s dependencies and compiles the project. Cargo prior to version 0.72.2, bundled with…
- CVE-2026-5222 — Medium (CVSS 6.5): Cargo between 1.68 and 1.96 incorrectly normalized the URLs of third-party registries using the sparse index protocol.…
- CVE-2026-5223 — Medium (CVSS 5.3): Cargo incorrectly handled symlinks inside of crate tarballs downloaded from third-party registries, allowing a…
- CVE-2022-46176 — Medium (CVSS 5.3): Cargo is a Rust package manager. The Rust Security Response WG was notified that Cargo did not perform SSH host key…
- CVE-2022-36114 — Medium (CVSS 4.8): Cargo is a package manager for the rust programming language. It was discovered that Cargo did not limit the amount of…
All CVEs affecting Rust-lang Cargo →
Other CWE-59 (Improper Link Resolution Before File Access (Link Following)) vulnerabilities
- CVE-2024-37143 — Critical (CVSS 10.0): Dell PowerFlex appliance versions prior to IC 46.381.00 and IC 46.376.00, Dell PowerFlex rack versions prior to RCM…
- CVE-2024-28189 — Critical (CVSS 10.0): Judge0 is an open-source online code execution system. The application uses the UNIX chown command on an untrusted file…
- CVE-2024-28185 — Critical (CVSS 10.0): Judge0 is an open-source online code execution system. The application does not account for symlinks placed inside the…
- CVE-2022-22995 — Critical (CVSS 10.0): The combination of primitives offered by SMB and AFP in their default configuration allows the arbitrary writing of…
- CVE-2014-4480 — Critical (CVSS 10.0): Directory traversal vulnerability in afc in AppleFileConduit in Apple iOS before 8.1.3 and Apple TV before 7.0.3 allows…
- CVE-2002-2374 — Critical (CVSS 10.0): Unspecified vulnerability in pprosetup in Sun PatchPro 2.0 has unknown impact and attack vectors related to "unsafe use…
Browse all CWE-59 (Improper Link Resolution Before File Access (Link Following)) vulnerabilities →