text stringlengths 0 1.99k |
|---|
generator about the success or failure of a single file transfer. This |
mechanism becomes important later. |
-- 2.0.3 - Rsync Server Connection Modes |
In this section, we will briefly describe two ways a Rsync client can |
connect to a Rsync server on a remote machine and how they affect the |
vulnerabilities we found. We will go into more detail about the individual |
bugs in later sections. |
-- 2.0.3.0 - Daemon Mode |
The same rsync binary that is used as a client CLI can be used to launch a |
server. To do so, it is sufficient to run it with rsync --daemon. |
Typically, the daemon listens on port 873 accepting plain TCP connections. |
In daemon mode, the server calls fork() on every new connection. Servers |
running in this mode can be scanned for on the internet. In October 2024, |
we found ~550,000 Rsync daemons exposed to the internet via Shodan. |
-- 2.0.3.1 - SSH Mode |
Rsync can be invoked on a remote machine over an SSH connection. This is |
done by running rsync on the remote host with special server flags. While |
the protocol differs slightly in this mode, the same synchronization logic |
is carried over the SSH channel. |
Although SSH access to the remote machine already implies access, in some |
cases SSH is configured to restrict access only to the rsync command to |
strictly specified flags. In such cases, the access is "sandboxed", as |
only the rsync binary can be launched. Such a setup is described, for |
example, by linux-audit.com: |
command="rsync –server -vlogDtprCze.iLsfx –delete . \ |
/data/backups/system01",no-agent-forwarding,no-port-forwarding,\ |
no-pty,no-user-rc,no-X11-forwarding ssh-ed25519 AAAA........ \ |
backupuser for system1 |
In such cases, the client to server RCE exploit we developed could be used |
to break out of this "sandbox". The same vulnerabilities can be triggered |
in this mode, although there are some exploitation differences that we |
will go into in later sections. |
-- 2.1.0 - Exploitation of Memory Corruption Vulnerabilities |
In the next sections, we will detail the memory safety issues we |
discovered in Rsync's server-side code. We will provide an overview of the |
server-side checksum parsing, which will provide the background knowledge |
required to understand the sections that follow. We will also detail the |
exploitation strategies we used to achieve reliable Remote-Code-Execution. |
The exploit we developed was written for the following binary running in |
daemon mode with the default configuration: |
* Distro: Debian 12 Bookworm |
* Rsync version: 3.2.7-1 (At the time Bookworm stable) |
* MD5 of binary: 003765c378f66a4ac14a4f7ee43f7132 |
-- 2.1.1 - Background - Server Side Checksum Parsing |
The server reads the checksums in the receive_sums() function. First, |
information about the checksums is read in the read_sum_head() function. |
We break down individual values and their meaning here: |
/* Populate a sum_struct with values from the socket. This is |
* called by both the sender and the receiver. */ |
void read_sum_head(int f, struct sum_struct *sum) |
{ |
int32 max_blength = protocol_version < 30 ? OLD_MAX_BLOCK_SIZE \ |
: MAX_BLOCK_SIZE; |
sum->count = read_int(f); |
if (sum->count < 0) { |
rprintf(FERROR, "Invalid checksum count %ld [%s]\n", |
(long)sum->count, who_am_i()); |
exit_cleanup(RERR_PROTOCOL); |
} |
... |
} |
count refers to the number of checksums that will follow. This corresponds |
to the number of chunks that the file is split into for synchronization. |
Next comes blength: |
sum->blength = read_int(f); |
if (sum->blength < 0 || sum->blength > max_blength) { |
rprintf(FERROR, "Invalid block length %ld [%s]\n", |
(long)sum->blength, who_am_i()); |
exit_cleanup(RERR_PROTOCOL); |
} |
The blength tells the server the length of a chunk within the file, which |
are all the same length. The server will read blength bytes from a file, |
calculate a digest and compare it to the corresponding checksum the client |
sent. |
Next comes s2length: |
sum->s2length = protocol_version < 27 ? csum_length |
: (int)read_int(f); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.