Skip to content

Enforce --confine-root on destination/source paths and update confinement tests - #1169

Open
seks99x wants to merge 1 commit into
RsyncProject:masterfrom
seks99x:fix-confine
Open

seks99x wants to merge 1 commit into
RsyncProject:masterfrom
seks99x:fix-confine

Conversation

@seks99x

@seks99x seks99x commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Enforce --confine-root on source and destination paths and update confinement tests

  • util1.c (change_dir): Enforced --confine-root validation when changing directories on both receiver and sender sides ((confine_root || !am_sender)), ensuring a confined server cannot chdir() outside the restricted root via .. traversal or pre-existing in-tree symlinks pointing to outside directories.
  • receiver.c (recv_files): Extended the inplace_partial open-failure check from am_daemon to (am_daemon || confine_root) so that if opening operator-peer-path file fails under --confine-root, the receiver fails closed immediately (matching daemon behavior) rather than falling back or retrying unsafely.
  • syscall.c (ona_open): Narrowed the confine_root check on kernel pseudo-paths to confine_root && (operator_path_resolve || filesfrom_owner_walk_active()) so confinement only restricts peer/untrusted path walks rather than blocking trusted operator-supplied options like --log-file.
  • testsuite/tests/rrsync/rrsync-merge-file-confine.py: Routed confined_pull through a remote shell wrapper (-e alias_rsh) so --confine-root applies only to the server sender instead of leaking into the local client receiver via fork() and blocking writes to the test destination, and restored explanatory test comments.
  • testsuite/tests/rrsync/rrsync-userns-procfs.py: Routed the confined transfer through a remote shell wrapper (-e rsh) so --confine-root applies only to the server side instead of leaking into the local client via fork(), and restored explanatory comments detailing the mount namespace, /proc remount, and overflow UID test setup.
  • testsuite/tests/path/pseudo-paths.py: Updated Test 2 to assert that --log-file=>(...) succeeds under --confine-root={base_path}, since --log-file is a trusted operator-supplied path that should not be restricted by root confinement, and restored the inline test comments. Since there is currently no reachable edge case where an untrusted transfer path can resolve and accept a kernel pipe/pseudo-path under --confine-root, the test solely verifies that pseudo-paths work cleanly both with and without --confine-root (later when stream-source options: add --stream-source FIFO transfers #1150 is merged, we could add an edge case for the source confinement).
  • testsuite/tests/path/confine-root-dest-symlink.py: Added destination regression coverage verifying that static destination escapes and live parent-swap TOCTOU races are blocked under --confine-root.
  • testsuite/tests/path/confine-root-source.py: Added sender/source regression coverage verifying that a confined server sender refuses to traverse out of --confine-root via pre-existing in-tree symlinks (--copy-links, trailing-slash directory pulls) or relative .. source arguments.

Note: None of these cases constitute an untrusted-symlink vulnerability on their own, as they rely on a pre-existing root/operator-owned ("trusted") symlink inside the tree. Rather, they fix incomplete confinement checks where --confine-root allowed a trusted in-tree symlink or relative traversal to redirect a transfer outside the confined root.

Reported-by: karimabisaad@gmail.com

@seks99x

seks99x commented Nov 12, 2026 •

Copy link
Copy Markdown
Member Author

The sender/source is still not confined well. Only enforced under files-from. Confine-root is the same as a daemon tree and source should be also confined. Will push tomorrow.

@seks99x seks99x changed the title Enforce --confine-root on destination paths and update confinement tests Enforce --confine-root on destination/source paths and update confinement tests Nov 13, 2026
@seks99x
seks99x force-pushed the fix-confine branch 3 times, most recently from e23d0a4 to 6187ec4 Compare November 15, 2026 19:39
…finement tests

Reported-by: <karimabisaad@gmail.com>
@seks99x

seks99x commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Description Updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant