Skip to content

fix(client): reject bundle manifests whose entry paths name one file - #2747

Merged
thiras merged 2 commits into
mainfrom
fix/bundle-path-collisions-2691
Oct 29, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/bundle-path-collisions-2691

Conversation

@thiras

@thiras thiras commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

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 while p kept bytes B never matched. On macOS and Windows, P/p or a composed/decomposed é did the same.

  • Reader: BundleManifest::parse fails with MalformedManifest when 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 quote and the gateway all go through parse.
  • Pull (BundleManifest::new / land_at skip parse): 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.
  • Publisher: origin import walks the whole tree, checks the relative paths, and only then imports. A refused --move import moves nothing, and no blob reaches the store. emit_manifest also parses its own bytes as a backstop.
  • ADR appendix-bundles.md Path-safety rule 7; CHANGELOG Security entry.

Closes #2691

Reviewer notes

  • Read path_key / path_collision in crates/client/src/bundle.rs first, then DiskState and plan_slots in engine.rs, then walk_and_collect in crates/cli/src/commands/manifest.rs.
  • The key over-joins a few pairs that full case folding keeps apart (dotless ı/i, Kelvin K/k). Such a pair is refused, never written over.
  • The path+hash skip key is defense in depth. Once colliding paths fail, no input this code accepts tells it apart from a path-only key. The rejection and the per-entry failure are the fix.
  • New dependency edge: icu_normalizer (compiled_data only) is already in the graph through url → idna, so Cargo.lock gains one line.
  • determinism_mixed_case_bytewise_sort used A.txt/a.txt, which is now refused. It now checks bytewise order with B.txt/a.txt, and dry_run_refuses_paths_that_differ_only_in_case covers the refusal.
  • Out of scope, filed: client: Win32 name aliasing (trailing dot/space, :, 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 deny reports the existing RUSTSEC-2026-0387 crypto-bigint advisory, warn-only, already on main)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run --workspace: 6156 passed
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items
  • PR title: fix(client): …, lowercase subject
  • Public API of decdn-client: .snap regenerated (one added line, path_collision)
  • adr/: make -C adr check-refs; the architecture.md summary line needs no change
  • A crate dependency edge: python3 .github/scripts/check_crate_edges.py passes (no table change; the banned-crate closures are unaffected)
  • User-visible change: CHANGELOG.md entry
  • Mutation checks: a path-only skips() fails plan_slots_skips_only_the_entry_whose_blob_is_confirmed; disabling the walk-phase collision check fails directory_import_refuses_paths_that_name_one_file (the source files are moved).

🤖 Generated with Claude Code

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]>
@thiras thiras added kind:security Security impact; report a vulnerability to [email protected], not here area:client decdn-client SDK: paid pull, lanes, buyer pool labels Oct 29, 2026
Copilot AI balanced review requested due to automatic review settings October 29, 2026 02:39
@thiras thiras self-assigned this Oct 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread crates/cli/tests/origin_import.rs Resolved
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]>
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 9d7df5a fix/bundle-path-coll... eb52976 +/-
77% 77% 0%
View coverage of the 6 most impacted files.
File main 9d7df5a fix/bundle-path-coll... eb52976 +/-
crates/client/s...undle/engine.rs 65% 65% 0%
crates/node/src...s/client/mod.rs 91% 91% 0%
crates/node/src...gin/pull_leg.rs 84% 84% 0%
crates/cli/src/...nds/manifest.rs 95% 95% 0%
crates/cli/src/...mands/origin.rs 90% 90% 0%
crates/client/src/bundle.rs 37% 40% +3%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@thiras
thiras merged commit 8473f6e into main Oct 29, 2026
39 checks passed
@thiras
thiras deleted the fix/bundle-path-collisions-2691 branch October 29, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:client decdn-client SDK: paid pull, lanes, buyer pool kind:security Security impact; report a vulnerability to [email protected], not here

Projects

None yet

Development

Successfully merging this pull request may close these issues.

client: duplicate or case-folded bundle manifest paths poison the skip set

2 participants