Introduction to Hash DoS Attacks

    Someone asked me about the Hash DoS attack recently disclosed at CCC, so I thought I would give a high level explanation of it here in case it benefits others as well. Hash tables are often used in programming languages to map data keys and values together. A comparable real world example could be a phone book which maps a person's name (the key) to their phone number (the value). Web App languages often parse user-supplied request data into hash tables to allow developers easy access to the request. For example, in PHP you can access the fname parameter submitted in a POST request via the $_POST["fname"] variable.

    When hashing strings, it is not uncommon for more than one unique string to end up with the same hashed value. This is known as a Hash Collision. Normally this is not a problem, as languages use various strategies to resolve these collisions. However, an attacker can exploit this behavior to exhaust the CPU by forcing a large number of collisions via a single request with many parameters. Krzysztof Kotowicz created a demo that can be used to test whether your app is vulnerable.

    The core issue has been known since 2003 and as a result several languages, such as Perl and CRuby, have added randomization to their hash functions. Other languages have recently limited the number of parameters allowed in a single request, e.g. PHP's max_input_vars directive. By default, the max_input_vars directive limits the number of GET, POST and Cookie input variables to 1000. For those who can not patch their application framework, ModSecurity can be used to virtually patch this flaw. The rule below implements the same default functionality of the max_input_vars directive described above.

    SecRule &ARGS|&REQUEST_COOKIES_NAMES|&REQUEST_COOKIES "@gt 1000" "phase:2, \
      t:none,log,block,severity:2,msg:'Hash DoS Detected'"
    

Post new comment

The content of this field is kept private and will not be shown publicly.

Most Popular List

06/05/2011 | Written By Gordon Maddern | 62,233 Hits
About a month ago I was chatting on skype to a colleague about a payload for...
15/10/2011 | Written By Ty Miller | 17,545 Hits
Lets say that at some point you decided to adhere to security best practices...
28/06/2011 | Written By Sandeep Nain | 15,455 Hits
Coming from a family of civil engineers, I always knew that it is a rigorous...
24/05/2011 | Written By Gordon Maddern | 8,494 Hits
Skype has patched and released the fix for the Skype bug we found so we can d...

Most Recent Posts List

19/05/2013 | Written By Josh Zlatin | 3,201 Hits
Often when implementing customised ModSecurity solutions we need to...
07/05/2013 | Written By Richard Brown | 338 Hits
The term ‘ethical hacker’ is often misrepresented as the keywords...
05/04/2013 | Written By Gordon Maddern | 478 Hits
I recently had to go in to bat for a client who was told by their PCI auditor...
04/03/2013 | Written By Ty Miller | 2,289 Hits
  If you are anything like me, when you hear "Hacking in the Year 2...