Is there an example of two known strings which have the same MD5 hash value (representing a so-called "MD5 collision")?
-
$\begingroup$ Example in Wikipedia. $\endgroup$– Tomasz NurkiewiczCommented Dec 11, 2011 at 9:04
-
$\begingroup$ mscs.dal.ca/~selinger/md5collision $\endgroup$– Nicolas TheryCommented Mar 19, 2014 at 11:24
-
$\begingroup$ Once wrote two bash script that got the same MD5 value, and did two different things none-the-less. Pretty easy to do, but McAfee ate the .zip as a proto-virus was stored in it as well (you can create a .zip scanner but not one that can delete the files from the .zip, pretty lame). $\endgroup$– Maarten Bodewes ♦Commented May 6, 2014 at 23:43
-
$\begingroup$ Related questions: What is the MD5 collision with the smallest input values? and Are there MD5 collisions for inputs of different length?. $\endgroup$– fgrieu ♦Commented Oct 4, 2022 at 16:53
7 Answers
Yes you can, see at the MD5 Collision Demo, the two blocks:
d131dd02c5e6eec4693d9a0698aff95c 2fcab58712467eab4004583eb8fb7f89 55ad340609f4b30283e488832571415a 085125e8f7cdc99fd91dbdf280373c5b d8823e3156348f5bae6dacd436c919c6 dd53e2b487da03fd02396306d248cda0 e99f33420f577ee8ce54b67080a80d1e c69821bcb6a8839396f9652b6ff72a70
and
d131dd02c5e6eec4693d9a0698aff95c 2fcab50712467eab4004583eb8fb7f89 55ad340609f4b30283e4888325f1415a 085125e8f7cdc99fd91dbd7280373c5b d8823e3156348f5bae6dacd436c919c6 dd53e23487da03fd02396306d248cda0 e99f33420f577ee8ce54b67080280d1e c69821bcb6a8839396f965ab6ff72a70
produce an MD5 collision.
Each of these blocks has MD5 hash 79054025255fb1a26e4bc422aef54eb4
.
-
4$\begingroup$ Are there any 2 email addresses that you know, that will produce the same MD5 hash? I ask this because I know that Gravatar website uses MD5 as an identifier of accounts (here: en.gravatar.com/site/implement/images/java ) , which is done on email addresses. Since email addresses aren't bound by length, any function that operates on it and returns a limited string must have collisions. $\endgroup$ Commented Jul 25, 2019 at 19:41
Just to show you how easy it is today to create collisions on MD5:
One could create collisions using Marc Steven's HashClash on AWS and estimated the the cost of around $0.65 per collision.
These 2 images have the same md5 hash: 253dd04e87492e4fc3471de5e776bc3d
If you want to test it yourself and the images below do not give you the MD5 hash displayed above then you may need to take images from the original link below:
Reference: http://natmchugh.blogspot.com/2015/02/create-your-own-md5-collisions.html
-
27$\begingroup$ Same hash and theme... $\endgroup$ Commented May 11, 2016 at 11:37
-
$\begingroup$ when i used the basic hash of mac's terminal, i get different results !! MD5 (image1.jpg) = d37ca5b7a8e39f810bc341616005fd0f MD5 (image2.jpg) = 6dbe9c815f73327fd10c3a5b0b3a7498 $\endgroup$ Commented Jul 23, 2017 at 16:18
-
46$\begingroup$ @DeyaEldeen probably the images have been altered by stackexchange. Btw only looking at the pictures clearly shows there is a collision somewhere… ;-) $\endgroup$ Commented Aug 16, 2017 at 9:45
-
$\begingroup$ @DeyaEldeen The target hash is
253dd04e87492e4fc3471de5e776bc3d
$\endgroup$– Déjà vuCommented Nov 29, 2021 at 5:34 -
3$\begingroup$ I got the pictures downloaded directly from stackexchange and I can confirm the collision. Also, by inspecting the pictures I can also see the picture itself has "little" to do with the collision itself, since there's data after both pictures JPEG end marker (0xffd9), which the image renderer completely ignores but the md5 does not. So it's just adding some strings at the end of both files that don't affect the picture rendered until the collision is found. $\endgroup$– AzurlakeCommented Sep 5, 2023 at 8:23
A new result shows how to generate single block MD5 collisions, including an example collision:
> md5sum message1.bin message2.bin
> 008ee33a9d58b51cfeb425b0959121c9 message1.bin
> 008ee33a9d58b51cfeb425b0959121c9 message2.bin
There is an earlier example of a single block collision, but the technique for generating it was not published.
-
2$\begingroup$ I just saw it too on eprint and was about to post this one, but you beat me to that :) $\endgroup$– JalajCommented Jan 30, 2012 at 18:26
MD5 was intended to be a cryptographic hash function, and one of the useful properties for such a function is its collision-resistance. Ideally, it should take work comparable to around $2^{64}$ tries (as the output size is $128$ bits, i.e. there are $2^{128}$ different possible values) to find a collision (two different inputs hashing to the same output). (Actually, brute-forcing this is today almost in the range of possible, so this alone would be a reason not to use any small-output hash function like MD5.)
It showed that MD5 is not that resistant as intended, and nowadays it is relatively easy to produce more collisions, even with an arbitrary common prefix and suffix.
There was a spectacular example, when someone used an MD5 collision to get a fake SSL certificate from a certification agency. The agency signed a certificate for a domain which belonged to the attacker, and the attacker produced a different certificate (for another domain) with the same hash, i.e. for which the same signature was valid.
Don't use MD5 for any application which relies on collision-resistance (like signatures) ... or for any new application at all. Use SHA-2 (or SHA-3) now.
-
$\begingroup$ Or use Blake2b. Faster and more secure. $\endgroup$– DemiCommented Mar 24, 2016 at 2:21
-
6$\begingroup$ @Demetri while faster can be easily proven (on specific hardware), is there a proof of it being more secure (if it's twice as fast it might be twice as insecure from a brute-force attack)? The most analysis goes into the most-widely used crypto functions trying to break them, so it doesn't always seem a fair comparison. $\endgroup$– Nick TCommented Jul 25, 2016 at 22:12
-
$\begingroup$ Just adding this link Is Blake better (2017), that may be relevant to the discussion (see SHA-2 near the bottom). $\endgroup$– Déjà vuCommented Nov 29, 2021 at 5:29
Two different strings in hex format:
4dc968ff0ee35c209572d4777b721587d36fa7b21bdc56b74a3dc0783e7b9518afbfa200a8284bf36e8e4b55b35f427593d849676da0d1555d8360fb5f07fea2 4dc968ff0ee35c209572d4777b721587d36fa7b21bdc56b74a3dc0783e7b9518afbfa202a8284bf36e8e4b55b35f427593d849676da0d1d55d8360fb5f07fea2
both have MD5 hash:
008ee33a9d58b51cfeb425b0959121c9
Example:
> md5sum message1.bin message2.bin 008ee33a9d58b51cfeb425b0959121c9 message1.bin 008ee33a9d58b51cfeb425b0959121c9 message2.bin > sha1sum message1.bin message2.bin c6b384c4968b28812b676b49d40c09f8af4ed4cc message1.bin c728d8d93091e9c7b87b43d9e33829379231d7ca message2.bin
Another example (in hex):
0e306561559aa787d00bc6f70bbdfe3404cf03659e704f8534c00ffb659c4c8740cc942feb2da115a3f4155cbb8607497386656d7d1f34a42059d78f5a8dd1ef 0e306561559aa787d00bc6f70bbdfe3404cf03659e744f8534c00ffb659c4c8740cc942feb2da115a3f415dcbb8607497386656d7d1f34a42059d78f5a8dd1ef
both have MD5 hash:
cee9a457e790cf20d4bdaa6d69f01e41
Example 1. is straight from Marc Stevens: Single-block collision for MD5, 2012; he explains his method, with source code (alternate link to the paper).
Example 2. is adapted from Tao Xie and Dengguo Feng: Construct MD5 Collisions Using Just A Single Block Of Message, 2010.
Please note that above examples are hexadecimal representation of the strings. So to test it, you've to write these hex values into the binary files and then compare them as shown above.
To make simple test in shell, please check the commands provided in: Can two different strings generate the same MD5 hash code?
See also: What is the MD5 collision with the smallest input values?
-
15$\begingroup$ For those who can't squint: The 18th-to-last character in 1 is different
555
andd55
and in 2 it's somewhere in the middle of first row659e744
and659e704
$\endgroup$– rathCommented Apr 29, 2014 at 14:49 -
-
4$\begingroup$ In response to others saying they're not getting the same MD5 hash, the data is in hex format and must be converted to binary format. Here's an example in PHP: ideone.com/UyP22Z $\endgroup$ Commented Mar 7, 2016 at 21:24
-
2$\begingroup$ @ub3rst4r If you've got python, just type this:
hashlib.md5(bytearray.from_hex("STRING HERE")).digest()
$\endgroup$ Commented Aug 22, 2016 at 21:47 -
1$\begingroup$ Or this tool supports also HEX input: decrane.io/md5 $\endgroup$ Commented Jan 31, 2017 at 19:47
Here are some other interesting examples. One of them is, two downloadable executables that have the same MD5 hash, but are actually different, and produce different (safe) results when run!
So much for using MD5 hashes to ensure download file integrity :-(
From "Schneier on Security", March 10, 2005…
More Hash Function Attacks
Here's(1) a pair of valid X.509 certificates that have identical signatures. The hash function used is MD5.
And here's a paper(2) demonstrating a technique for finding MD5 collisions quickly: eight hours on 1.6 GHz computer.
Links: