Skip to content

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

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

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 (guarding it with operator_path_resolve) 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.
filesfrom_owner_walk_active() check on the pseudo paths may be useless and break legit cases also. I’ll look into that

@seks99x seks99x added the Security Public work arising from a confirmed or disclosed security issue label Nov 16, 2026
@steadytao

Copy link
Copy Markdown
Member

This would belong solely in 4.0, not 3.5. But it is still nowhere ready. This makes some very broad changes without a proper confinement contract or BSD behaviour. And pseudo-path policy should be altered separately.

@steadytao

steadytao commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

I suggest moving this to a Design discussion.

@seks99x

seks99x commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Merging one confinement fix without the other breaks CI, which is why the pseudo-path changes are included in this PR. I don't think this is a design to discuss, this aligns --confine-root with its documented requirement to match daemon behavior. Previously, --confine-root was only enforced on operator-peer paths (--backup-dir , --temp-dir, --partial-dir, alt-dest , etc) without updating change_dir(), and --files-from enforced root confinement on the source while standard source and destination paths did not, which is inconsistent. Furthermore, the change_dir() update is strictly scoped to --confine-root and leaves all other code paths untouched, though I am still investigating the root cause of the BSD failure. We could leave it for 4.0.0 if you want but I do not suggest that because there will be already some changes on the confinement and symlinks if a release is cut before. Tell me what do you think ?

@steadytao

Copy link
Copy Markdown
Member

--confine-root allows explicit source arguments to select their own transfer roots. Extending confinement to those paths changes that contract and is broader than 3.5 -- We need to agree on which operator-selected and peer-selected paths should be restricted before settling the implementation.

The CI failure that requires both changes needs to be identified properly and the dependency justified. Splitting changes should be done where coupling is not strictly required. The pseudo-path policy should be reviewed separately. The broader confinement behaviour needs a Design discussion and the BSD regression needs resolving. This should be brought under 4.0 nonetheless.

@steadytao steadytao closed this Nov 17, 2026
@seks99x

seks99x commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

I still don’t see this as extending at all since we are matching daemon source/destination and files-from source confinement behavior which is what root confinement should be. We should have discussed this before on the files-from patching ( if you don’t want source/dest confinement) at least so we can have a consistent design, and we shouldn’t be also documenting that trusted-symlink confinement is same as daemon if we wont confine source/destination.

Pseudo-path policy currently accept daemon log-file and refuse log-file under root confinement which remains inconsistent too. Anyways its your call to make i’ll leave it to u!

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

Labels

Security Public work arising from a confirmed or disclosed security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants