Repository navigation
fix(client): reject bundle manifests whose entry paths name one file - #2747
Merged
Merged
Conversation
A manifest could hold {p -> A} and {p -> B}, or paths that differ only in
case or Unicode normalization. The pull's skip set was keyed by path
alone, so with A on disk the B entry was skipped too and the pull
reported success while p kept bytes B never matched (GHSA-3c38-gqx6-v7fm).
- BundleManifest::parse fails with MalformedManifest when two paths
share a path_collision key (NFD, lower/upper/lower case, NFC).
- A pull of a hand-built manifest fails every colliding entry and
writes none of them; an entry skips only when its own hash is
confirmed at its path; a saved file at a case variant of a path the
pull writes is no whole-file donor.
- origin import checks the walked paths before it imports, moves or
writes any file, then parses its own manifest as a backstop.
- ADR appendix-bundles Path-safety rule 7; CHANGELOG Security entry.
Closes #2691
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Collision assertions in both tests assume an order that WalkDir does not guarantee, so valid rejections can fail before the no-move/no-write checks; the assertions should accept either ordering.
1 open issue
What changed in this PR
This PR addresses #2691 by rejecting bundle paths that collide under case or Unicode normalization, preventing incorrect skips and conflicting writes.
Changes:
- Adds shared collision detection for manifest parsing, pull planning, and publisher imports.
- Makes skips hash-specific and excludes conflicting whole-file donors.
- Adds regression tests and documents the security behavior.
| File | Description |
|---|---|
| crates/client/tests/snapshots/public_api__public_api.snap | Records the public collision helper. |
| crates/client/src/bundle/engine/tests.rs | Tests collision failures, hash-specific skips, and donor exclusions. |
| crates/client/src/bundle/engine.rs | Rejects colliding destinations and tightens reuse checks. |
| crates/client/src/bundle.rs | Adds normalized path keys and manifest rejection. |
| crates/client/Cargo.toml | Adds the normalization dependency. |
| crates/cli/tests/origin_import.rs | Tests rejection before imports or source moves. |
| crates/cli/tests/origin_import_dryrun.rs | Tests dry-run rejection and updates sorting fixtures. |
| crates/cli/src/commands/origin.rs | Validates generated manifests before emission. |
| crates/cli/src/commands/manifest.rs | Checks all collected paths before processing files. |
| crates/cli/src/commands/gateway.rs | Clarifies malformed-manifest comments only. |
| crates/cli/src/commands/fetch.rs | Clarifies malformed-manifest comments only. |
| crates/cli/src/commands/bundle_pull.rs | Clarifies malformed-manifest comments only. |
| CHANGELOG.md | Documents the security fix. |
| Cargo.toml | Declares the workspace normalization dependency. |
| Cargo.lock | Records the client’s normalization dependency. |
| adr/appendix-bundles.md | Documents unique-path validation and failure behavior. |
Review effort: Balanced
The walk meets files in directory order, so the refusal named a colliding pair in whatever order the file system listed it, and the CI runner saw `readme` before `README`. Sort by path bytes first: the manifest already uses that order, and the error now names the pair the same way on every machine. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 6 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
7 tasks done
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.

What
GHSA-3c38-gqx6-v7fm. A bundle manifest could hold
{p → A}and{p → B}, or paths that differ only in case or Unicode normalization. The pull keyed its skip set by path alone, so with A on disk the B entry was skipped too, and the pull reported success whilepkept bytes B never matched. On macOS and Windows,P/por a composed/decomposedédid the same.BundleManifest::parsefails withMalformedManifestwhen two entry paths share a key. The key is NFD, then lower, upper and lower case, then NFC (decdn_client::bundle::path_collision).decdn get, cached manifests,decdn quoteand the gateway all go throughparse.BundleManifest::new/land_atskipparse): every colliding entry fails before its fetch, with or without--overwrite, and none is written. An entry skips only when its own hash is confirmed at its path. A saved file at a case variant of a path the pull writes is no whole-file donor.origin importwalks the whole tree, checks the relative paths, and only then imports. A refused--moveimport moves nothing, and no blob reaches the store.emit_manifestalso parses its own bytes as a backstop.appendix-bundles.mdPath-safety rule 7; CHANGELOG Security entry.Closes #2691
Reviewer notes
path_key/path_collisionincrates/client/src/bundle.rsfirst, thenDiskStateandplan_slotsinengine.rs, thenwalk_and_collectincrates/cli/src/commands/manifest.rs.ı/i, KelvinK/k). Such a pair is refused, never written over.icu_normalizer(compiled_dataonly) is already in the graph throughurl→idna, soCargo.lockgains one line.determinism_mixed_case_bytewise_sortusedA.txt/a.txt, which is now refused. It now checks bytewise order withB.txt/a.txt, anddry_run_refuses_paths_that_differ_only_in_casecovers the refusal.:, 8.3 names) can make two bundle entry paths one file #2746 (Win32 aliasing: trailing dot/space,:, 8.3 names).Verification
pre-commit run(commit hooks: fmt, clippy, doc, ADR hygiene, crate edges all passed;cargo denyreports the existing RUSTSEC-2026-0387crypto-bigintadvisory, warn-only, already on main)cargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run --workspace: 6156 passedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemsfix(client): …, lowercase subjectdecdn-client:.snapregenerated (one added line,path_collision)adr/:make -C adr check-refs; thearchitecture.mdsummary line needs no changepython3 .github/scripts/check_crate_edges.pypasses (no table change; the banned-crate closures are unaffected)CHANGELOG.mdentryskips()failsplan_slots_skips_only_the_entry_whose_blob_is_confirmed; disabling the walk-phase collision check failsdirectory_import_refuses_paths_that_name_one_file(the source files are moved).🤖 Generated with Claude Code