Skip to content

fix: anchor receiver opens via held parent, local-copy delete fidelity - #8228

Merged
oferchen merged 21 commits into
masterfrom
fix/cve-53796-receiver-waves
Oct 20, 2026
Merged

oferchen merged 21 commits into
masterfrom
fix/cve-53796-receiver-waves

Conversation

@oferchen

@oferchen oferchen commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

CVE-2026-53796 receiver anchoring and rustls-webpki

  • Second wave of the CVE-2026-53796 receiver work: anchors the receiver's remaining destination probes, opens, cleanup and stats through the held destination parent instead of resolving the full path again, mirroring upstream's do_*_at() / held-dirfd model.
  • One held parent is now shared by the destination sandbox and metadata apply, so the extra parent opens the anchoring needs are paid once rather than twice.
  • Push of a fresh tree drops 20,600 syscalls (-7.8%). The remaining increases stay within the costs accepted for this CVE work.
  • Also bumps rustls-webpki 0.103.15 -> 0.103.16 (lockfile only) for RUSTSEC-2026-0382, which turned cargo-deny red on master and on every PR.

RUSTSEC-2026-0382 (rustls-webpki)

0.103.15 may accept certificate paths through the distrusted emSign intermediates, whose private keys are public. oc's only rustls user is the QUIC transport (rsync_io::quic). It verifies peers against the operator's --quic-ca store or pinned certificates and loads no public root set (no webpki-roots, native or platform verifier). Exposure therefore needs an emSign anchor in that store, but the patched release is semver-compatible, so bump. cargo clippy -p rsync_io --all-targets --all-features and the 58 QUIC tests pass on 0.103.16.

Local-copy delete and error fidelity (round 2)

  • Delete gating (local copy). A send-time open failure now blocks only the --delete-after pass. Before, it also suppressed deletions the walk had already decided under --delete-during and --delete-delay. upstream: sender errors reach the generator only after the send loop (sender.c:811-812), so only do_delete_pass sees them, and generator.c:304 gates on IOERR_GENERAL alone.
  • Vanished sources. A vanished source now gates no deletion and prints file has vanished once. The run ends with exit 24 and upstream's warning. upstream: IOERR_VANISHED gates nothing (generator.c:304), and cleanup.c:215-216 maps it to RERR_VANISHED.
  • Unreadable sources: wording. Every source that cannot be opened is reported as rsync: [sender] send_files failed to open "<path>": <error>. The run then ends with some files/attrs were not transferred (see previous errors) (code 23). Before, only the first failure was printed, folded into the final line, and every later one was lost (sender.c:711-722, log.c:98-99).
  • Unreadable sources: --stats. An unreadable source still counts as created and transferred in --stats (sender.c:625-635).
  • Busy mount points in --delete. A busy mount point (EBUSY) inside a doomed directory no longer aborts the recursive peel, so its siblings are still deleted.
    • Each entry that cannot be removed prints delete_file: rmdir(<name>) failed: <error> (delete.c:141-164, delete.c:264-266).
    • Under --max-delete, the failure no longer aborts the whole transfer.
    • cannot delete non-empty directory now uses the transfer-relative name instead of an absolute path.

Oracle: upstream 3.5.1 (/usr/bin/rsync) vs this branch

Every row matches upstream on exit code, filesystem outcome and diagnostics.

Case Fixture upstream 3.5.1 this branch master before
Open failure, --delete-during unreadable file + stale dest entries rc 23, stale deleted rc 23, stale deleted stale kept
Open failure, --delete-delay same rc 23, stale deleted rc 23, stale deleted stale kept
Open failure, --delete-before same rc 23, stale deleted rc 23, stale deleted -
Open failure, --delete-after same rc 23, stale kept rc 23, stale kept -
Vanished source, --delete / -after / -delay sibling removed mid-run rc 24, z/stale deleted, one file has vanished same stale kept
Unreadable file, -r and --delete-before sub/b.txt mode 000 send_files failed to open "D/src/sub/b.txt": Permission denied (13) + (code 23) summary same text failed to copy file in final line
--stats, unreadable 1000-byte file a.txt 5 B + sub/b.txt created 3 (reg 2, dir 1), transferred 2, total transferred 1,005, literal 5 same created 2, transferred 1, total 5
Busy tmpfs at dst/x/m, --delete / -after / -delay x/sib, x/m/inner rc 23, sib + inner deleted, x kept, rmdir(x/m) failed: Device or resource busy (16), stdout cannot delete non-empty directory: x same sib kept, no rmdir line, absolute path in notice
Busy tmpfs, --max-delete=10 same same as above, transfer completes same transfer aborted (a not copied)

Known remaining difference, out of scope: a local copy's Total bytes sent/received reports bytes copied rather than upstream's wire bytes. Local copies have no wire model.

Details

What is anchored (each step goes through the held parent dirfd of the destination directory):

Commit Sites
fix: apply macOS ACLs through the pinned destination fd macOS ACL apply
fix: anchor receiver directory, link and special probes directory create and touch-up, symlink and hard-link probes, device/FIFO probes (receiver/directory/*, itemize.rs)
fix: anchor receiver basis and destination opens basis-file open and destination writes
fix: anchor receiver backup, listing and partial-dir cleanup --backup renames, delete listing, --partial-dir cleanup
refactor: give destination stats a constructible metadata type EntryMetadata so anchored stats can feed metadata apply
perf: stat destinations with fstatat instead of an O_PATH open stat via fstatat on the held parent
perf: share one held parent between the sandbox and metadata apply DestinationRoot::sharing_held reuses the sandbox's Arc<HeldDir>
fix: stat regular-file destinations through the held parent Phase-B regular-file stat in receiver/transfer/candidates.rs (dest_lstat(follow=true))

Upstream parity: generator.c:2600-2602 (touch-up stats against the held directory) and the do_stat_at() / held_dfd_for() pattern in syscall.c.

HeldDir holds its mutex only for the cached lookup and, on a miss, the one parent open (fast_io/src/held_dir.rs:58-75). Operations then use the returned Arc<OwnedFd> outside the lock.

Measured (release builds, 10,100-file tree plus one deep path, quiet host, 9 interleaved rounds)

io is the strace -f -c total excluding futex and sched_yield (median of 3). master-copy is an identical second copy of the master binary, used as the noise floor.

Case master io branch io (delta) master-copy io (delta) branch wall master-copy wall
local fresh 350,964 350,961 (-3) 350,973 (+9) -0.4% -2.6%
local noop 177,376 177,376 (0) 177,378 (+2) +5.2% +6.1%
push fresh 264,607 244,007 (-20,600) 264,569 (-38) -1.8% +1.0%
push noop 147,261 147,318 (+57) 147,262 (+1) -0.8% -0.7%

The accepted costs for this work were +12 syscalls for the anchored touch-up stat (generator.c:2600-2602 parity) and about +132 for the anchored Phase-B stat, +144 in total. On current master the observed increases are all at or below that: the largest is +57, on push noop. Wall time stays within the master/master-copy noise in every case.

Residuals (later waves)

  • crates/transfer/src/disk_commit/process/metadata.rs:65: the pre-transfer stat on the disk-commit path still resolves the full path.
  • crates/transfer/src/disk_commit/process/file_ops.rs inplace_pre_transfer_stat: same, for --inplace.

CVE-2026-53796 stays "Partially fixed" in the CHANGELOG index until those are anchored.

Test plan

CVE-2026-53796 receiver anchoring and rustls-webpki

  • CI: fmt + clippy, nextest (stable), Windows, macOS, Linux musl, and cargo-deny (clears RUSTSEC-2026-0382).
  • cargo nextest run -p rsync_io --all-features -E 'test(quic)' on rustls-webpki 0.103.16: 58 passed
  • cargo fmt --all -- --check and python3 tools/ci/check_rustfmt_all.py
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings
  • cargo check --target x86_64-pc-windows-gnu -p fast_io -p metadata -p transfer -p engine --all-features
  • cargo nextest run -p transfer -p engine -p metadata -p fast_io -p filters -p daemon --all-features: 13,821 passed
  • cargo nextest run --all-features -E 'binary(destination_root_owner_walk) | binary(daemon_concurrent_module_confinement) | binary(nonutf8_network_receiver) | binary(receiver_generator_rsyserr) | binary(upstream_compat_inc_recurse_receiver_oracle) | binary(make_room_max_delete) | binary(daemon_transfer_logging_per_file) | binary(ssh_transport) | binary(daemon_client_filter_merge_does_not_read_hidden_file)': 74 passed
  • python3 tools/ci/unsafe_owner_deps.py, python3 tools/ci/dead_code_census.py, cargo run -p xtask -- no-placeholders, cargo run -p xtask -- citations, python3 tools/ci/citation_drift_audit.py --ratchet
  • Upstream 3.5.1 testsuite, master vs branch, EMIT_EXPECT_RESULT manifests identical: nonroot 274 passed on both, root 304 passed on both, 0 differing cells.

Local-copy delete and error fidelity (round 2)

  • CI: fmt + clippy, nextest (stable), Windows, macOS, Linux musl.
  • Every test below was written first and failed before its fix.
  • Every fix was then mutation-checked by reverting it and confirming that the targeted test fails:
  • Local gates run and passing:
    • cargo fmt --all -- --check and tools/ci/check_rustfmt_all.py;
    • scoped clippy -D warnings on engine, core, cli, fast_io and bin, for both the Linux and x86_64-pc-windows-gnu targets;
    • targeted nextest on engine, core, cli and fast_io, plus the root local-copy, delete, exit-code and stats tests;
    • unsafe_owner_deps, dead_code_census, xtask no-placeholders and citation_drift_audit.

Coordination

CVE-2026-53796 receiver anchoring and rustls-webpki

Local-copy delete and error fidelity (round 2)

  • Related PRs / issues: tasks 138-142.
  • Depends on: none.
  • Blocked by: none.

Conventional commit prefix

  • fix: - security fix (receiver path confinement), a dependency advisory bump, and local-copy fixes that mirror upstream.

Security considerations

CVE-2026-53796 receiver anchoring and rustls-webpki

  • Threat surface affected: the receiver's destination operations (directory, link and special probes, basis and destination opens, backup, listing and partial-dir cleanup, destination stats). Before this change a racing local attacker could swap a destination parent for a symlink between checks and steer one of these operations outside the destination tree.
  • Mitigations / tests added: every listed site now goes through the held destination parent dirfd, so a swapped parent is never re-resolved by path. Covered by receiver/tests/dest_parent_swap.rs, tests/destination_root_owner_walk.rs, and the existing sandbox carrier tests.
  • Cross-references: SECURITY.md (CVE-2026-53796 row), CHANGELOG.md Security section and CVE index.

Local-copy delete and error fidelity (round 2)

  • Threat surface affected: fast_io::recursive_unlinkat, the dirfd-anchored recursive peel.
    • A non-ENOTEMPTY rmdir failure on a nested directory is now recorded in UnlinkResidue::failures and stepped over. Before, it aborted the descent.
    • EACCES on a child unlink is recorded the same way.
    • The descent root's own rmdir failure is still returned to the caller.
  • Mitigations / tests added: no path resolution changed.
    • O_DIRECTORY | O_NOFOLLOW descent, ELOOP cycle refusal and the per-level openat errors still abort exactly as before.
    • Covered by the existing recursive_unlinkat_* tests and the new busy-mount root test.
  • Cross-references: SECURITY.md is unchanged.

Pre-merge checklist

  • Conventional commit prefix on PR title matches the change category.
  • cargo fmt --all run locally.
  • CHANGELOG.md updated if user-visible.
  • SECURITY.md updated if security-relevant. The CVE stays "Partially fixed" because of the residuals above, so no status change.
  • No references to internal tooling or non-human authoring aids; hyphens, not em-dashes.

Upstream's macOS build has no SUPPORT_ACL_FD (configure.ac:1512-1514),
so set_rsync_acl() sets the extended ACL by path (acls.c:1315-1322) and
re-walks every parent. A parent swapped for a symlink between the
confined pin and that call redirects the ACL outside the destination.

A confined macOS receiver now writes the ACL with acl_set_fd_np on the
O_NOFOLLOW leaf fd the xattr writes already hold. A refused pin skips
the ACL as upstream's xattr_refuse does; device and socket leaves keep
the path-based set. Entries are encoded as sys_acl_set_info() does
(lib/sysacls.c:2833-2874): allow/deny tag, the mbr_*_to_uuid qualifier,
then the permission and flag sets.

This is a deliberate improvement over upstream on macOS. FreeBSD keeps
upstream's path-based set until a FreeBSD CI job exists to exercise an
fd arm. Linux is unchanged.
The network receiver's directory, symlink, hard-link and special-file
passes still stat, read, chmod and re-time destination entries by path,
and create missing parents with fs::create_dir_all. A directory inside
the destination swapped for a symlink after entry could steer those
operations, including a mkdir chain, out of the tree.

Route them through the destination sandbox the way upstream resolves
every entry against the held destination (syscall.c held_dfd_for(),
util1.c make_path()):

- fast_io: one shared resolver (at_dest_leaf) backs the lstat, stat,
  metadata, chmod and utimes helpers. chmod and utimes gain the held
  parent and beneath-only arms, and utimes takes optional slots so an
  mtime repair leaves atime alone. create_dir_all_via creates missing
  parents one mkdirat at a time beneath the sandbox.
- transfer: directory classification, pre-transfer stats,
  touch_up_dirs, symlink readlink, probes and make_path, hard-link
  leader probes, special-file probes and make_path, and the symlink
  itemize stat use the anchored helpers.

Tests swap dest/a for a symlink to outside/ after the sandbox opens and
assert nothing under outside/ is created, chmodded or re-timed.
The generator opens the exact destination basis, and the receiver reads
the delta basis, beneath the held destination: held parent, single
component or RESOLVE_BENEATH anchor, with O_NOFOLLOW on the leaf. The
in-place output, the --write-devices target and the post-transfer
truncate and hole punch reopen the destination the same way.

A missing leaf under the held parent is now that directory's answer, as
upstream's held descriptor gives it, instead of dropping the cache and
re-resolving.

upstream: receiver.c:1086-1093, receiver.c:1212-1241, syscall.c:3858
Resolve the remaining receiver-side destination operations from the
pinned destination instead of by path, so a parent swapped for a
symlink after resolution cannot redirect them out of the tree.

- Nested directory listings open through the held parent dirfd
  (upstream: syscall.c:3858-3871 held_dfd_for) instead of falling back
  to std::fs::read_dir for any multi-component path.
- The backup ladder's link and rename tiers run the ownership walk from
  the held destination rather than from the absolute path, as upstream
  walks from the receiver's chdir'ed cwd (backup.c:445
  operator_path_resolve, syscall.c:1100 do_link_at, syscall.c:2026
  do_rename_at). A trusted in-tree symlink at the backup dir is still
  followed and a foreign one refused; an absolute --backup-dir walks
  from / as before. The existence and regular-file probes stat beneath
  the destination (backup.c:236 x_lstat).
- The --delete pre-delete backup probes the victim beneath the
  destination, so a present victim is never reported as vanished and
  unlinked without a backup.
- Partial-dir obstruction clearing and the emptied partial-dir rmdir
  resolve beneath the destination (upstream: util1.c handle_partial_dir
  PDIR_CREATE / PDIR_DELETE), for the commit, robust_rename and
  delayed-update callers.
- The in-place EACCES recovery arms (the protected_regular retry and
  the read-only recovery's probe and reopen) run through the same
  anchored opener as the first arm instead of falling back to the path
  chain (upstream: receiver.c:1212-1241), so an EACCES never hands the
  retry to a resolver a swapped parent could redirect.
std::fs::Metadata has no public constructor, so a destination stat
answered by fstatat beneath the pinned destination cannot be handed to
the metadata layer. Promote the sender's SourceMetadata to
fast_io::EntryMetadata, an either/or of a std::fs::Metadata and an
fstatat AtMetadata behind one MetadataExt-named accessor surface, and
take it wherever the metadata apply and quick-check paths accept a
destination stat.

The retype is behaviour-neutral: every existing caller wraps its
std::fs::Metadata in the Std variant, including the engine's local-copy
callers, and no syscall changes. Windows keeps only the Std variant.

A parity test stats a regular file, a directory, a symlink and a FIFO
through both variants and requires mode, size, uid, gid, dev, ino,
nlink, rdev, file type and the second and nanosecond fields of mtime
and atime to match lstat exactly; the quick-check compares mtime to the
nanosecond.
The receiver's pre-transfer destination stats went through
metadata_via_sandbox_or_fallback, which opened the entry O_PATH, fstat'ed
it and closed it: three syscalls where upstream's do_lstat_at() issues one
fstatat (syscall.c). The O_PATH open existed only because fs::Metadata has
no public constructor.

With EntryMetadata in place the consumers take the fstatat answer
directly:

- directory creation and symlink replacement stat through dest_lstat
  (lstat/stat_via_sandbox_or_fallback);
- the quick-check, existence-gate, itemize and up-to-date helpers take
  EntryMetadata, so their path-based stats wrap without a second call;
- a non-directory symlink obstacle reuses the lstat already taken
  instead of statting it again.

metadata_via_sandbox_or_fallback has no callers left and is removed.
The receiver kept two held-directory caches over the same destination:
the DirSandbox's, for probes and opens, and the metadata
DestinationRoot's, for attribute applies. Both resolve root-relative
parents with open_dir_beneath_nofollow beneath the same pinned root, so
every nested parent was opened twice. Upstream keeps a single held
parent for every per-entry operation (syscall.c:3858-3871
held_dfd_for()).

The receiver now opens the sandbox before the metadata root and hands
it the sandbox's cache. Behaviour is unchanged; a nested parent is
opened once instead of once per consumer.
0.103.15 may accept certificate paths through the distrusted emSign
intermediates, whose private keys are public. oc trusts only the
operator --quic-ca store or pinned certificates and loads no public
roots, so exposure needs an emSign anchor in that store; bump anyway.
@oferchen oferchen changed the title fix: anchor receiver opens and stats through the held parent (CVE-2026-53796) fix: anchor receiver opens via the held parent (CVE-2026-53796), bump rustls-webpki Oct 20, 2026
@github-actions github-actions Bot added the bug Something isn't working label Oct 20, 2026
A source that cannot be opened while sending no longer suppresses the
--delete-during and --delete-delay decisions taken during the walk,
while --delete-after now sees send errors from every directory.
Upstream's sender reports them only after its send loop
(sender.c:811-812), so only the after pass's delete_in_dir() sees them.
A file or directory that vanishes between the walk and its send sets
IOERR_VANISHED, which upstream's delete_in_dir() never tests
(generator.c:304 gates on IOERR_GENERAL only), so deletions proceed at
every timing. The vanish is also reported once, by the frame that sent
the file, instead of again by each enclosing directory and the operand.
A local copy now prints `send_files failed to open "<path>": <error>`
for every source it cannot open, and ends the run with upstream's
summary: `some files/attrs were not transferred (see previous errors)`
for exit 23, or `some files vanished before they could be transferred`
for exit 24. Before, only the first failure was printed, folded into
the final line, and every later one was lost (sender.c:708-722,
log.c:98-99).
upstream's sender bumps created_files (for a new entry), xferred_files
and total_transferred_size before it opens the file (sender.c:625-635),
so a source that cannot be opened still counts as attempted. A local
copy now does the same, so --stats on such a run matches upstream.
A local --delete that met an rmdir failure inside a doomed directory
(EBUSY on a mount point without -x, say) aborted the recursive peel, so
the failing entry's siblings survived, and under --max-delete it aborted
the whole transfer. Nothing named the entry, and the non-empty notice
printed an absolute path.

The peel now records each entry it cannot remove and keeps going, the
pass prints upstream's `delete_file: rmdir(<name>) failed` line for it,
and the run ends RERR_PARTIAL as upstream does (delete.c:141-164,
delete.c:264-266). The non-empty notice uses the transfer-relative name.
@oferchen oferchen changed the title fix: anchor receiver opens via the held parent (CVE-2026-53796), bump rustls-webpki fix: anchor receiver opens via held parent, local-copy delete fidelity Oct 20, 2026
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