CVE-2026-5222: Cargo can be coerced to share credentials between registries

Published May 25, 2026
·
Updated

Cargo between 1.68 and 1.96 incorrectly normalized the URLs of third-party registries using the sparse index protocol. If a hosting provider allowed multiple registries to be hosted with arbitrary names within the same domain, an attacker able to publish crates in a registry could obtain the credentials of others users of the same registry. The severity of the vulnerability is low, due to the extremely niche requirements needed to achieve the attack.

Other sources

Cargo can be coerced to share credentials between registries

Microsoft

The Rust Security Response Team was notified that Cargo incorrectly normalized the URLs of third-party registries using the [sparse index protocol][1]. If a hosting provider allowed multiple registries to be hosted with arbitrary names within the same domain, an attacker able to publish crates in a registry could obtain the credentials of others users of the same registry.

This vulnerability is tracked as CVE-2026-5222. The severity of the vulnerability is low, due to the extremely niche requirements needed to achieve the attack.

Overview

Originally Cargo only supported storing a registry's index within git repositories. Most git hosting solutions allow accessing a git repository with or without the .git suffix, so Cargo mirrored this behavior when normalizing registry URLs. This allowed credentials for https://example.com/index to be used for https://example.com/index.git.

This normalization was unintentionally applied to the new sparse indexes too. Sparse indexes can be hosted on any HTTPS server, which treat URLs ending with .git as different URLs than those without the suffix.

If the following conditions apply:

https://example.com/index is a sparse index. https://example.com/index allows crates to depend on crates from any other registry. The attacker is able to publish crates on https://example.com/index. The attacker is able to upload arbitrary files to https://example.com/index.git.

...the attacker could configure https://example.com/index.git to be a Cargo sparse registry requiring authentication for downloads, and with a download URL pointing to a server recording any credentials set to it.

When the attacker then publishes a crate foo to https://example.com/index depending on a crate bar from https://example.com/index.git, and tricks the victim into downloading foo, Cargo will think the two registries share the same credential and send the victim's Cargo token to the malicious registry.

Mitigations

Rust 1.96, to be released on May 28th, 2026, will update Cargo to only strip the .git suffix from registry URLs using the git protocol. No mitigations are available for users of older versions of Cargo.

Affected versions

All versions of Cargo shipped between Rust 1.68 (the stabilization of sparse registries) and 1.96 are affected.

Acknowledgements

Cargo would like to thank Christos Papakonstantinou for reporting this issue according to the [Rust security policy][2].

Cargo also wants to thank the members of the Rust project who helped address the vulnerability: Arlo Siemens for developing the fix; Weihang Lo, Eric Huss and Emily Albini for reviewing the fix; Emily Albini for writing this advisory; Emily Albini, Josh Stone and Manish Goregaokar for coordinating the disclosure.

[1]: https://doc.rust-lang.org/cargo/reference/registries.html#registry-protocols [2]: https://rust-lang.org/policies/security

GitHub

Affected Software

5 affected componentsFixes available
Rust Cargo>=1.68<=1.96
rust-lang Cargo Rust>=1.68.0<1.96.0
Microsoft azl3 rust 1.90.0-8<1.90.0-9
1.90.0-9
Microsoft azl3 rust 1.75.0-29<1.75.0-30
1.75.0-30
rust/cargo<0.97.0
0.97.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 1.90.0-9
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 1.75.0-30
  3. Upgrade

    Upgrade rust/cargo to a version that resolves this vulnerability.

    Fixed in 0.97.0

Event History

May 25, 2026
CVE Published
via MITRE·08:54 AM
Data Sourced
via MITRE·08:54 AM
RemedyDescriptionWeakness
Data Sourced
via NVD·10:16 AM
RemedyDescriptionSeverityWeaknessAffected Software
May 27, 2026
Data Sourced
via Microsoft·08:18 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·08:18 AM
Affected Software
Updated
via Microsoft·08:18 AM
DescriptionSeverity
Jun 26, 2026
Advisory Published
via GitHub·09:47 PM
Data Sourced
via GitHub·09:47 PM
DescriptionWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-5222?

The severity of CVE-2026-5222 is rated as 15.

2

How do I fix CVE-2026-5222?

To fix CVE-2026-5222, upgrade to Rust Cargo version 1.96 or later when it is released on May 28th, 2026.

3

What versions of Cargo are affected by CVE-2026-5222?

Cargo versions from 1.68 to 1.96 are affected by CVE-2026-5222.

4

What kind of attack does CVE-2026-5222 enable?

CVE-2026-5222 allows an attacker to coerce Cargo into sharing credentials between different registries.

5

Is there a workaround for CVE-2026-5222?

No mitigations are available for users of older versions of Cargo prior to the release of version 1.96.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203