Saturday, January 27, 2024

Stop Using MD-5, Now!

TL;DR: Don't use MD-5 to identify malware samples. Believe me, it is a bad idea. Use SHA-256 or a stronger hash function.

This post is dedicated to all malware researchers, still using MD-5 to identify malware samples.

Before deep-diving into the details, let me explain my view on this topic. Whenever you want to identify a malware, it is only OK to publish the MD-5 hash of the malware if you post at least the SHA-256 hash of the malware as well. Publishing only the MD-5 hash is unprofessional. If you want to understand why, please continue reading. If you know about the problem, but want to help me spread the word, please link to my site www.stopusingmd5now.com.

By writing articles/posts/etc. and publishing the MD-5 hash only, it is the lesser problem that you show people your incompetency about hash functions, but you also teach other people to use MD-5. And it spreads like a disease... Last but not least, if I find a sample on your blog post, and you use MD-5 only, I can't be sure we have the same sample.

Here is a list to name a few bad examples (order is in Google search rank order):


Introduction to (cryptographic) hash functions

A long time ago (according to some sources since 1970) people started designing hash functions, for an awful lot of different reasons. It can be used for file integrity verification, password verification, pseudo-random generation, etc. But one of the most important properties of a cryptographic hash function is that it can "uniquely" identify a block of data with a small, fixed bit string. E.g., malware can be identified by using only the hash itself, so everybody who has the same malware sample will have the same hash; thus they can refer to the malware by the hash itself.

It is easy to conclude that there will always be collisions, where a different block of data has the same result hashes. The domain (block of data) is infinite, while the codomain (possible hash values) is finite. The question is how easy it is to find two different blocks of data, having the same hash. Mathematicians call this property "collision resistance." Proper cryptographic hash functions are collision-resistant, meaning it is impractical or impossible to find two different blocks of data, which have the same hash.

In 1989 Ronald Rivest (the first letter in the abbreviation of the RSA algorithm) designed the MD-2 hashing algorithm. Since 1997 there are publications about that this hashing algorithm is far from perfect.

In 1990 Ronald Rivest designed the MD-4 algorithm, which is considered as broken at least from 1991. But MD-4 is still in use from Windows XP until Windows 8 in the password protocol (NTLM). Unfortunately, there are more significant problems with NTLM besides using MD-4, but this can be the topic of a different blog post.

In 1991 (you might guess who) designed yet another hashing algorithm called MD-5, to replace MD-4  (because of the known weaknesses). But again, in from 1993 it has been shown many times that MD-5 is broken as well. According to Wikipedia, "On 18 March 2006, Klima published an algorithm [17] that can find a collision within one minute on a single notebook computer, using a method he calls tunneling". This means, that with the 8 years old computing power of a single notebook one can create two different files having the same MD-5 hash. But the algorithms to generate collisions have been improved since, and "a 2013 attack by Xie Tao, Fanbao Liu, and Dengguo Feng breaks MD-5 collision resistance in 2^18 time. This attack runs in less than a second on a regular computer." The key takeaway here is that it is pretty damn hard to design a secure cryptographic hash function, which is fast, but still safe. I bet that if I would develop a hash function, Ron would be able to hack it in minutes.

Now, dear malware researcher, consider the following scenario. You as, a malware analyst, find a new binary sample. You calculate the MD-5 hash of the malware, and Google for that hash. You see this hash value on other malware researchers or on a sandbox/vendor's site. This site concludes that this sample does this or that, and is either malicious or not. Either because the site is also relying solely on MD-5 or because you have only checked the MD-5 and the researcher or sandbox has a good reputation, you move on and forget this binary. But in reality, it is possible that your binary is totally different than the one analyzed by others. The results of this mistake can scale from nothing to catastrophic.

If you don't believe me, just check the hello.exe and erase.exe on this site from Peter Sellinger. Same MD-5, different binaries; a harmless and a (fake) malicious one... And you can do the same easily at home. No supercomputers,  no NSA magic needed.

On a side-note, it is important to mention that even today it can be hard to find a block of data (in generic), if only the MD-5 hash is known ("pre image resistance"). I have heard people arguing this when I told them using MD-5 as a password hash function is a bad idea. The main problem with MD-5 as a password hash is not the weaknesses in MD-5 itself, but the lack of salt, lack of iterations, and lack of memory hardness. But still, I don't see any reason why you should use MD-5 as a building block for anything, which has anything to do with security. Would you use a car to drive your children to the school, which car has not been maintained in the last 23 year? If your answer is yes, you should neither have children nor a job in IT SEC.

