Junglewise Threat Intelligence

CVE-2026-5222: Rust Cargo credential leakage via incorrect URL normalization in sparse registries

CVE-2026-5222 · Severity: medium · CVSS 4 · Published 2026-05-25

Technologies: cargo (crates.io). Vendors: crates.io.

Executive brief

Cargo, the package manager for the Rust programming language, contains a vulnerability that could allow a malicious actor to steal a user's registry credentials. This occurs when Cargo incorrectly treats two different package registries as the same because of how it handles web addresses. An attacker would need to control a specific type of registry and trick a user into downloading a malicious package to capture their authentication token.

Technical details

A vulnerability exists in Cargo's URL normalization logic for sparse registries (introduced in Rust 1.68). Cargo incorrectly applies a legacy normalization rule—stripping the '.git' suffix from registry URLs—to the sparse index protocol. On hosting providers that allow multiple registries under the same domain, an attacker can create a malicious registry at a URL differing only by the '.git' suffix. By publishing a crate that depends on a package from the malicious registry, the attacker can coerce Cargo into sending the victim's authentication token for the legitimate registry to the attacker-controlled server. This is fixed in Rust 1.96 (Cargo 0.97.0).

Affected products

  • Rust cargo 1.68 to 1.95.x

Timeline

  • 2026-05-25: advisory: Initial advisory published by Rust Security Response Team
  • 2026-05-28: patched: Fixed in Rust 1.96 / Cargo 0.97.0
  • 2026-06-26: other: GitHub Advisory reviewed and updated

References

Related threats