Repository navigation
fix(engine): confine the local-copy alt-dest basis stat to the ownership walk - #7463
Merged
Merged
Conversation
…hip walk A --link-dest / --copy-dest / --compare-dest argument is an operator-supplied path, so it may legitimately point outside the transfer tree and location cannot be the trust signal. Upstream makes authority the signal instead: basis_link_stat() (generator.c:962) resolves the parent with owner_walk_parent() and lstats the leaf through the returned descriptor, so a symlink component owned by neither uid 0 nor our euid is refused. A refusal makes the basis look absent and the file transfers normally, which is what every one of its four call sites does with the -1 (generator.c:1084, :1110, :1227, :1254). The local-copy engine resolved its basis candidates with a plain fs::symlink_metadata at all four of its matching sites, so an unprivileged user who controls a directory along the basis path could swap a component for a symlink and redirect the stat - and then the hard link, the copy, or the --compare-dest skip - at a file of their choosing. Measured against real upstream 3.5.0 as root with a nobody-owned parent symlink and a matching basis, --link-dest: upstream, euid-owned link nlink=2 (follows, links) upstream, foreign-owned nlink=1 (refuses, transfers fresh) oc, euid-owned link nlink=2 (control: instrument valid) oc, foreign-owned nlink=2 (followed and hard-linked) --compare-dest showed the same class: oc skipped the file where upstream transferred it. The non-matching-basis rows transfer on both, which is what rules out a fallback difference and leaves "followed the link". The receiver already carried a complete port of this rule (receiver/quick_check.rs::basis_stat); the local-copy path is its unhardened twin. The mechanism moves into fast_io::operator_symlink_metadata so both sides share one implementation, and the receiver's OwnerWalk arm now delegates to it. Local copy is never a daemon worker, so it has no analogue of upstream's am_daemon plain-stat fall-through. The three new fast_io cells pin the contract - a leaf symlink reports as a symlink, a euid-owned parent component is still followed, a missing leaf is an error - and the last of those is what a careless "refuse every symlink" change would break. They do NOT discriminate the walk from a plain stat: that requires a symlink owned by a foreign uid and therefore root, so the discriminating cells are the root testsuite's operator-path alt-dest rows.
The root pipe leg reported exactly three expected-result mismatches against
this branch:
operator-path-compare-dest: expected fail, got pass (xpass)
operator-path-copy-dest: expected fail, got pass (xpass)
operator-path-link-dest: expected fail, got pass (xpass)
overall result is 3
Those three cells plant a symlink owned by a non-self uid and assert that the
alt-dest basis is not reached through it - which is precisely the confinement
this branch restores, so they now pass. The manifest is the ledger: leaving
them recorded as `fail` is what would be the waiver, because a future
regression would then be reported as the expected outcome and pass silently.
⚠ The header says regenerate rather than hand-edit. This edit is equivalent to
a regeneration and is derived from a real run, not typed: the gate compares all
345 outcomes and enumerated exactly these three as mismatched, so a regenerated
manifest differs from the committed one in exactly these three rows. Row count
is unchanged at 345 (254 pass / 37 fail / 54 skip, was 251/40/54).
Deliberately untouched:
- upstream-3.5.0-expect.nonroot.txt already records all three as `pass` - the
cells need root to plant a foreign-uid symlink and self-skip without it.
- Neither TCP manifest contains these cells at all, which is why the root TCP
leg reported `overall result is 0` on this same commit.
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
…hip walk (#7463) * fix(engine): confine the local-copy alt-dest basis stat to the ownership walk A --link-dest / --copy-dest / --compare-dest argument is an operator-supplied path, so it may legitimately point outside the transfer tree and location cannot be the trust signal. Upstream makes authority the signal instead: basis_link_stat() (generator.c:962) resolves the parent with owner_walk_parent() and lstats the leaf through the returned descriptor, so a symlink component owned by neither uid 0 nor our euid is refused. A refusal makes the basis look absent and the file transfers normally, which is what every one of its four call sites does with the -1 (generator.c:1084, :1110, :1227, :1254). The local-copy engine resolved its basis candidates with a plain fs::symlink_metadata at all four of its matching sites, so an unprivileged user who controls a directory along the basis path could swap a component for a symlink and redirect the stat - and then the hard link, the copy, or the --compare-dest skip - at a file of their choosing. Measured against real upstream 3.5.0 as root with a nobody-owned parent symlink and a matching basis, --link-dest: upstream, euid-owned link nlink=2 (follows, links) upstream, foreign-owned nlink=1 (refuses, transfers fresh) oc, euid-owned link nlink=2 (control: instrument valid) oc, foreign-owned nlink=2 (followed and hard-linked) --compare-dest showed the same class: oc skipped the file where upstream transferred it. The non-matching-basis rows transfer on both, which is what rules out a fallback difference and leaves "followed the link". The receiver already carried a complete port of this rule (receiver/quick_check.rs::basis_stat); the local-copy path is its unhardened twin. The mechanism moves into fast_io::operator_symlink_metadata so both sides share one implementation, and the receiver's OwnerWalk arm now delegates to it. Local copy is never a daemon worker, so it has no analogue of upstream's am_daemon plain-stat fall-through. The three new fast_io cells pin the contract - a leaf symlink reports as a symlink, a euid-owned parent component is still followed, a missing leaf is an error - and the last of those is what a careless "refuse every symlink" change would break. They do NOT discriminate the walk from a plain stat: that requires a symlink owned by a foreign uid and therefore root, so the discriminating cells are the root testsuite's operator-path alt-dest rows. * test(ci): record the three alt-dest operator-path cells as passing The root pipe leg reported exactly three expected-result mismatches against this branch: operator-path-compare-dest: expected fail, got pass (xpass) operator-path-copy-dest: expected fail, got pass (xpass) operator-path-link-dest: expected fail, got pass (xpass) overall result is 3 Those three cells plant a symlink owned by a non-self uid and assert that the alt-dest basis is not reached through it - which is precisely the confinement this branch restores, so they now pass. The manifest is the ledger: leaving them recorded as `fail` is what would be the waiver, because a future regression would then be reported as the expected outcome and pass silently. ⚠ The header says regenerate rather than hand-edit. This edit is equivalent to a regeneration and is derived from a real run, not typed: the gate compares all 345 outcomes and enumerated exactly these three as mismatched, so a regenerated manifest differs from the committed one in exactly these three rows. Row count is unchanged at 345 (254 pass / 37 fail / 54 skip, was 251/40/54). Deliberately untouched: - upstream-3.5.0-expect.nonroot.txt already records all three as `pass` - the cells need root to plant a foreign-uid symlink and self-skip without it. - Neither TCP manifest contains these cells at all, which is why the root TCP leg reported `overall result is 0` on this same commit.
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
Routes the local-copy alt-dest basis lookup onto the ownership walk, mirroring upstream's
basis_link_stat().A
--link-dest/--copy-dest/--compare-destargument is an operator-supplied path, so it may legitimately point outside the transfer tree and location cannot be the trust signal. Upstream makes authority the signal instead —generator.c:962 basis_link_stat():A symlink component owned by neither uid 0 nor our euid is refused, and every one of its four call sites (
generator.c:1084,:1110,:1227,:1254) turns the-1into acontinue— so a redirected basis simply looks absent and the file transfers normally.The local-copy engine resolved its basis candidates with a plain
fs::symlink_metadataat all four of its matching sites. An unprivileged user who controls a directory anywhere along the basis path could swap a component for a symlink and redirect the stat — and then the hard link, the copy, or the--compare-destskip — at a file of their choosing.Measured
Real upstream 3.5.0 vs
oc-rsync, run as root on Linux, parent symlink owned by uid 65534, basis byte-identical to the source.--link-dest:The
euid-ownedrow is the control that validates the instrument in both directions.--compare-destshowed the same class: oc skipped the file (destination left stale) where upstream transferred it. The non-matching-basis rows transfer on both impls, which is what rules out "wrong fallback on an unreadable basis" and leaves "followed the link".Shape
The receiver already carried a complete port of this rule (
crates/transfer/src/receiver/quick_check.rs::basis_stat, from #7421). The local-copy path is its unhardened twin. Rather than copy it:fast_io::operator_symlink_metadata(parent viaowner_trusted_parent, leaf viafstatat_nofollow, plus the(dev, ino)cross-check that makes the returnedstd::fs::Metadatasafe to carry),BasisTrust::OwnerWalkarm delegates to it,basis_stat.Local copy is never a daemon worker, so it has no analogue of upstream's
am_daemonplain-stat fall-through (generator.c:1010) — stated in the doc comment rather than left implicit.Tests, and what they do not prove
Three new
fast_iocells pin the contract: a leaf symlink reports as a symlink (so theis_file()filter drops it, which is what stops a symlinked basis entry being hard-linked), a euid-owned parent component is still followed, and a missing leaf is an error rather than a silent empty result.⚠ Stated plainly: these three do not discriminate the ownership walk from a plain path stat. Mutating
operator_symlink_metadataback tofs::symlink_metadataleaves all three green — the mutation kills nothing. The discriminating fixture needs a symlink owned by a foreign uid, which needs root; that is the same reason upstream marks its own matching cells root-only. The discriminating coverage is therefore the root testsuite leg'soperator-path-*-destcells, not a unit test, and the measured table above is the cross-implementation evidence.The follow-direction cells are still load-bearing: they are what a careless "confine it, refuse every symlink" change would break, and that over-refusal is the most likely regression a future edit introduces here.
Residuals (filed, not claimed as covered)
hard_link_oneinoperator_path_resolve = 1(generator.c:1120-1133) to close the stat→link race. This change fixes the stat gate, which is the substance; the race is a separate step.BasisTrust::for_receiverbranches only onis_daemon_connection, while upstream's predicate also carriesam_root >= 0(--fake-super) and!symlink_optout_allowed()(--insecure-links). oc is therefore stricter than upstream in those two cells — the opposite direction, and deliberately not folded into a security fix.