Conclusion

If you are a malware researcher, and used MD-5 only to identify malware samples in the past, I suggest to write it down 1000 times: "I promise I won't use MD-5 to identify malware in the future."

I even made a website dedicated to this problem, www.stopusingmd5now.com . The next time you see a post/article/whatever where malware is identified by the MD-5 hash only, please link to this blog post or website, and the world will be a better and more professional place.


PS: If you are a forensics investigator, or software developer developing software used in forensics, the same applies to you.
PS 2: If you find this post too provocative and harsh, there is a reason for this ...

Update: I have modified two malware (Citadel, Atrax) with the help of HashClash, and now those have the same MD-5. Many thanks for Marc Stevens for his research, publishing his code, and help given during the collision finding.
Related articles

  1. Pentest Tools Apk
  2. Easy Hack Tools
  3. Hack Tools For Pc
  4. Pentest Tools Url Fuzzer
  5. Hack App
  6. Hacking App
  7. Hacking Tools 2019
  8. Game Hacking
  9. Pentest Tools Bluekeep
  10. Hackrf Tools
  11. Hack Website Online Tool
  12. Underground Hacker Sites
  13. Hacker Tools
  14. Pentest Tools Website
  15. Hack Tools For Ubuntu
  16. Nsa Hack Tools Download
  17. How To Install Pentest Tools In Ubuntu
  18. Hacking Apps
  19. Hack Tool Apk
  20. Android Hack Tools Github
  21. Hacking Tools Name
  22. Pentest Tools Website
  23. Pentest Tools For Ubuntu
  24. Underground Hacker Sites
  25. Hack Tools
  26. Kik Hack Tools
  27. Easy Hack Tools
  28. Android Hack Tools Github
  29. Hacking Tools Kit
  30. Hacker Tools Linux
  31. Ethical Hacker Tools
  32. Pentest Tools Download
  33. Hak5 Tools
  34. Computer Hacker
  35. Pentest Reporting Tools
  36. New Hacker Tools
  37. Pentest Tools Port Scanner
  38. Bluetooth Hacking Tools Kali
  39. Pentest Tools Windows
  40. Pentest Tools Github
  41. Computer Hacker
  42. New Hack Tools
  43. Hacking Tools Mac
  44. Pentest Tools Kali Linux
  45. Hack Tools For Games
  46. Easy Hack Tools
  47. Hacking Tools For Windows Free Download
  48. Usb Pentest Tools
  49. Hacking Tools Windows 10
  50. Pentest Tools Github
  51. Hack App
  52. Hacking Tools Download
  53. Hack Tools Pc
  54. Computer Hacker
  55. Usb Pentest Tools
  56. Pentest Tools Alternative
  57. Hack Tool Apk
  58. Pentest Tools Free
  59. Hacker Tools Software
  60. Hacker Search Tools
  61. Hacking Tools 2020
  62. Hacking Tools For Windows 7
  63. Hacker Hardware Tools
  64. Hacker Tools Apk Download
  65. Hacker Tools List
  66. Hacking Tools Mac
  67. Hacking Tools Pc
  68. Best Hacking Tools 2019
  69. Pentest Tools Alternative
  70. Best Hacking Tools 2020
  71. Hacking Tools Mac
  72. Hack Tools For Games
  73. Hacking Tools Kit
  74. Pentest Tools Subdomain
  75. Hack App
  76. How To Install Pentest Tools In Ubuntu
  77. What Is Hacking Tools
  78. Best Pentesting Tools 2018
  79. Hacking Tools Github
  80. Computer Hacker
  81. Hacker Tools For Windows
  82. Physical Pentest Tools
  83. Pentest Tools Online
  84. Pentest Tools List
  85. Pentest Tools Kali Linux
  86. Hack Tools For Pc
  87. Hackrf Tools
  88. Pentest Tools For Android
  89. Pentest Tools Website
  90. Hack Tools For Games
  91. Wifi Hacker Tools For Windows
  92. Hacking Tools Windows 10
  93. Hacker Tools For Ios
  94. Pentest Tools Kali Linux

No comments:

Post a Comment