Skip to content

fix(client): reject bundle path segments that are not portable file names - #2749

Merged
thiras merged 3 commits into
mainfrom
fix/2746-portable-bundle-paths
Oct 29, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2746-portable-bundle-paths

Conversation

@thiras

@thiras thiras commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

GHSA-jr93-46mf-88wx (low bundle) and the follow-up to #2747.

One predicate, decdn_client::bundle::path_segment_problem, now decides whether a segment is a portable file name, on every platform. It refuses a segment that is empty, . or .., or that holds a control character (C0/DEL/C1) or one of \ : * ? " < > |, or that ends in . or a space, or whose stem is a Windows device name (CON PRN AUX NUL COM0-9 LPT0-9, any case, any extension), or whose stem ends in ~ and digits after a non-empty base.

  • Reader: BundleManifest::parse fails with MalformedManifest and names the segment Debug-escaped. decdn get, cached manifests, decdn quote and the gateway all go through it.
  • Pull: safe_join checks every segment, so a manifest built with BundleManifest::new fails each such entry.
  • Publisher: validate_relpath checks every component during the walk, so origin import (including --subfolder and single-file names) refuses the tree before it imports, moves or writes anything.
  • CLI output: the dry-run listing, the failed: lines and the progress labels pass paths through pull_progress::terminal_safe. It escapes control characters only, so quotes and non-ASCII still print as they are; str::escape_debug would print Bob's as Bob\'s.
  • ADR appendix-bundles.md § Path-safety rules, rule 8; CHANGELOG Security entry.

Closes #2746
Closes #2705

Breaking

A published bundle with such a path no longer parses, and origin import refuses a tree that holds one. A notable case is macOS's Icon\r custom-icon file: exclude it or remove it before import. Pre-mainnet, so no compatibility path.

Reviewer notes

Verification

  • Commit hooks (fmt, clippy, doc, markdownlint, ADR hygiene; cargo deny reports the existing RUSTSEC-2026-0387 advisory, warn-only, already on main)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run --workspace: 6162 passed
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items
  • Public API of decdn-client: .snap regenerated (one added line, path_segment_problem)
  • adr/: make -C adr check-refs; the architecture.md summary needs no change
  • CHANGELOG.md entry
  • Mutation checks: a no-op predicate in WireEntry::parse fails parse_manifest_rejects_an_unportable_path_segment; a pass-through terminal_safe fails terminal_safe_escapes_control_characters_only.

🤖 Generated with Claude Code

…ames

Windows joins README, "README." and "README " into one file, and resolves
a `:` stream name, a device name and an 8.3 short name to something other
than the path suggests, so two entries could still land at one file there
after #2691. A publisher could also put terminal escapes in a path that
`decdn get` printed raw.

path_segment_problem refuses a segment with a control character, a
Windows-reserved character, a trailing dot or space, a device-name stem or
the 8.3 `~N` stem form, on every platform. BundleManifest::parse rejects
such a manifest, safe_join fails such an entry, and origin import refuses
such a tree before it writes anything. The CLI escapes control characters
in the dry-run listing, the failure lines and the progress labels.
appendix-bundles.md gains Path-safety rule 8.

Closes #2746
Closes #2705

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 03:27
@github-code-quality

github-code-quality Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 94e180d fix/2746-portable-bu... f6f66a1 +/-
77% 77% 0%
View coverage of the 6 most impacted files.
File main 94e180d fix/2746-portable-bu... f6f66a1 +/-
crates/node/src...s/client/mod.rs 91% 91% 0%
crates/cli/src/...nds/manifest.rs 95% 95% 0%
crates/client/s...undle/engine.rs 65% 65% 0%
crates/cli/src/...ull_progress.rs 76% 77% +1%
crates/cli/src/.../bundle_pull.rs 61% 62% +1%
crates/client/src/bundle.rs 40% 47% +7%

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


Updated October 29, 2026 04:00 UTC

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

Optimized imports can move source files or write to the store before validation rejects them, while Windows device-name checks remain incomplete and a path-validation test fails on Windows.

3 open issues
What changed in this PR

This PR strengthens bundle path safety across deCDN readers, downloads, and publishing. It addresses Windows filename aliasing and terminal escape injection, building on the earlier path-collision checks.

Changes:

  • Adds shared portable-filename validation to manifest parsing, download paths, and publisher path checks.
  • Escapes control characters in CLI listings, failure paths, and progress labels.
  • Adds regression tests and documents the stricter bundle requirements.
File Description
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records the new public validation helper.
crates/​client/​src/​bundle/​engine/​tests.rs Tests segment validation, parsing, and safe joins.
crates/​client/​src/​bundle/​engine.rs Rejects nonportable segments before joining paths.
crates/​client/​src/​bundle.rs Defines shared validation and applies it during parsing.
crates/​cli/​tests/​origin_import.rs Tests directory rejection without import side effects.
crates/​cli/​src/​commands/​pull_progress/​tests.rs Tests control-character escaping.
crates/​cli/​src/​commands/​pull_progress.rs Escapes paths used in progress labels.
crates/​cli/​src/​commands/​manifest/​tests.rs Tests publisher path rejection.
crates/​cli/​src/​commands/​manifest.rs Applies shared validation to publisher paths.
crates/​cli/​src/​commands/​bundle_pull.rs Escapes paths in listings and failure output.
CHANGELOG.md Documents security fixes and compatibility impact.
adr/​appendix-bundles.md Specifies portable segments and safe CLI output.

Review effort: Balanced

Comment thread crates/cli/src/commands/manifest.rs Resolved
Comment thread crates/client/src/bundle.rs Resolved
thiras and others added 2 commits October 29, 2026 06:49
import_single_optimized imported the file (and with --move, moved it into
the store) before validate_relpath refused its name, so `README.` with
--optimize --move left the source in the store and failed. Validate first.

Also refuse the superscript device names Windows reserves (COM¹–³,
LPT¹–³), and keep the `a:b` test case off the front of the path, where
Windows parses `a:` as a drive prefix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit ca076a0 into main Oct 29, 2026
37 checks passed
@thiras
thiras deleted the fix/2746-portable-bundle-paths branch October 29, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants