Summary
A path traversal vulnerability in rsync can allow a malicious sender to redirect file writes outside the intended module root through symlinks in the module file tree. The issue becomes risky when --partial-dir or --backup-dir is used and an attacker can place or influence a symlink that the receiving process trusts.
Affected context
The vulnerability affects rsync deployments that receive files into a module root while using options such as --partial-dir or --backup-dir. It may arise when the module tree contains attacker-controlled or trusted symlinks and file-write operations resolve those links without sufficiently enforcing the intended root boundary.
Exploit preconditions
- Attack surface: An rsync module receiving files from a potentially malicious sender
- Required access: Ability to send or synchronize files to the affected module, plus the ability to place a symlink under the module root or exploit a pre-existing trusted symlink
- Trigger point: File creation or update operations associated with partial transfers or backups
- Why exploitation is possible: Symlink resolution can redirect writes outside the module root, allowing paths to escape the intended directory boundary
Why this happens
The underlying bug is insufficient confinement of filesystem writes when symlinks are present in a destination tree. Operations associated with partial files or backups may follow a symlink and resolve the target relative to a location outside the intended module root. This maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, with CWE-59: Improper Link Resolution Before File Access describing the unsafe reliance on link resolution.
Potential impact
- An attacker may overwrite files outside the intended module directory
- Sensitive configuration or application files could be modified
- Service availability may be disrupted through destructive file writes
- Modified files could enable privilege escalation or code execution in another process
- Integrity of backups, partial transfers, or synchronized data could be compromised
General mitigation guidance
Mitigation generally focuses on enforcing destination confinement independently of symlink state.
Common defensive patterns include:
- Resolve and validate destination paths before writes, while rejecting paths that escape the authorized root
- Avoid following untrusted symlinks during file creation, replacement, backup, and partial-transfer operations
- Use filesystem APIs and flags that enforce directory-relative, no-follow, or beneath-root access where available
- Restrict who can create or modify symlinks within module trees
- Separate writable synchronization areas from sensitive operating-system and application paths
- Run rsync services with the minimum filesystem permissions required for their function
- Treat module contents and sender-controlled names as untrusted input
How teams detect issues like this
Detection approaches can include:
- Static analysis for file operations that combine user-controlled paths with symlink-following behavior
- Code review checks for missing canonical-path, root-boundary, or no-follow validation
- Tests that place symlinks at destination, partial-transfer, and backup paths and verify that writes remain confined
- Runtime auditing of rsync-created or modified files outside approved module directories
- Policy enforcement that limits module write permissions and disallows symlinks where they are not required
- Automated security review tools that flag path traversal and unsafe link-resolution patterns

