Skip to content

fix(cli): route --*clude-from and merge-file opens through the ownership walk - #7426

Merged
oferchen merged 1 commit into
masterfrom
fix/cli-aux-file-ownership-walk
Aug 21, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/cli-aux-file-ownership-walk

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Problem

Upstream opens every filter file through open_no_attacker_symlinks()
(exclude.c:1683), which walks each path component with O_NOFOLLOW and
follows a symlink only when its owner is root or our euid (syscall.c:406).

oc's two CLI-side filter-file opens used a plain File::open, so a component
symlink planted by another uid was followed. That is the excludefrom-symlink
cell of the upstream 3.5.0 testsuite.

Change

Both sites in crates/cli/src/frontend/filter_rules/sources.rs now open
through one seam backed by fast_io::operator_open_read (oc's existing,
already-tested port of the upstream primitive):

  • load_filter_file_patterns - --exclude-from / --include-from
  • read_merge_file - a merge / . rule's file

Upstream fidelity notes

A refusal needs no new error arm. Upstream reaches one if (!fp) block for
every open failure, and this call site passes XFLG_FATAL_ERRORS
(exclude.c:1587), so the failure is fatal either way. A refused open reports
through the existing "failed to open {in,ex}clude file" path unchanged. This is
deliberately unlike the per-directory merge loaders, which upstream runs
without XFLG_FATAL_ERRORS and therefore skips silently.

Confinement is a separate, non-uniform decision - not applied here. Upstream
has two orthogonal protections, and syscall.c:185-240 is explicit that they
cover different option sets: the ownership walk applies to all aux files, while
operator_path_resolve root-confinement covers only
--partial-dir/--backup-dir/alt-basis/merge paths - --log-file, --*-from,
lock and motd "may legitimately live elsewhere". This PR ships the walk only.
Composing the module-root half is tracked separately; a blanket application
would create a new divergence.

The cfg(unix) split stays at the call site. fast_io::owner_walk is
Unix-only. Hiding the fallback behind a cross-platform export would turn a
security control into a silent File::open on Windows; spelling the cfg here
keeps that visible.

Verification

  • Targeted: cli filter/merge suite 26/26 green.
  • cargo fmt --all -- --check clean; clippy -p cli --all-targets --all-features -D warnings clean.
  • Manifest: excludefrom-symlink fail -> pass in the root pipe leg, in this
    commit. Row count still 345. The nonroot leg records the cell skip (it needs
    root to plant a cross-uid symlink) and the TCP legs do not carry it, so those
    three manifests are untouched.

Limit of the local test, stated plainly. The added test
(a_self_owned_symlink_to_a_filter_file_is_still_read) pins the over-refusal
direction - a symlink we own must still be followed. It does not
discriminate the fix: mutating the seam back to File::open leaves it green,
because on a single-uid non-root machine the two are behaviourally identical for
every constructible fixture. The refusal itself is proven only by the root
testsuite leg in CI, which plants the cross-uid symlink. Recording this rather
than implying the unit test proves the routing.

…hip walk

upstream exclude.c:1683 opens every filter file named by a rule or by
--exclude-from/--include-from with open_no_attacker_symlinks(), which walks
each component with O_NOFOLLOW and follows a symlink only when its owner is
root or our euid (syscall.c:406). oc's two CLI-side filter-file opens used a
plain File::open, so a component symlink planted by another uid was followed.

Both sites are fatal on open failure upstream (exclude.c:1587 passes
XFLG_FATAL_ERRORS), so a refusal needs no new arm - it reports through the
existing "failed to open {in,ex}clude file" path, exactly as any other
fp == NULL does.

The cfg(unix) split stays at the call site rather than moving behind a
cross-platform fast_io export: an implicit File::open fallback would make the
absence of this control on non-Unix invisible to a reader of the function.

Flips excludefrom-symlink to pass in the root pipe manifest. The nonroot leg
records it skip (the cell needs root to plant a cross-uid symlink) and the TCP
legs do not carry it, so those manifests are unchanged.
@github-actions github-actions Bot added the bug Something isn't working label Aug 21, 2026
@oferchen
oferchen merged commit f230c25 into master Aug 21, 2026
70 checks passed
@oferchen
oferchen deleted the fix/cli-aux-file-ownership-walk branch August 21, 2026 15:40
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 (#7426)

upstream exclude.c:1683 opens every filter file named by a rule or by
--exclude-from/--include-from with open_no_attacker_symlinks(), which walks
each component with O_NOFOLLOW and follows a symlink only when its owner is
root or our euid (syscall.c:406). oc's two CLI-side filter-file opens used a
plain File::open, so a component symlink planted by another uid was followed.

Both sites are fatal on open failure upstream (exclude.c:1587 passes
XFLG_FATAL_ERRORS), so a refusal needs no new arm - it reports through the
existing "failed to open {in,ex}clude file" path, exactly as any other
fp == NULL does.

The cfg(unix) split stays at the call site rather than moving behind a
cross-platform fast_io export: an implicit File::open fallback would make the
absence of this control on non-Unix invisible to a reader of the function.

Flips excludefrom-symlink to pass in the root pipe manifest. The nonroot leg
records it skip (the cell needs root to plant a cross-uid symlink) and the TCP
legs do not carry it, so those manifests are unchanged.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant