text
stringlengths
0
1.99k
+------------------+-----------------------+-----------------------------+
| CVE-2024-12087 | Arbitrary File Write | The server can make clients |
| | | write files outside of |
| | | destination directory |
+------------------+-----------------------+-----------------------------+
| CVE-2024-12088 | Symlink Validation | Improper handling of nested |
| | Bypass | symlinks allows bypass of |
| | | --safe-links |
+------------------+-----------------------+-----------------------------+
-- 2 - Technical Details
The following sections will provide all the background knowledge required
to gain a general understanding of Rsync and follow along with the
exploitation sections. We then discuss the discovered vulnerabilities and
describe the exploit we developed.
-- 2.0.0 - Background - Rsync architecture
The following sections provide a simplified explanation of Rsync. A more
comprehensive understanding can be obtained from the official project
website (rsync.samba.org) and the original paper [9] that describes the
algorithm. The background provided in this article is enough to understand
the vulnerabilities and the exploits. We recommend reading through this
section, as it explains the functions that will be referenced in the
exploitation sections.
-- 2.0.1 - File Comparison Algorithm
The Rsync algorithm was designed to synchronize files between a source and
destination, often on separate machines. Rsync achieves this by splitting
existing files into chunks and only updating mismatching chunks or adding
new chunks.
The following graphic shows a file present in both the source and
destination. By splitting the file into chunks, calculating a checksum for
each chunk and comparing them, only a single chunk needs to be downloaded:
/tmp/foo (Client)
+-----------+-----------+-----------+
| 7f912f0 | ae16850 | 5351f3d |
+-----------+-----------+-----------+
|
x
/tmp/foo (Server) |
+-----------+-----------+-----------+
| 7f912f0 | e27c8bf | 5351f3d |
+----------+------------+-----------+
-- 2.0.2 - Rsync Workflow
When the client starts to sync from a server it first gets a list of files
that will be offered. This list is called the file list and contains
directories and files that are available in the server's source directory.
The client receives this file list and decides which files it wants to
update/download based on command line flags.
At this point, the client process calls fork() and now works with two
processes: the generator and the receiver. The generator process is
responsible for going through the file list the client received from the
server and creating missing directories and, if enabled, symbolic links,
devices and more.
The generator then goes through the regular files in the file list and
checks if they already exist locally. If they do, it divides the file into
an array of chunks and calculates two checksums for each of the chunks:
* A 32-bit Adler-CRC32 Checksum
* A digest of the file chunk. The digest algorithm is determined at the
beginning of the protocol negotiation
The generator then sends all chunks at once to the server, along with an
index into the file list. This instructs the server to read the checksums
and compare them against its own copy of the file. The server then sends
the receiver, the second client process, a list of tokens. A token in this
context is an instruction for the receiver process to either skip over a
chunk when the chunks match or the server sends a stream of inline-data to
overwrite mismatching chunks in the client's copy of the file.
The following graphic shows this workflow in action:
+----------+
| Server |
+----------+
^
/ \
/ \
/ \
Keep chunk 1 / \ Checksum 1
Keep chunk 2 / \ Checksum 2
Inline Data for chunk #3 ...
... / \ Checksum N
Keep chunk N / \
+---------------------+ +---------------------+
| | | |
| Receiver |<--------------->| Generator |
| |Success / Failure| |
+---------------------+ +---------------------+
The receiver only communicates with the generator. It informs the