Repository navigation
fix(client): reject bundle path segments that are not portable file names - #2749
Merged
Merged
Conversation
…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]>
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. Updated |
There was a problem hiding this comment.
🟡 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
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]>
…dle-paths # Conflicts: # CHANGELOG.md
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-jr93-46mf-88wx (low bundle) and the follow-up to #2747.
:, 8.3 names) can make two bundle entry paths one file #2746. Windows joinsREADME,README.andREADMEwith a trailing space into one file, and resolvesREADME::$DATA(a stream),NUL.txt(a device) andLONGFI~1.TXT(an 8.3 short name) to something other than the path suggests.Path::components()returns each as oneNormalcomponent, so client: duplicate or case-folded bundle manifest paths poison the skip set #2691's skip-set poisoning could come back on Windows.decdn getprinted manifest paths raw, so a publisher could put terminal escape sequences in a path. The dry-run listing also printed paths thatsafe_joinlater rejected.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.BundleManifest::parsefails withMalformedManifestand names the segment Debug-escaped.decdn get, cached manifests,decdn quoteand the gateway all go through it.safe_joinchecks every segment, so a manifest built withBundleManifest::newfails each such entry.validate_relpathchecks every component during the walk, soorigin import(including--subfolderand single-file names) refuses the tree before it imports, moves or writes anything.failed:lines and the progress labels pass paths throughpull_progress::terminal_safe. It escapes control characters only, so quotes and non-ASCII still print as they are;str::escape_debugwould printBob'sasBob\'s.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 importrefuses a tree that holds one. A notable case is macOS'sIcon\rcustom-icon file: exclude it or remove it before import. Pre-mainnet, so no compatibility path.Reviewer notes
path_segment_problemincrates/client/src/bundle.rsfirst, then its three callers.:, 8.3 names) can make two bundle entry paths one file #2746's "confirm on Windows" box: the rule refuses these names on every platform, so the fix does not depend on how cap-std reachesCreateFileW.parsenow also refuses..,.and empty segments up front. Before, it accepted them and the pull failed the entry. No existing test depended on the old behavior.Verification
cargo denyreports the existing RUSTSEC-2026-0387 advisory, warn-only, already on main)cargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run --workspace: 6162 passedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemsdecdn-client:.snapregenerated (one added line,path_segment_problem)adr/:make -C adr check-refs; thearchitecture.mdsummary needs no changeCHANGELOG.mdentryWireEntry::parsefailsparse_manifest_rejects_an_unportable_path_segment; a pass-throughterminal_safefailsterminal_safe_escapes_control_characters_only.🤖 Generated with Claude Code