Miggo Logo

CVE-2022-36113: Cargo extracting malicious crates can corrupt arbitrary files

3.9

CVSS Score
3.1

Basic Information

EPSS Score
0.8587%
Published
9/16/2022
Updated
8/14/2023
KEV Status
No
Technology
TechnologyRust

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:L
Package NameEcosystemVulnerable VersionsFirst Patched Version
cargorust< 0.65.00.65.0
cargorust= 0.66.00.67.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability arises from two key issues in src/cargo/sources/registry/mod.rs:

  1. Unsafe Extraction: The loop processing crate entries lacked a check to skip .cargo-ok, allowing a malicious symlink to be extracted. The patch adds this check (via entry_path.file_name() == PACKAGE_SOURCE_LOCK).
  2. Unsafe File Creation: The .cargo-ok file was opened with create(true), which overwrites existing files (including symlinks). The patch uses create_new(true) to ensure the file doesn't exist before writing. Both functions are necessary for the exploit: the first allows the symlink to exist, and the second triggers the corruption by writing to it. The high confidence stems from the direct correspondence between the patch and the vulnerability description.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

T** Rust S**urity R*spons* W* w*s noti*i** t**t **r*o *i* not pr*v*nt *xtr**tin* som* m*l*orm** p**k***s *ownlo**** *rom *lt*rn*t* r**istri*s. *n *tt**k*r **l* to uplo** p**k***s to *n *lt*rn*t* r**istry *oul* *orrupt *r*it*ry *il*s w**n **r*o *ownlo

Reasoning

T** vuln*r**ility *ris*s *rom two k*y issu*s in `sr*/**r*o/sour**s/r**istry/mo*.rs`: *. **Uns*** *xtr**tion**: T** loop pro**ssin* *r*t* *ntri*s l**k** * ****k to skip `.**r*o-ok`, *llowin* * m*li*ious symlink to ** *xtr**t**. T** p*t** ***s t*is ***