Decide "is this source crates.io" in one helper: CargoLock::entries uses a substring test that accepts index.crates.io.evil.example

Ouverte
#1,933 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
50/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
rust
Domaine
security

Piste de recherche

Start with CargoLock::entries in crates/socket-patch-core/src/formats/cargo/mod.rs (around L483) and add a failing unit test with the index.crates.io.evil.example and github.com/rust-lang/crates.io-index-fork lookalikes. Then read the other three sites: vendor/cargo.rs (L576), patch/redirect/mod.rs (L2451), vendor/cargo_manifest.rs (L78), plus the CRATES_IO_SOURCE const in redirect/upstream/cargo.rs. Done means one is_crates_io_source helper is called from all four sites, the local copies are gone, and the cargo lock and vendor cargo tests pass.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

agent:triaged arch-audit bug priority:p2

[agent] Filed by the scheduled architecture audit (audit-core). Register: register.

Kind: bug (duplicated rule that drifted). Register ID: A55.

Problem

Whether a Cargo.lock source is crates.io is decided in four places, by three different rules:

Site Rule
formats/cargo/mod.rs L483-L484 (CargoLock::entries) substring: source.contains("github.com/rust-lang/crates.io-index") || source.contains("index.crates.io")
vendor/cargo.rs L576-L577 two exact strings
patch/redirect/mod.rs L2451-L2461 normalized (case, registry+/sparse+, trailing /, .git)
vendor/cargo_manifest.rs L78-L87 the [patch]-key variant

There is also a CRATES_IO_SOURCE const in redirect/upstream/cargo.rs L25.```

Executed (a scratch copy at cbbbdb9): a lock entry with source = "sparse+https://index.crates.io.evil.example/" gets SourceKind::CratesIo and a Sha256Hex verifier from CargoLock::entries. Downstream, VEX discovery treats it as crates.io (vex/discover/mod.rs L2942).

Proposed change

Add one formats::cargo::is_crates_io_source(&str) -> bool next to is_registry_source. It uses the normalized rule from redirect/mod.rs, plus the [patch]-key spelling. Call it from all four sites, and delete the local copies and CRATES_IO_SOURCE.

Size

5 files, about −30/+20 lines.

Acceptance criteria

  • A unit table test covers both canonical spellings, case and trailing-slash variants, and the index.crates.io.evil.example and github.com/rust-lang/crates.io-index-fork lookalikes (both rejected).
  • The cargo lock equivalence tests and vendor cargo tests pass.
Langage dominant
Rust
Étoiles
9
Forks
2
Merge moyen
20 h 47 min
PR mergées (30 j)
681

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de SocketDev/socket-patch

Toutes les issues de SocketDev/socket-patch

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.