Skip to content
Crypto Disclosed report Advanced

rsync hash collisions may allow an attacker to corrupt or modify files

The rsync algorithm uses MD5 checksums for file blocks, and an attacker can craft a file that produces the same MD5 hash as a legitimate block while also matching the rolling checksum, allowing the attacker to corrupt or modify files during synchronisation. This could bypass validation rules or, when untrusted data is mixed with system data, lead to privilege escalation.

mik Follow

Originally disclosed on HackerOne

  • Fixed in 4 months
  • Paid in 4 months
  • Disclosed after 4 months

The rsync algorithm synchronizes remote files in 3 steps:

  • The receiver divides the basis file into 700-byte blocks, performing two checksums on each block (a rolling checksum based on Addler32) and an md5 sum
  • The sender then scans it's version of the file byte-by-byte looking for matches against both sums, transmitting either literal data, or a copy command (copy offset length)
  • The receiver makes a copy of the file by applying the delta commands from the sender

While it is known that md5 doesn't offer much collision resistance, it is perhaps unknown that the fast md5 collisions can be combined with a collision against the rolling sum. They can.

For files where all of the data is in the same privilege domain, this may allow bypassing validation rules.

More critically, for files where data for the system and other users is mixed with untrusted data (VM images, databases), this could allow privilege escalation.

There are two different classes of attack on md5 - collisions and chosen-prefix collisions:

  • Collisions are very quick to generate on a normal PC, but require a fully crafted file to work (the original demo was a postscript file). This is what I have attached.
  • Chosen-prefix attacks are more serious, but require more work to generate (approx 2^50) - I do not have an example of one of these yet.

Also note that rsync does a final full-file hash, which will fail. This reduces this to just a DoS attack unless --inplace is used (common for syncing large files).

Since rsync is used for mirroring large open-source projects, and is used in the background for many open source, closed-source and in-house systems, I believe this may qualify for an internet bug bounty.

The original report as published on HackerOne, by mik. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the use of MD5, which is vulnerable to collision attacks, combined with a rolling checksum that can also be collided, allows an attacker to craft data that matches both checksums without being identical.

Impact

This could allow bypassing validation rules or privilege escalation, but the final full-file hash will fail, reducing it to a denial-of-service unless the --inplace option is used.

What the attacker needed

Attacker can supply a crafted file

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Rsync is a tool that copies files efficiently by only sending the parts that changed. It uses a checksum (a kind of digital fingerprint) to decide which parts are the same. The report shows that an attacker can create a file that has the same fingerprint as a legitimate part, so rsync might accept malicious data as if it were unchanged.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.