Summary
Rsync versions prior to 3.4.3 contain a flaw in the receiver's compressed-token decoder where a 32-bit signed counter can overflow without detection.
A malicious sender can manipulate this overflow to read process memory, potentially exposing environment variables, passwords, and memory pointers, which in turn weakens ASLR and can facilitate additional attacks.
Affected context
This vulnerability appears in rsync deployments where compressed or delta-transferred data is accepted from potentially untrusted or semi-trusted senders.
It specifically affects the receiver side, during decoding of compressed tokens, when the process uses a 32-bit signed counter without overflow checks.
The risk is higher in scenarios such as backup servers, file mirrors, or sync endpoints that accept incoming rsync connections from external networks or unverified clients.
Exploit preconditions
- Attack surface: Rsync receiver process handling incoming data streams.
- Required access: Ability to connect as an rsync sender (e.g., via network or local invocation) and provide crafted data.
- Trigger point: The compressed-token decoding phase, where rsync maintains a signed 32-bit counter without bounds checking.
- Why exploitation is possible: The arithmetic on the signed counter does not enforce limits, allowing controlled integer overflow that leads to miscalculated offsets and subsequent leakage of in-process memory contents.
Why this happens
The underlying bug is an integer overflow in a 32-bit signed counter used during compressed-token decoding.
Arithmetic operations on this counter do not include explicit range validation, so large or carefully crafted values can wrap around and produce incorrect internal state.
This miscalculation allows the decoder to read or expose memory beyond the intended bounds, mapping to CWE-190: Integer Overflow or Wraparound and resulting in CWE-200: Exposure of Sensitive Information when out-of-bounds data is returned to the attacker.
Potential impact
- Attackers may read environment variables from the rsync process.
- Sensitive secrets such as passwords, tokens, or configuration data could be disclosed.
- Memory pointers from the heap, stack, or shared libraries can be leaked.
- Leaked pointers may significantly reduce the effectiveness of ASLR, aiding follow-on exploitation.
- Information gathered could be combined with other vulnerabilities to achieve arbitrary code execution.
General mitigation guidance
Effective mitigation focuses on enforcing safe arithmetic and reducing exposure of untrusted inputs:
- Introduce strict range checks around counters and lengths used in decoding logic, rejecting or safely handling anomalous values.
- Prefer unsigned, size-aware types and centralized helper functions for length and offset calculations to avoid ad hoc arithmetic.
- Treat incoming rsync data as untrusted and validate protocol fields, token counts, and sizes before performing memory operations.
- Run rsync services with least privilege, isolated accounts, and constrained environments to limit the impact of any data leakage.
- Restrict rsync access to authenticated and authorized peers, and avoid exposing receivers directly to untrusted networks where possible.
How teams detect issues like this
Detection typically relies on code-centric and operational approaches:
- Static analysis: Configure rules to flag arithmetic on 32-bit counters or indices used in decoding or buffer calculations without explicit bounds checks.
- Code review: Look for counters and offsets in compression, decompression, or delta-transfer logic that lack overflow protection or sanity checks.
- Fuzzing: Use protocol-aware fuzzers against rsync's receiver path, particularly targeting compressed-token streams and size fields, to detect anomalous memory access or leaks.
- Runtime monitoring: Enable hardened builds and runtime sanitizers (where feasible) to capture integer overflows and out-of-bounds accesses during testing.

