Home > Specs > BitTorrent
BitTorrent SHA-1 Collision Demo
Written by Kevin Hearn (kh@tixati.com)
Last update October 6, 2025

The following demonstration that shows how easy it is to make a torrent with two versions of the same piece that both pass the SHA-1 hash check.

This could be used to establish a torrent containing a piece of software that appears safe and works correctly, but is later transparently swapped out for the alternate version containing the other collision block.  The software could detect this via a self-check and then run an alternate code path.

Other document and media files could also be pre-sabotaged depending on the specifics of the format and the viewer software.

The demonstration is contained in a small zip file.

BitTorrent_Collision_Demo.zip9.1 KB

After extraction, there will be three files.  A readme file, and then two shell scripts named test.sh, one in folder A, one in folder B.

In Tixati or perhaps Transmission, create a new single-file torrent from either of the two test.sh files.  In Tixati, the protocol must be set to v1.0.  Notice that the info hash is exactly the same.  If you attempt to create the second torrent before removing the first, you will get a duplicate torrent warning.

The fact that the files are different can be verified on the command line:

sha512sum a/test.sh
436b03fd39d85e452e518f8ab9295d0 ...

sha512sum b/test.sh
2284f4efe33009138a4165a9d727855 ...

For a demonstration of how this could be used, refer to the content of the shell script:

SUM=$( tail -n +38 $0 | sha512sum | cut -d " " -f 1 )

GOODSUM="9aca017277990c96596aa5840151320ad47794fcb768bc1fa5b5022717684bea641345fa3c842cbfc2dac2ae4edb2862bf239e4f1069dd05a4591537e1782822"
BADSUM="fbe97f92617e934089a4a8c70a3c9f046645c40ab913a1b0685092e0fd95e4222757b68d53d4fd7c63e66c10babc4ff355f056ec14d37d581352cead99b4f03f"

if [ "$SUM" = "$GOODSUM" ]
then
  echo "Everything is fine!"
elif [ "$SUM" = "$BADSUM" ]
then
  echo "This is the poison version!  Imagine what could happen now?"
else
  echo "Something else went wrong!"
fi

exit
# padding ...

This is obviously a very simplistic program, but it clearly demonstrates the overall concept.  In more complex programs, it would be trivial to hide such functionality.


Further Reading


https://tixati.com/specs/bittorrent/sha1_problems

https://tixati.com/specs/bittorrent/v3

https://en.wikipedia.org/wiki/SHA-1

https://sha-mbles.github.io/


This web site is powered by Super Simple Server