Repository navigation
fix(cargo): fail crates.io lookups where configuration replaces crates.io - #174
Merged
Merged
Conversation
…s.io Cargo only takes a crate from the registry its dependency names, so crates.io lookups were safe, except where a repository's Cargo configuration replaces crates.io with another source: Cargo then takes every unnamed crate from there, and Cargo.lock still records crates.io. A .cargo/config.toml or .cargo/config in the crate's folder or above that replaces crates.io with anything but a vendored directory source, or a chain the repository does not define, now fails the crates.io lookups of the manifests and lockfiles below it. Every definition of a source in any applying configuration counts, so one a closer configuration overrides only makes lookups fail. An unreadable configuration fails them too, and a symlinked .cargo folder is unreadable.
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Rust | Nov 4, 2026 3:27a.m. | Review ↗ | |
| JavaScript | Nov 4, 2026 3:27a.m. | Review ↗ | |
| Shell | Nov 4, 2026 3:27a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
count-patchula | 877b8af | Commit Preview URL Branch Preview URL |
Nov 04 2026, 03:24 AM |
|
Docs7 for sweepies/count-patchula
Commit |
- A configuration that includes others is not read, so it fails. - A crate a [patch.crates-io] or [replace] entry takes from another registry, in the manifest, its workspace's or a configuration, fails its lookup; a git or path patch keeps crates.io's crate. - A registry-index dependency is skipped like an alternate registry, without repeating the index URL. - Configurations anywhere in the crate's workspace apply, since Cargo reads them from wherever it runs. - A symlinked settings folder in a working tree is unreadable whenever its target exists, so a .cargo with only the legacy config is caught.
Matching patched crates by name kept missing forms Cargo accepts (patch tables keyed by index URL, name@version replace keys, - and _ spelt interchangeably). Any [patch] or [replace] entry from another registry, in the crate's manifest, any manifest above it or an applying configuration, now fails every crates.io lookup there, locked crates included. Manifests above a crate's are read in a follow-up pass whatever exclude says, so a workspace root's patches are always seen; one that cannot be read fails closed instead of breaking extraction. Results are cached per lockfile.
- The manifest beside a lockfile is fetched in the follow-up pass too, so a lockfile selected without its manifest still sees its patches. - Only manifests and lockfiles Cargo's selection takes are parsed for extraction: one fetched only for its patches no longer supplies workspace dependencies to members, and one that does not parse fails its crates' lookups rather than the whole scan.
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fifth per-ecosystem fix from the registry audit, after Bundler (#168), Composer (#170), NuGet (#171) and Maven/Gradle (#173).
Why Cargo needs little
Cargo takes a crate only from the registry its dependency names: no
registrykey means crates.io, and Cargo never searches several registries. Alternate-registry, git and path dependencies were already listed as skipped. So the one gap is source replacement. A repository's.cargo/config.tomlcan replace crates.io with another source. Cargo then fetches every unnamed crate from it, whileCargo.lockstill recordsregistry+https://github.com/rust-lang/crates.io-index, so the lock can't tell.The rule
.cargo/config.tomlor.cargo/configin the crate's folder or above that replaces crates.io fails that crate's crates.io lookups, for the manifest and for locked crates in itsCargo.lock.directorysource (whatcargo vendorsets up), since it holds copies of crates.io's crates.$CARGO_HOME)..cargofolder, which counts as unreadable.Renovate does the same in spirit: it follows
replace-withand skips a crate whose registry it can't resolve.Also fails closed
includes others, or that the Count cannot read.[patch]or[replace]entry taking a crate from another registry, in the crate's manifest, any manifest above it, or an applying configuration. It fails every crates.io lookup there, since it can stand for any crate under any name Cargo accepts for it. Manifests above a crate's are read in a follow-up pass, whateverexcludesays.Follow-ups
$CARGO_HOME,--configorCARGO_*variables in CI) isn't seen.members = ["../x"],package.workspace) aren't tied to their root.