Fortinet Blog | News and Threat Research

  • Products
  • Solutions
  • Service & Support
  • Partners
  • Corporate
  • Resources
  • How to Buy

Trash CRC32

by RSS Axelle Apvrille  |  June 09, 2009  |  Category: Security Research

Read this article if you use CRC32, or if you know it is unsecure but think it is good enough in your case.

CRC32 - Cyclic Redundancy Check with 32 bits of output - is a widely used checksum algorithm. It is designed to detect accidental alteration of data during transmission or storage. It is not meant to be used in security-related situations. Now, my crypto-friends are probably already bored and will tell me it has been known for ages. Sure, but if it is that obvious, why do people keep on using CRC32 in wrong situations ? Have a look at the following bad ideas, all have been taken from real situations and sometimes widely deployed:

* WEP uses CRC32 for data integrity of each packet. Consequently, WEP is vulnerable to practical chop-chop attacks. Do not use CRC32 for data integrity.

* CRC32 has been used to generate unique IDs. This is a bad idea too, because CRC32 collisions are far too likely. For example, the two words a1sellers and advertees produce the same checksum. Note that, in addition, they have the same length. Do not use CRC32 for unique ID generation.

* Outlook PST’s passwords are ‘protected’ with CRC32. As a consequence, an attacker merely needs to find any word whose CRC32 matches the original password’s CRC32. Have a look at this video to see how easy it is to break PSTs. Do not use CRC32 for authentication.

* CRC32 has been used for anti-virus whitelisting. The checksum of known clean files (for example, legitimate files of your favoritate Operating System) are gathered in a so-called white list. Then, whenever a file is scanned, it is first checked against the white-list, thus speeding up the process for clean files and reducing chances for False Positives. However, this is a bad idea, because an attacker can easily craft a modified virus, for example with random overlay, so as to match the checksum of a whitelisted clean file. Such a virus would bypass the anti-virus detection. Adding the file’s size to each clean file checksum does not significantly complicate the attack: crafting a malware with the same CRC32 and size as a clean file is no more than a few dozen minutes of computing. Do not use CRC32 for data matching.

* _**Why isn't CRC32 good for security?**_ There are at least two reasons. The first is because its output is only 32-bit long. This is far too small for a low collision rate, using today's computers. [Lenstra and Verheul](http://www.keylength.com/en/1/) recommend at least 154 bits. The second reason is that checksums do not fulfill the three mathematic properties asked for cryptographic hash functions which are [pre-image resistance (also known as one-way functions), second pre-image resistance (also known as weak collision resistance) and collision resistance](http://en.wikipedia.org/wiki/Cryptographic_hash_function).


* _**If CRC32 detects accidental errors, why can't it detect malicious alteration ? what's so different between both?**_ In practice, accidental errors often occur sporadically rather than at random. CRC32 typically produces a very different checksum for similar input with only a few errors. However, a clever attacker can intentionally make an error in one location and then craft the necessary modifications in the rest of the input to compensate for the initial error. CRC32 is not designed to detect intentional modifications.


* _**I need high performance, hash functions are slow**_. While this statement might be true, people usually say that without conducting benchmarks for their specific use. Performance is a complicated matter: depending on implementations, underlying hardware, machine load (etc), there are cases where CRC32 will be slower than SHA1. However, reliable benchmarks of software cryptographic libraries generally show that SHA1 is 20 to 40 percent slower than CRC32 ([Crypto++](http://www.cryptopp.com/benchmarks.html), [LibTomCrypt](http://libtomcrypt.com/ltc113.html), [Botan](http://botan.randombit.net/news/benchmarks/1_7_18.html)). With a SHA1 chip, it is quite likely you won't notice any difference at all...


* _**CRC32, MD5, SHA1 (etc) are all broken. What difference does it make if I use CRC32 ?**_ Actually, there **is** a big difference. The meaning of "broken" is quite different for these algorithms. For SHA1, collisions are theoretical, orĀ  if [McDonald et al](http://eurocrypt2009rump.cr.yp.to/837a0a8086fa6ca714249409ddfae43d.pdf)'s recent work is confirmed - at best, they require very high computational power. For MD5, a few researchers have demonstrated collisions could be found in practice. For example, read the recent work of [Sotirov et al](http://www.phreedom.org). Anybody with a good understanding of their work (or related) can find collisions in MD5. Finally, CRC32 is the worst case: collisions can be found very easily. It does not require any specific knowledge nor equipment. A 100-line Perl script will find collisions.


* _**Okay... but which hash function should I choose ?**_ If you need a widely supported algorithm, I recommend you select SHA1. Otherwise, you could look into RIPEMD-160 or SHA512. Check the current status of those algorithms on the [Hash Function Lounge](http://www.larc.usp.br/~pbarreto/hflounge.html), and be sure to keep an eye on [NIST's SHA3](http://csrc.nist.gov/groups/ST/hash/sha-3/index.html) contest.

All those situations would have required use of a cryptographic hash functionsuch as SHA1, SHA256, RIPEMD-160, or a Hashed MAC - HMAC - for authentication. But some of you might not be convinced yet.

by RSS Axelle Apvrille  |  June 09, 2009  |  Category: Security Research
Tags: CRC32 Cryptography hash function
comments powered by Disqus

Category

  • All
  • RSS Subscribe
  • Security Research
  • RSS Subscribe
  • Industry Trends & News
  • RSS Subscribe

FortiGuard Labs on the Web

  • Twitter Twitter
  • Facebook Facebook
  • LinkedIn LinkedIn
  • Youtube Youtube

Monthly Archives

  • May 2013 8
  • April 2013 17
  • March 2013 12
  • February 2013 11
  • January 2013 12
  • December 2012 8
  • November 2012 7
  • October 2012 4
  • September 2012 7
  • August 2012 7
  • July 2012 9
  • June 2012 17
  • May 2012 14
  • April 2012 16
  • March 2012 15
  • February 2012 11
  • January 2012 6
  • December 2011 4
  • November 2011 6
  • October 2011 11
  • September 2011 2
  • August 2011 2
  • July 2011 4
  • June 2011 6
  • May 2011 6
  • April 2011 5
  • March 2011 7
  • February 2011 5
  • January 2011 7
  • December 2010 8
  • November 2010 11
  • October 2010 3
  • September 2010 8
  • August 2010 4
  • July 2010 9
  • June 2010 9
  • May 2010 9
  • April 2010 6
  • March 2010 8
  • February 2010 6
  • January 2010 9
  • December 2009 8
  • November 2009 6
  • October 2009 6
  • September 2009 8
  • August 2009 5
  • July 2009 8
  • June 2009 7
  • May 2009 4
  • April 2009 7
  • March 2009 9
  • February 2009 4
  • January 2009 1
  • Older

Popular topics

exploit symbian derek manky Zeus BYOD SpyEye iphone symbos/yxes Mac OS X symbianos reverse engineering zitmo bredolab botnet mobile phones Firewall challenge Anonymous conference Threat Landscape virut reversing Research UTM FortiGate Mobile Security webinar privacy Anti-Spam adobe apple Security hacking challenge Fortinet google stuxnet hashdays android Cryptography Malware facebook Windows mobile malware sms trojan microsoft mobile mobile phone network security Antivirus