CVE-2022-36113
Extracting malicious crates can corrupt arbitrary files
Also known as GHSA-rfj2-q3h3-hm5j
Mitigation
- Upgrade cargo to one of 0.65.0, 0.67.0 (or later in the same release line).
Who should check
- Projects that depend on crates.io package cargo (< 0.65.0)
- Anyone running rust-lang cargo < 0.65.0; = 0.66.0
Vulnerability facts
- Affected
- cargo < 0.65.0
- Fixed in
- 0.65.0, 0.67.0
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- None known
- Remote exploitation
- Remote, login needed
- CVSS
- 4.6 (v3.1, CNA)CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:LOpen in CVSS calculator
Show all 8 CVSS metrics
- Attack vector: Network
- Attack complexity: High
- Privileges required: Low
- User interaction: Required
- Scope: Unchanged
- Confidentiality impact: Low
- Integrity impact: Low
- Availability impact: Low
- EPSS
- 1.26% chance of exploitation in 30 days (percentile 70, 2026-11-26)
- CWE
- CWE-22
- 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.
Affected and fixed versions
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
Check whether anything I run is affected by CVE-2022-36113. Work read-only: do not install, upgrade, delete or change anything. Details: https://flawdb.com/CVE-2022-36113.md Affected: cargo < 0.65.0 Fixed in: 0.65.0, 0.67.0 Steps: 1. Search this machine and project for cargo (crates.io), rust-lang cargo: dependency manifests and lockfiles, installed packages, container images and running services. 2. For each match, note the installed version and whether it is inside the affected range. 3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
References
Vendor advisories
Patches
FAQ
Is CVE-2022-36113 being exploited?
There is no confirmed exploitation: CVE-2022-36113 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 1.26% chance of exploitation in the next 30 days (as of 2026-11-26).
How serious is CVE-2022-36113?
Medium: CVSS 4.6 (v3.1, scored by CNA). Remote, login needed. A user has to take an action, such as opening a link, for the attack to work. The attack needs conditions outside the attacker's control, which makes it harder.
Which versions are affected by CVE-2022-36113?
cargo < 0.65.0.
Is there a fix for CVE-2022-36113?
Yes. Fixed in 0.65.0, 0.67.0. Upgrade cargo to one of 0.65.0, 0.67.0 (or later in the same release line).
How do I check if I'm affected by CVE-2022-36113?
Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.