Summary
Multiple command and argument injection flaws in rsync before 3.5.0 allow malicious values to be interpreted as shell syntax across several connection and wrapper code paths. An attacker who can influence hostnames, host specifications, environment settings, daemon hooks, or related inputs may execute arbitrary commands with the privileges of rsync or the invoking user.
Affected context
The vulnerability occurs in rsync deployments that process attacker-influenced values through connection setup, daemon hooks, the rsync-ssl wrapper, or remote-shell command construction. Risk is present when hostnames, hostspecs, environment variables, or hook-related values reach shell or command interpreters without adequate separation and neutralization.
Exploit preconditions
- Attack surface: rsync client, daemon, wrapper, and remote-shell command paths
- Required access: Ability to influence a processed hostname, hostspec, environment value, hook input, or equivalent connection parameter
- Trigger point: Construction or execution of a shell command during connection setup or synchronization
- Why exploitation is possible: Unsanitized values may be interpreted as shell metacharacters, argument separators, or newline-delimited commands
Why this happens
The underlying issue is the unsafe incorporation of untrusted input into commands and argument strings. Shell metacharacters and newline characters can alter command boundaries or introduce additional operations when values are passed through command interpreters or assembled into remote-shell invocations. This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, with related behavior covered by CWE-88: Improper Neutralization of Argument Delimiters in a Command.
Potential impact
- Attackers may execute arbitrary commands
- Commands may run with the privileges of the rsync process or invoking user
- Local files and synchronized data could be modified, disclosed, or deleted
- Compromised hosts could be used for lateral movement
- Automation and backup workflows could be disrupted or tampered with
General mitigation guidance
Mitigation generally focuses on removing shell interpretation from command construction and reducing trust in connection-related input.
Common defensive patterns include:
- Prefer direct process execution with structured argument arrays instead of shell command strings
- Apply strict allowlists and canonical validation to hostnames, hostspecs, hook values, and environment-controlled inputs
- Treat newline characters, shell metacharacters, and argument delimiters as invalid where they are not explicitly required
- Separate data from executable command logic at every wrapper and remote-shell boundary
- Restrict daemon hooks and environment-variable control to trusted administrators
- Run rsync processes with least privilege and isolate synchronization services from sensitive systems
- Use narrowly scoped service accounts and filesystem permissions to limit consequences if command execution occurs
How teams detect issues like this
High-level detection approaches include:
- Static analysis rules that identify shell execution APIs, command-string concatenation, and interpolation of host or environment values
- Code review checks for newline handling, shell metacharacter filtering, and construction of remote-shell commands
- Tests using malformed delimiters and control characters to verify that inputs remain data rather than executable syntax
- Runtime monitoring for unexpected child processes, shell launches, or commands spawned by rsync and its wrappers
- Policy enforcement that restricts configurable hooks, environment variables, and synchronization endpoints to approved values
- Automated code review tools can help flag command construction patterns during development

