Repository navigation
test: port link-dest module-escape rejection to nextest - #5900
Merged
Merged
Conversation
Pin the daemon's `--link-dest` / `--copy-dest` / `--compare-dest` path-validation invariant against four module-escape scenarios drawn from the upstream `alt-dest-symlink-race.test` / `link-dest-module- escape` security pin: - relative `--link-dest=../etc/passwd` from a dest at the module root must be silently dropped (lexical climb past the module root); - relative in-module sibling `--link-dest=../01` from `dest/00/` must survive as a legitimate basis (positive control matching upstream `main.c:1199-1206`); - an in-module symlink `mod/cd -> /outside` used as `--link-dest=cd` must canonicalise out of the module root and be dropped (the exact attack shape from upstream `alt-dest-symlink-race.test`); - an absolute `--link-dest` pointing outside the module root must be dropped (canonicalise-with-lexical-fallback branch). The tests exercise `confine_basis_under_module`, the daemon-side defence introduced in PR #5778 / extended via URV-5.b.1.c. They lock in the silent-drop contract upstream `util1.c:1035 sanitize_path` and `main.c:841 check_alt_basis_dirs` model, guarding against a future regression to either a hard `@ERROR` reject or admission of the escape into `cfg.reference_directories`.
oferchen
force-pushed
the
test/uts-nextest-link-dest-module-escape
branch
from
June 17, 2026 19:31
87751cd to
06623d5
Compare
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Pin the daemon's `--link-dest` / `--copy-dest` / `--compare-dest` path-validation invariant against four module-escape scenarios drawn from the upstream `alt-dest-symlink-race.test` / `link-dest-module- escape` security pin: - relative `--link-dest=../etc/passwd` from a dest at the module root must be silently dropped (lexical climb past the module root); - relative in-module sibling `--link-dest=../01` from `dest/00/` must survive as a legitimate basis (positive control matching upstream `main.c:1199-1206`); - an in-module symlink `mod/cd -> /outside` used as `--link-dest=cd` must canonicalise out of the module root and be dropped (the exact attack shape from upstream `alt-dest-symlink-race.test`); - an absolute `--link-dest` pointing outside the module root must be dropped (canonicalise-with-lexical-fallback branch). The tests exercise `confine_basis_under_module`, the daemon-side defence introduced in PR #5778 / extended via URV-5.b.1.c. They lock in the silent-drop contract upstream `util1.c:1035 sanitize_path` and `main.c:841 check_alt_basis_dirs` model, guarding against a future regression to either a hard `@ERROR` reject or admission of the escape into `cfg.reference_directories`.
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.
Summary
Pin the daemon's
--link-dest/--copy-dest/--compare-destpath-validation invariant against four module-escape scenarios drawn from the upstreamalt-dest-symlink-race.test/link-dest-module-escapesecurity pin. The tests extend the existing unit-test suite forconfine_basis_under_moduleincrates/daemon/src/daemon/sections/module_access/tests.rs(alongsideconfine_basis_drops_absolute_out_of_module,_dotdot_escape_to_sibling, etc.) so the daemon's basedir-confinement contract runs on every PR via the standard nextest matrix.Scenarios pinned
confine_basis_link_dest_relative_etc_passwd_escape_is_dropped: client sends--link-dest=../etc/passwdfrom a dest at the module root; the lexical normalisation collapses past the module root andstarts_with(module_root)rejects.confine_basis_link_dest_in_module_symlink_to_outside_is_dropped: ports the exact attack shape from upstreamalt-dest-symlink-race.test. An in-module symlinkmod/cd -> /outsideused as--link-dest=cdcanonicalises out of the module root and is dropped before the receiver's basis-file lookup can hard-link to attacker-readable files outside the module.confine_basis_link_dest_absolute_etc_passwd_is_dropped: absolute--link-destpointing outside the module root is dropped via the canonicalise-with-lexical-fallback containment check.confine_basis_link_dest_relative_in_module_sibling_is_accepted: relative--link-dest=../01fromdest/00/survives as a legitimate basis, matching upstreammain.c:1199-1206'scheck_alt_basis_dirs()afterget_local_name()chdir's into the dest.Lineage
target/interop/upstream-src/rsync-3.4.4/testsuite/alt-dest-symlink-race.test(thelink-dest-module-escapefamily; namedalt-dest-symlink-race.testin 3.4.3+).fix(daemon): silently drop out-of-module --link-dest/--copy-dest paths, extended via URV-5.b.1.c to inspect all three--{link,copy,compare}-destflags throughvalidate_client_paths_in_module/confine_basis_under_moduleincrates/daemon/src/daemon/sections/module_access/{transfer,client_args}.rs.Note on divergence from the upstream test's literal error string
Upstream rsync's daemon does NOT emit a literal "outside the module"
@ERRORfor these scenarios. Itsutil1.c:1035 sanitize_pathcollapses..against the module root depth (rewriting the path under the module) andmain.c:841 check_alt_basis_dirsonly warns when the resulting basis is missing or out-of-tree. PR #5778 aligned the oc-rsync daemon with that contract by switching from a hard@ERRORreject to a silent drop. These tests pin the silent-drop contract so a future regression to either the old@ERRORreject path or to admission of the escape cannot ship.Test plan
cargo fmt --all -- --checkclean locallymodule_access_testsmodule#[cfg(unix)]; the other three are portable and exercise the sameconfine_basis_under_moduleinvariant on every platform