text stringlengths 0 1.99k |
|---|
However, the local sum2 buffer is a buffer on the stack that is not |
cleared, and thus contains uninitialized stack contents. |
A malicious client could send a known xxhash64 checksum for a given chunk |
of a file, which leads to the daemon writing 8 bytes to the stack buffer |
sum2. The following image visualizes the contents of the sum2 buffer with |
this setup: |
sum2 stack buffer |
+----------------------+-------------------------------------------------+ |
| 8-bytes of checksum | 56 bytes of uninitialized stack contents | |
+----------------------+-------------------------------------------------+ |
The attacker can set s2length to 9 bytes. The result of such a setup would |
be that the first 8 bytes match and an attacker-controlled 9th byte is |
compared with an unknown value of uninitialized stack data. This is |
visualized by the following: |
sum2 stack buffer |
+----------------------+----+--------------------------------------------+ |
| 8-bytes of checksum | ?? | 55 bytes of uninitialized stack contents | |
+----------------------+----+--------------------------------------------+ |
+---------------------------+ |
| s2length = 9 | |
+---------------------------+ |
The server responds with different messages based on the comparison |
result. If the 9 bytes match, the server tells the client to keep the |
chunk. Otherwise, the server sends the data corresponding to the chunk |
directly to the client, as in the eyes of the server, the data on the |
server differs. |
The attacker can send 256 different checksums, until the sum matches. |
Thus, the attacker can derive what the 9th byte (i.e. the 1st byte of |
unknown stack data) from the server's behavior. The attacker can then |
incrementally repeat this process to leak more bytes from the stack |
buffer. Let's assume the attacker leaked the byte 0x47. While there are |
some constraints, which are detailed later, they can then continue the |
leak as more bytes of the stack are now known: |
sum2 stack buffer |
+----------------------+------+----+-------------------------------------+ |
| 8-bytes of checksum | 0x47 | ?? | 54 bytes of uninitialized stack data| |
+----------------------+------+----+-------------------------------------+ |
+----------------------------------+ |
| s2length = 10 | |
+----------------------------------+ |
As a result, they can leak MAX_DIGEST_LEN - 8 bytes of uninitialized stack |
data, which can contain pointers to Heap objects, stack cookies, local |
variables, pointers to global variables and return pointers. With those |
pointers they can defeat ASLR. |
-- 2.2.1 - Breaking ASLR |
In the case of the binary that we exploited, we were able to achieve a |
layout for the sum2 buffer where, starting at offset sum2+8, is a pointer |
into the .text section of the rsync binary: |
(gdb) x/gx sum2+8 |
0x7fffffff7558: 0x00005555555596847 |
(gdb) x/gx 0x00005555555596847 |
0x5555555596847 <set_compression+599>: 0x058d48fffffef4e9 |
(gdb) |
The first 8 bytes of sum2 buffer are overwritten by the checksum of the |
target file, and the 8 bytes that are leaked immediately lead to a full |
bypass of ASLR. |
Since an attacker can leak up to 56 bytes of stack contents, it is very |
likely that this infoleak can also be ported to other binaries and |
environments. An attacker can trigger different stack frames before the |
entry into hash_search(), for example by triggering allocations or |
initializing different compression algorithms. |
-- 2.2.2 - Speed vs Reliability of the Infoleak |
In theory, the infoleak algorithm previously described can be optimized by |
splitting a file into 256 different chunks and performing the oracle with |
256 different values. Then, the client can observe which of the 256 chunks |
matched on the server side and derive the stack contents from that. That |
would mean that a single byte can be leaked per file request. |
In addition, a client can repeatedly request the same file over and over |
again from the server. In theory, an attacker can leak the entire stack |
contents in a single connection. However, this comes at the cost of |
reliability of the infoleak as the stack contents may contain dynamic data |
such as heap pointers or other local variables that change based on the |
overall state of the program. As such, the previously disclosed stack |
contents may change and thus the incremental bruteforce of data may not |
work. |
For our Proof-of-Concept exploit, we decided on maximum reliability and |
portability which is achieved by attempting a single oracle step |
per-connection. The logic here is based on the fact that the rsync daemon |
runs in a fork() loop. Assuming a system where glibc's allocator is used, |
the heap layout is deterministic. If we send the exact same packets |
leading up to the hash_search() function being called, the stack frames |
will always be exactly the same. As a result, the incremental brute-force |
is slower but values are more likely to stay static. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.