#  Cargo not respecting umask when extracting crate archives

Cargo extracted crate archives preserving world-writable permissions, letting a local attacker modify cached dependency source and achieve code execution on the victim's next build.

- Payout: $4,660
- Severity: high
- Program: Internet Bug Bounty
- Found by: addisoncrump
- Disclosed: 2023-08-15
- CVE: CVE-2023-38497
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/2094785
- Library page: https://bugbountylibrary.com/r/h1%3A2094785
- Tags: area:oss domain:oss impact:integrity impact:rce kind:bounty platform:hackerone sev:high tech:rust technique:recon technique:source-review vuln:misconfiguration

**Target:** Cargo package manager (crate archive extraction) on UNIX-like systems
**Root cause:** Cargo did not apply the process umask when extracting crate archives, propagating file permission bits stored in the archive as-is, including world-writable bits.
**Steps:**
1. Run `find / ! -type l -perm -002 -exec ls -alhd {} \;` to locate world-writable files.
2. Observe files under the cargo registry cache are world-writable after extracting a crate whose archive marks them so.
3. As a local attacker, edit the cached dependency source in the registry.
4. Victim recompiles; modified code is compiled and executed, or prebuilt binaries are poisoned.
**How found:** Routine personal file-permissions audit using `find / ! -type l -perm -002` surfaced world-writable files in the cargo registry cache, leading to the umask hypothesis.
**Exploitation:** A local attacker with access to the same filesystem modifies world-writable cached crate source in the cargo registry; when the victim compiles, the tampered code executes as the victim, or downstream prebuilt binaries are poisoned.
**Escalation:** Local code execution escalates to supply-chain attack by poisoning prebuilt binaries distributed to downstream users.
**Insight:** Periodic filesystem permission sweeps (`find / -perm -002`) on build caches and package managers reveal umask-bypass bugs; any tool extracting archives should be checked for whether it honors umask vs. archive permission bits.

