Repository navigation
fix(receiver): stat alt-dest basis via the ownership walk - #7421
Merged
Merged
Conversation
oferchen
force-pushed
the
fix/alt-dest-confined-parent
branch
from
August 21, 2026 09:23
a536e95 to
01307b4
Compare
oferchen
marked this pull request as draft
August 21, 2026 09:28
Owner
Author
|
Marking draft: the required Both fail at every protocol (unforced and fp=28..32), in the Ruled out so far, by measurement on macOS against the same shapes:
So the trigger is Linux-specific and not reproducible here. Not merging until it is root-caused; the earlier |
The receiver resolved a `--compare-dest` / `--copy-dest` / `--link-dest` basis entry with a plain path stat, which walks every component of a peer-supplied entry name at call time. Upstream reaches the same entry through `owner_walk_parent()` plus `link_stat_at()` (generator.c:979-990), so a symlink component owned by neither root nor our euid is refused with ELOOP instead of followed. Route the basis stat onto `fast_io::owner_walk`, the same primitive the sibling operator-path families already use for --temp-dir and --backup-dir. Only the parent is walked: the leaf is `fstatat(AT_SYMLINK_NOFOLLOW)`'d and never opened, because upstream must report a symlink at the basis name AS a symlink for its `!S_ISREG` filter to drop it, and because opening would demand read permission the --link-dest hard-link path does not need. The `fs::Metadata` handed downstream comes from a second path stat that is accepted only when it names the same (dev, ino) the confined stat saw, so a parent flipped between the two calls is refused. Measured against real rsync 3.5.0: a self-owned symlinked parent is traversed by both implementations, and that half is now pinned. The refusing half needs a foreign-owned symlink and therefore root to construct; it stays pinned at the predicate, by owner_walk's `refuses_an_owner_that_is_neither_root_nor_the_euid`.
The alt-dest basis lookup stats a file two ways - `fstatat` through the confined dirfd and `symlink_metadata` by path - and accepts the second only when it names the same `(dev, ino)` as the first. That cross-check silently degrades into "basis absent" on any target where the two stat APIs disagree, and the comparison is not a tautology: `fstatat_nofollow` calls `libc::fstatat`, while `std` on Linux goes through `statx` and rebuilds `st_dev` from the returned major/minor pair. Pin the agreement directly so the platform where it stops holding fails loudly and by name instead of surfacing as a mis-attributed transfer.
oferchen
force-pushed
the
fix/alt-dest-confined-parent
branch
from
August 21, 2026 14:33
a6c3ccf to
b3ccc59
Compare
`basis_link_stat()` has three arms, and only the first belongs to a
non-daemon receiver:
1. `!am_daemon && am_root >= 0 && !symlink_optout_allowed()` resolves the
basis parent through the ownership walk (generator.c:978).
2. `am_daemon && !am_chrooted && path[0] == '/'` walks it with module-root
confinement (generator.c:993).
3. everything else takes a plain `link_stat()` (generator.c:1010).
The ownership walk was being applied unconditionally, so a daemon receiver
took arm 1 where upstream takes arm 3. That is not just stricter than
upstream, it is inoperative: the walk opens every component starting at `/`,
and a daemon worker is confined - chroot, or a Landlock ruleset rooted at the
module - precisely so the module's ancestors are not openable. The first
`openat("/")` returns EACCES, the basis looks absent, and every file is
re-transferred. Upstream's own note on arm 2 covers this exact shape: a
relative basis such as `--link-dest=../01` is a dest-relative sibling whose
`../` `sanitize_path` has already clamped to the module root, so it "must
keep the plain link_stat below (#915/#930)".
Arm selection is spelled as a `BasisTrust` value rather than a bare bool so
neither arm can be picked by accident at a call site. Arm 2 (an absolute
basis under module-root confinement) is not implemented here; on that path
the receiver keeps the path-based stat it has always used, so this is no
weaker than before in any configuration.
Measured on Linux against the upstream 3.5.0 testsuite cell
`link-dest-relative-basis`, which exercises `--link-dest`, `--copy-dest` and
`--compare-dest` over a daemon push: it is `pass` in both pipe manifests, and
the unconditional walk turned it red.
oferchen
marked this pull request as ready for review
August 21, 2026 16:31
This was referenced Aug 23, 2026
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…7477) The docs were last refreshed at #7423; 55 PRs have merged since, and the testsuite figures they quote had drifted far enough to understate the current state by roughly half. CHANGELOG: fill in Unreleased for everything merged since #7423. The dominant theme is routing every operator-named auxiliary file open onto the ownership walk - upstream's open_no_attacker_symlinks() applied at the call sites upstream applies it - plus a daemon hardening batch and an alt-dest correctness batch. README and SECURITY: the per-leg outcome tables were re-derived from the committed expect manifests rather than carried forward. Failures fell and the corpus grew, so every figure moved: non-root pipe 43 -> 21 fail (345 -> 349 corpus) root pipe 62 -> 29 fail (345 -> 349 corpus) non-root tcp 42 -> 29 fail (155 -> 158 corpus) root tcp 55 -> 38 fail (155 -> 158 corpus) Distinct divergences: 64 -> 31 across the two full-corpus legs, 89 -> 55 across all four. SECURITY, two CVE rows that had gone stale: - CVE-2026-53790 said "under audit". The refusal has since been applied at the live sink - oc-rsync's own single-character config expander, which upstream does not have, so an upstream-shaped port alone would have been inert (#7465, #7430, #7445). - CVE-2026-53795 listed only the staging family. The auxiliary-file family followed it onto the walk (#7421-#7426, #7439, #7441-#7443, #7459, #7463); what remains is the per-option-family confinement.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* fix(receiver): stat alt-dest basis via the ownership walk
The receiver resolved a `--compare-dest` / `--copy-dest` / `--link-dest`
basis entry with a plain path stat, which walks every component of a
peer-supplied entry name at call time. Upstream reaches the same entry
through `owner_walk_parent()` plus `link_stat_at()` (generator.c:979-990),
so a symlink component owned by neither root nor our euid is refused with
ELOOP instead of followed.
Route the basis stat onto `fast_io::owner_walk`, the same primitive the
sibling operator-path families already use for --temp-dir and --backup-dir.
Only the parent is walked: the leaf is `fstatat(AT_SYMLINK_NOFOLLOW)`'d and
never opened, because upstream must report a symlink at the basis name AS a
symlink for its `!S_ISREG` filter to drop it, and because opening would
demand read permission the --link-dest hard-link path does not need. The
`fs::Metadata` handed downstream comes from a second path stat that is
accepted only when it names the same (dev, ino) the confined stat saw, so a
parent flipped between the two calls is refused.
Measured against real rsync 3.5.0: a self-owned symlinked parent is
traversed by both implementations, and that half is now pinned. The
refusing half needs a foreign-owned symlink and therefore root to
construct; it stays pinned at the predicate, by owner_walk's
`refuses_an_owner_that_is_neither_root_nor_the_euid`.
* test(fast_io): pin AtMetadata against std::fs::Metadata on one file
The alt-dest basis lookup stats a file two ways - `fstatat` through the
confined dirfd and `symlink_metadata` by path - and accepts the second only
when it names the same `(dev, ino)` as the first. That cross-check silently
degrades into "basis absent" on any target where the two stat APIs disagree,
and the comparison is not a tautology: `fstatat_nofollow` calls
`libc::fstatat`, while `std` on Linux goes through `statx` and rebuilds
`st_dev` from the returned major/minor pair.
Pin the agreement directly so the platform where it stops holding fails
loudly and by name instead of surfacing as a mis-attributed transfer.
* fix(receiver): keep the plain basis stat on a daemon receiver
`basis_link_stat()` has three arms, and only the first belongs to a
non-daemon receiver:
1. `!am_daemon && am_root >= 0 && !symlink_optout_allowed()` resolves the
basis parent through the ownership walk (generator.c:978).
2. `am_daemon && !am_chrooted && path[0] == '/'` walks it with module-root
confinement (generator.c:993).
3. everything else takes a plain `link_stat()` (generator.c:1010).
The ownership walk was being applied unconditionally, so a daemon receiver
took arm 1 where upstream takes arm 3. That is not just stricter than
upstream, it is inoperative: the walk opens every component starting at `/`,
and a daemon worker is confined - chroot, or a Landlock ruleset rooted at the
module - precisely so the module's ancestors are not openable. The first
`openat("/")` returns EACCES, the basis looks absent, and every file is
re-transferred. Upstream's own note on arm 2 covers this exact shape: a
relative basis such as `--link-dest=../01` is a dest-relative sibling whose
`../` `sanitize_path` has already clamped to the module root, so it "must
keep the plain link_stat below (#915/#930)".
Arm selection is spelled as a `BasisTrust` value rather than a bare bool so
neither arm can be picked by accident at a call site. Arm 2 (an absolute
basis under module-root confinement) is not implemented here; on that path
the receiver keeps the path-based stat it has always used, so this is no
weaker than before in any configuration.
Measured on Linux against the upstream 3.5.0 testsuite cell
`link-dest-relative-basis`, which exercises `--link-dest`, `--copy-dest` and
`--compare-dest` over a daemon push: it is `pass` in both pipe manifests, and
the unconditional walk turned it red.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…7477) The docs were last refreshed at #7423; 55 PRs have merged since, and the testsuite figures they quote had drifted far enough to understate the current state by roughly half. CHANGELOG: fill in Unreleased for everything merged since #7423. The dominant theme is routing every operator-named auxiliary file open onto the ownership walk - upstream's open_no_attacker_symlinks() applied at the call sites upstream applies it - plus a daemon hardening batch and an alt-dest correctness batch. README and SECURITY: the per-leg outcome tables were re-derived from the committed expect manifests rather than carried forward. Failures fell and the corpus grew, so every figure moved: non-root pipe 43 -> 21 fail (345 -> 349 corpus) root pipe 62 -> 29 fail (345 -> 349 corpus) non-root tcp 42 -> 29 fail (155 -> 158 corpus) root tcp 55 -> 38 fail (155 -> 158 corpus) Distinct divergences: 64 -> 31 across the two full-corpus legs, 89 -> 55 across all four. SECURITY, two CVE rows that had gone stale: - CVE-2026-53790 said "under audit". The refusal has since been applied at the live sink - oc-rsync's own single-character config expander, which upstream does not have, so an upstream-shaped port alone would have been inert (#7465, #7430, #7445). - CVE-2026-53795 listed only the staging family. The auxiliary-file family followed it onto the walk (#7421-#7426, #7439, #7441-#7443, #7459, #7463); what remains is the per-option-family confinement.
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
The receiver resolved a
--compare-dest/--copy-dest/--link-destbasisentry with a plain
fs::symlink_metadata, which re-walks every component of apeer-supplied entry name at call time. Upstream reaches the same entry
through
owner_walk_parent()+link_stat_at()(generator.c:979-990), so asymlink component owned by neither root nor our euid is refused with
ELOOPrather than traversed.
This routes the basis stat onto
fast_io::owner_walk- the same primitive thesibling operator-path families already use for
--temp-dir(#7398) and--backup-dir(#7404).Why this shape
Only the parent is walked. The leaf is
fstatat(AT_SYMLINK_NOFOLLOW)'d andnever opened:
!S_ISREGfilter drops it. Opening the leaf resolves it, which measurablyre-opens the hole fix(receiver): never follow a symlinked alt-dest basis entry #7419 just closed - the existing
link_dest_skips_symlink_basis_entrycell caught exactly that while this wasbeing built.
--link-desthard-linkpath does not need.
The
fs::Metadatahanded downstream comes from a second path stat, acceptedonly when it names the same
(dev, ino)the confined stat saw. That keepsquick_check_matches/metadata_unchangedon theirstdtypes while makinga parent flipped between the two calls refusable rather than silently followed.
Scope, stated plainly
The ownership walk's rule is ownership, not location: uid 0 or our euid is the
operator's own layout (
--link-dest=/backupwherebackup -> /mnt/disk) and isfollowed; any other uid is refused.
Measured against real rsync 3.5.0: with
basis/sub -> ../outsideowned bythe invoking user, upstream consumes the basis and does not transfer
sub/payload.bin. oc did the same before this change, so the traversing half isunchanged - and it is now pinned, because breaking it would break the deployments
that rely on it.
The half that changes behaviour needs a foreign-owned symlink and therefore
root to construct, so it is not reachable from a non-root
nextestcell. Itstays pinned at the predicate, by
owner_walk's existingrefuses_an_owner_that_is_neither_root_nor_the_euid.Verification
symlink_basis_tests6/6, including the three--copy-dest/--link-dest/--compare-destleaf cells from fix(receiver): never follow a symlinked alt-dest basis entry #7419 as the regression guard.-p transfer --all-features: 2762 run, 2762 passed, 3 skipped.cargo fmt --all -- --checkclean;clippy -p transfer -p fast_io --all-targets --all-features -D warningsclean.rsync-3.5.0binary on thesymlinked-parent and real-parent cells.
Closes the alt-dest half of the operator-path confinement family.