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

Source: https://junglewise.ai/threats/cve-2026-5222-rust-cargo-credential-leakage-via-incorrect-url-normalization-in  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-05-25. Updated: 2026-06-26  
License: CC BY 4.0 with a link back

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

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.

Technologies: [cargo (crates.io)](https://junglewise.ai/threats/technologies/crates-io-cargo). Vendors: [crates.io](https://junglewise.ai/threats/vendors/crates-io).

## Quick answers

**Is CVE-2026-5222 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-5222 being exploited in the wild.

**How severe is CVE-2026-5222?** Medium severity, with a CVSS score of 4, published 25 May 2026.

**Which products and versions are affected?** cargo (crates.io) SEMVER:introduced=0,fixed=0.97.0; Rust Foundation Cargo 1.68 to 1.96.

**Is there a fix for CVE-2026-5222?** Yes. cargo (crates.io): upgrade to 0.97.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-5222 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-5222?** Check whether you run cargo (crates.io) or Rust Foundation Cargo at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- cargo (crates.io): upgrade to 0.97.0 or later

  ```sh
  cargo update -p cargo
  ```


## 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

## Identifiers

- CVE-2026-5222
- GHSA-p688-r7jv-fm6f

## 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

- [https://api.github.com/users/christos-spearbit](https://api.github.com/users/christos-spearbit)
- [https://github.com/christos-spearbit](https://github.com/christos-spearbit)
- [https://api.github.com/users/christos-spearbit/gists%7B/gist_id%7D](https://api.github.com/users/christos-spearbit/gists%7B/gist_id%7D)
- [https://api.github.com/users/christos-spearbit/repos](https://api.github.com/users/christos-spearbit/repos)
- [https://avatars.githubusercontent.com/u/265288016?v=4](https://avatars.githubusercontent.com/u/265288016?v=4)
- [https://api.github.com/users/christos-spearbit/events%7B/privacy%7D](https://api.github.com/users/christos-spearbit/events%7B/privacy%7D)

## Related threats

- [Rust Cargo symlink traversal in crate extraction](https://junglewise.ai/threats/cve-2026-5223-rust-cargo-symlink-traversal-in-crate-extraction)
- [Malicious dependencies can inject arbitrary JavaScript into cargo-generated timing reports](https://junglewise.ai/threats/cve-2023-40030-malicious-dependencies-can-inject-arbitrary-javascript-into-cargo)
- [Cargo not respecting umask when extracting crate archives](https://junglewise.ai/threats/cve-2023-38497-cargo-not-respecting-umask-when-extracting-crate-archives)
- [Cargo did not verify SSH host keys](https://junglewise.ai/threats/cve-2022-46176-cargo-did-not-verify-ssh-host-keys)
- [Cargo extracting malicious crates can corrupt arbitrary files](https://junglewise.ai/threats/cve-2022-36113-cargo-extracting-malicious-crates-can-corrupt-arbitrary-files)
