fix(file-manager): backport symlink-safe rsync targets to 7.3 - #2746
Conversation
Resolve symlink-backed destinations before File Manager rsync operations so rsync 3.5.0 does not reject exclusive-share paths. Preserve the existing path boundary and rsync security checks.\n\nLinear: OS-871
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔧 PR Test Plugin AvailableA test plugin has been generated for this PR that includes the modified files. Version: 📥 Installation Instructions:Install via Unraid Web UI:
Alternative: Direct Download
|
Cover the rsync target adapter and both copy and move call sites. Clean up temporary fixtures when setup fails and document the new helpers.\n\nLinear: OS-871\nReview: #2745
Limit exclusive-share path translation to verified OS mappings and reject other symlink components before rsync receives a pre-resolved path. This preserves rsync 3.5 symlink protections while retaining exclusive-share support. Linear: OS-872 Backport of OS-871
Use getfattr --no-dereference so the exclusive-share validation reads the OS-managed symlink attribute instead of following it to the backing directory.
Summary
This backport brings the File Manager rsync symlink hardening from OS-871 to the
7.3release branch. It rejects arbitrary symlink components and translates only verified Unraid exclusive-share mappings.Why This Exists
Rsync 3.5.0 rejects untrusted symlink components in operator-supplied paths. The previous implementation used recursive
realpath()resolution, which could hide an attacker-controlled symlink from rsync before its security checks ran. This backport is tracked by OS-872, with the original behavior tracked by OS-871.Resolution
Walk the destination path component by component with
lstat(). Translate only the OS-managed/mnt/user/<share>or/mnt/user0/<share>exclusive-share link after verifying the share state, exact backing target,system.LOCATION, and configured storage. Reject every other symlink component and preserve missing descendants and trailing slashes.Reviewer Considerations
7.3.--insecure-linksis not used.Behavior Changes
File Manager operations into arbitrary symlink-backed destinations now fail closed. Verified exclusive-share destinations continue to use their physical backing path for rsync.
Implementation Summary
realpath()target resolution with a component walk.Verification
php -l emhttp/plugins/dynamix/nchan/file_managerphp -l tests/file-manager-rsync-target-path.phpphp tests/file-manager-rsync-target-path.phpgit diff --checkValidation Limits
The local regression test uses a temporary symlink fixture. Full validation of the exclusive-share exception requires an Unraid runtime with
state/shares.ini,state/disks.ini, andsystem.LOCATIONmetadata.Risk
Contained; the change fails closed for unknown symlinks and does not disable rsync security checks. The main compatibility risk is intentionally stricter handling of non-system symlink destinations.