Skip to content

fix: confine daemon alt-basis paths to module root (URV-5.a) - #5540

Merged
oferchen merged 1 commit into
masterfrom
fix/urv-5a-alt-basis-resolve-beneath
Jun 10, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/urv-5a-alt-basis-resolve-beneath

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Wire upstream rsync 3.4.4 secure_relative_open() confinement (syscall.c:1791-1896) into the daemon's relative alt-basis admission path in crates/daemon/src/daemon/sections/module_access/client_args.rs.
  • The previous code called module_path.join(rel) with no .. rejection and no RESOLVE_BENEATH confinement, so a client could submit --copy-dest=../../etc on a chroot-disabled module and the receiver would target inodes outside the module root.
  • Front-door reject any .. component in --copy-dest=REL / --link-dest=REL / --compare-dest=REL relative paths, then join the validated path onto the module root. The session is torn down with @ERROR: refusing alt-basis path that escapes module root: ... on rejection.

Why upstream's portable fallback, not RESOLVE_BENEATH

Upstream's RESOLVE_BENEATH branch handles a case oc-rsync does not hit: rsync chdir's into a transfer subdirectory of the module and then needs to allow --link-dest=../sibling-within-module to climb back to a peer directory still inside the module (syscall.c:1817-1844). oc-rsync never chdir's the daemon process into a subdirectory of the module path (see the existing comment at build_server_config above the call site), so the relative ref-dir path is always interpreted against the module root directly. Upstream's portable fallback (syscall.c:1883-1896) is the matching semantics in that regime: reject .. outright. This is also the safest behaviour on platforms without kernel-side RESOLVE_BENEATH (NetBSD, OpenBSD, Solaris, Cygwin, pre-5.6 Linux), where per-component walking cannot adjudicate .. against bind-mounts and racing symlinks.

SECURITY.md classification

Bug class falls under the SEC-1 family in SECURITY.md (TOCTOU and filesystem confinement on chroot-disabled modules). The closely related CVE-2026-29518 / CVE-2026-43619 entries cover symlink races on receiver syscalls; this fix closes a narrower but related admission-time path-traversal hole on the same use chroot = no configurations that the SEC-1 work targets.

Test plan

  • Unit test: confine_alt_basis_admits_clean_relative_sibling
  • Unit test: confine_alt_basis_admits_nested_relative_path
  • Unit test: confine_alt_basis_rejects_bare_dotdot
  • Unit test: confine_alt_basis_rejects_leading_dotdot
  • Unit test: confine_alt_basis_rejects_path_traversal_to_etc (the headline ../../etc exploit)
  • Unit test: confine_alt_basis_rejects_embedded_dotdot
  • Unit test: confine_alt_basis_rejects_trailing_dotdot
  • Unit test: path_has_dotdot_component_detects_all_forms
  • CI: fmt + clippy
  • CI: nextest (Linux gnu/musl, macOS, Windows)

The daemon's relative alt-basis admission path
(--copy-dest=REL / --link-dest=REL / --compare-dest=REL) called
module_path.join(rel) without any confinement check. A client could
submit --copy-dest=../../etc on a chroot-disabled module and have
the receiver target inodes outside the module root.

Mirror upstream rsync 3.4.4 secure_relative_open() (syscall.c:1791-
1896) by front-door rejecting any `..` component in the relative
path before the join. This matches upstream's portable fallback
semantics (syscall.c:1883-1896), which is the only safe behaviour
without kernel-enforced RESOLVE_BENEATH on the destination tree.

oc-rsync never chdir's the daemon process into a transfer
subdirectory of the module, so upstream's re-anchoring branch
(syscall.c:1817-1844) for --link-dest=../sibling-within-module does
not apply: a relative ref-dir path is always interpreted against
the module root directly.

Add regression tests covering the headline exploit (../../etc),
bare `..`, leading `..`, trailing `..`, embedded `..`, and the
positive admission cases for clean siblings and nested paths.

Classified in SECURITY.md under the SEC-1 family (TOCTOU /
filesystem confinement on chroot-disabled modules).
@github-actions github-actions Bot added the bug Something isn't working label Jun 10, 2026
@oferchen
oferchen merged commit 8edaeb7 into master Jun 10, 2026
69 checks passed
@oferchen
oferchen deleted the fix/urv-5a-alt-basis-resolve-beneath branch June 10, 2026 09:30
oferchen added a commit that referenced this pull request Aug 24, 2026
The daemon's relative alt-basis admission path
(--copy-dest=REL / --link-dest=REL / --compare-dest=REL) called
module_path.join(rel) without any confinement check. A client could
submit --copy-dest=../../etc on a chroot-disabled module and have
the receiver target inodes outside the module root.

Mirror upstream rsync 3.4.4 secure_relative_open() (syscall.c:1791-
1896) by front-door rejecting any `..` component in the relative
path before the join. This matches upstream's portable fallback
semantics (syscall.c:1883-1896), which is the only safe behaviour
without kernel-enforced RESOLVE_BENEATH on the destination tree.

oc-rsync never chdir's the daemon process into a transfer
subdirectory of the module, so upstream's re-anchoring branch
(syscall.c:1817-1844) for --link-dest=../sibling-within-module does
not apply: a relative ref-dir path is always interpreted against
the module root directly.

Add regression tests covering the headline exploit (../../etc),
bare `..`, leading `..`, trailing `..`, embedded `..`, and the
positive admission cases for clean siblings and nested paths.

Classified in SECURITY.md under the SEC-1 family (TOCTOU /
filesystem confinement on chroot-disabled modules).
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