Sunday, February 26, 2017

Playing with the SHAttered PDFs

SHA-1 Collision 


I'm playing with the PDFs created by the SHAttered.io researchers, you can download their paper explaining how they were able to generate a collision which also includes a Base64 encoded tar.bz2 archive of the 2 PDFs files from their site or from here.

Artem Tashkinov, explains here and provides a link to a Pyhton3 script that creates collisions by Robert Xiao.

First, here is how the 2 PDFs look like so you can see they are very different


Original/Good PDF
Collision / BAD PDF

Both files have the same SHA1 hash:

igor@KYLO-REN:~$ sha1sum good.pdf bad.pdf
d00bbe65d80f6d53d5c15da7c6b4f0a655c5a86a good.pdf
d00bbe65d80f6d53d5c15da7c6b4f0a655c5a86a bad.pdf

Here's a diff of their Base64:

igor@KYLO-REN:~$ diff --side-by-side good.pdf.b64 bad.pdf.b64
JVBERi0xLjMKJeLjz9MKCgoxIDAgb2JqCjw8L1dpZHRoIDIgMCBSL0hlaWdod   JVBERi0xLjMKJeLjz9MKCgoxIDAgb2JqCjw8L1dpZHRoIDIgMCBSL0hlaWdod
IDQgMCBSL1N1YnR5cGUgNSAwIFIvRmlsdGVyIDYgMCBSL0NvbG9yU3BhY2UgN   IDQgMCBSL1N1YnR5cGUgNSAwIFIvRmlsdGVyIDYgMCBSL0NvbG9yU3BhY2UgN
IDggMCBSL0JpdHNQZXJDb21wb25lbnQgOD4+CnN0cmVhbQr/2P/+ACRTSEEtM   IDggMCBSL0JpdHNQZXJDb21wb25lbnQgOD4+CnN0cmVhbQr/2P/+ACRTSEEtM
ISGFL+wJIzl1nDmxocY8TJfh//4Bf0bck6a2fgE7ApqqHbJWC0XKZ9aIx/hLj | ISGFL+wJIzl1nDmxocY8TJfh//4Bc0bckWa2fhGPApq2IbJWD/nKZ8yox/hbq
aQkBxWtFwVMK/t+3YDjpcnIv561yjw5JBOBGwjBXD+nUE5ir4S71vJQr4zVCp | qQkB1d9FwU8m/t+z3DjpasIv571yjw5FvOBG0jxXD+sUE5i7VS71oKgr4zH+p
rDUU503cDyzBqHTNDHgwWiFWZGEwl4lga9C/P5jNqARG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differ (marked in red), and there's where the magic happens.

SHAttered already took it's first victim, WebKit's Apache SVN, you can read about it here
This means that is not only about SSL/TLS Certificates and encryption, it's also about potential DoS of systems that are depended on SHA1 to do deduping or version control for example.

No comments:

Post a Comment