HULK vs. THOR - Application DoS Smackdown

SpiderLabs Research Team Contributions from:

@jgrunzweig

@ethackal

@claudijd

There was a new web server DoS tool released yesterday called HULK (Http Unbearable Load King). Here is a snippet from the blog page:

In my line of work, I get to see tons of different nifty hacking tools, and traffic generation tools that are meant to either break and steal information off a system, or exhaust its resource pool, rendering the service dead and putting the system under a denial of service.

For a while now, I have been playing with some of the more exotic tools, finding that their main problem is always the same… they create repeatable patterns. too easy to predict the next request that is coming, and therefor mitigate. Some, although elegant, lack the horsepower to really put a system on its knees.

For research purposes, I decided to take some of the lessons I've learned over time and practice what I preach.

Enforcing Python's engines, I wrote a script that generates some nicely crafted unique Http requests, one after the other, generating a fair load on a webserver, eventually exhausting it of resources. this can be optimized much much further, but as a proof of concept and generic guidance it does its job.

HULK Profile

HULK is a python script that will use various techniques to make the requests dynamic and thus more difficult to detect with defensive signatures. For instance, HULK will rotate both User-Agent and Referer fields as shown below:

Screen shot 2012-05-18 at 11.46.15 AM

Here is the section of code where the request is being built:

Screen shot 2012-05-18 at 1.51.44 PM
When HULK is run against my local Apache web server, I get requests similar to this -

GET /?CFEGD=MBDPVA HTTP/1.1
Accept-Encoding: identity
Host: 192.168.1.103
Keep-Alive: 116
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; .NET CLR 2.0.50727; InfoPath.2)
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Referer: http://engadget.search.aol.com/search?q=ALXUW
Cache-Control: no-cache
GET /?ASH=REHRKP HTTP/1.1
Accept-Encoding: identity
Host: 192.168.1.103
Keep-Alive: 110
User-Agent: Opera/9.80 (Windows NT 5.2; U; ru) Presto/2.5.22 Version/10.51
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Referer: http://www.google.com/?q=VUCWJE
Cache-Control: no-cache
GET /?UALK=USXGPJD HTTP/1.1
Accept-Encoding: identity
Host: 192.168.1.103
Keep-Alive: 110
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.1 (KHTML, like Gecko) Chrome/4.0.219.6 Safari/532.1
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Referer: http://engadget.search.aol.com/search?q=ZNWFXTOD
Cache-Control: no-cache

Notice the bolded entries are indeed dynamic and change their payloads with each request. Also note, however, that the python urllib2 libary is overwriting the "Connection: keep-alive" request header designation specified by the request.add_header() function and instead using "Connection: close". So much for trying to optimize that part of the attack...

THOR (ModSecurity Rules) Profile

Since the attack tool's name is using the Marvel comics super-hero name, we thought that we would also pay hommage to The Avengers movie that is currently out and call our ModSecurity defense rules THOR (Thumping Http Obvious Requests).

While the HULK tool does achieve its goal of randomizing the payloads of various headers, it is still quite easily identifiable due to the request header ordering of the requests. The request header ordering is always:

  • Accept-Encoding
  • Host
  • Keep-Alive
  • User-Agent
  • Accept-Charset
  • Connection
  • Referer
  • Cache-Control

Even though HULK defines a certain order of request headers using the request.add_header() function call, the actual order of the headers at run time is dictated by the dictionary key ordering of the python implementation.

This ordering is a unique fingerprint for this tool as no other legitimate web clients have this header ordering. Therefore, I created the following ModSecurity rule to identify HULK traffic:

SecRule REQUEST_HEADERS_NAMES ".*" "id:'11',chain,phase:1,t:none,log,drop,msg:'Request Header Ordering Alert: Potential Attack Tool - HULK DoS.',setvar:'tx.header_order=%{tx.header_order}, %{matched_var}'"
SecRule TX:HEADER_ORDER "@streq , Accept-Encoding, Host, Keep-Alive, User-Agent, Accept-Charset, Connection, Referer, Cache-Control""

This ruleset will create a custom variable that holds the request header name ordering. It then checks to see if it matches our HULK profile. If so, it will then initiate a drop action to quickly terminate the connection.

HULK vs. THOR

Let's now pit these two superheros against each other! These are some sample entries for how it would look when HULK is run against a ModSecurity/THOR site:

[Fri May 18 12:04:29 2012] [error] [client 192.168.1.103] ModSecurity: Access denied with connection close (phase 1). String match ", Accept-Encoding, Host, Keep-Alive, User-Agent, Accept-Charset, Connection, Referer, Cache-Control" at TX:header_order. [file "/usr/local/apache/conf/crs/base_rules/modsecurity_crs_15_custom.conf"] [line "1"] [id "11"] [msg "Request Header Ordering Alert: Potential Attack Tool - HULK DoS."] [hostname "192.168.1.103"] [uri "/"] [unique_id "T7ZzDcCoAWcAAV8cETwAAAAB"]
[Fri May 18 12:04:29 2012] [info] [client 192.168.1.103] (9)Bad file descriptor: core_output_filter: writing data to the network
[Fri May 18 12:04:30 2012] [error] [client 192.168.1.103] ModSecurity: Access denied with connection close (phase 1). String match ", Accept-Encoding, Host, Keep-Alive, User-Agent, Accept-Charset, Connection, Referer, Cache-Control" at TX:header_order. [file "/usr/local/apache/conf/crs/base_rules/modsecurity_crs_15_custom.conf"] [line "1"] [id "11"] [msg "Request Header Ordering Alert: Potential Attack Tool - HULK DoS."] [hostname "192.168.1.103"] [uri "/"] [unique_id "T7ZzDsCoAWcAAV8fEYIAAAAE"]
[Fri May 18 12:04:30 2012] [info] [client 192.168.1.103] (9)Bad file descriptor: core_output_filter: writing data to the network
[Fri May 18 12:04:30 2012] [error] [client 192.168.1.103] ModSecurity: Access denied with connection close (phase 1). String match ", Accept-Encoding, Host, Keep-Alive, User-Agent, Accept-Charset, Connection, Referer, Cache-Control" at TX:header_order. [file "/usr/local/apache/conf/crs/base_rules/modsecurity_crs_15_custom.conf"] [line "1"] [id "11"] [msg "Request Header Ordering Alert: Potential Attack Tool - HULK DoS."] [hostname "192.168.1.103"] [uri "/"] [unique_id "T7ZzDsCoAWcAAV8bEUsAAAAA"]
[Fri May 18 12:04:30 2012] [info] [client 192.168.1.103] (9)Bad file descriptor: core_output_filter: writing data to the network
[Fri May 18 12:04:30 2012] [error] [client 192.168.1.103] ModSecurity: Access denied with connection close (phase 1). String match ", Accept-Encoding, Host, Keep-Alive, User-Agent, Accept-Charset, Connection, Referer, Cache-Control" at TX:header_order. [file "/usr/local/apache/conf/crs/base_rules/modsecurity_crs_15_custom.conf"] [line "1"] [id "11"] [msg "Request Header Ordering Alert: Potential Attack Tool - HULK DoS."] [hostname "192.168.1.103"] [uri "/"] [unique_id "T7ZzDsCoAWcAAV8eEYQAAAAD"]
[Fri May 18 12:04:30 2012] [info] [client 192.168.1.103] (9)Bad file descriptor: core_output_filter: writing data to the network
[Fri May 18 12:04:30 2012] [error] [client 192.168.1.103] ModSecurity: Access denied with connection close (phase 1). String match ", Accept-Encoding, Host, Keep-Alive, User-Agent, Accept-Charset, Connection, Referer, Cache-Control" at TX:header_order. [file "/usr/local/apache/conf/crs/base_rules/modsecurity_crs_15_custom.conf"] [line "1"] [id "11"] [msg "Request Header Ordering Alert: Potential Attack Tool - HULK DoS."] [hostname "192.168.1.103"] [uri "/"] [unique_id "T7ZzDsCoAWcAAV8dEUQAAAAC"]
[Fri May 18 12:04:30 2012] [info] [client 192.168.1.103] (9)Bad file descriptor: core_output_filter: writing data to the network

As an added benefit, using the ModSecurity drop action (which issues a TCP FIN packet to forcefully close the connection) seems to cause HULK to freeze. :) After receiving the inital 10 requests, and issuing the drop, HULK sits idle and does not send anymore requests. Apparently HULK only deals well with cleanly terminated HTTP responses.

Round 1 goes to THOR!

image from upload.wikimedia.org
Cover to The Mighty Thor #272 (June 1978).

Art by John Buscema.

Trustwave reserves the right to review all comments in the discussion below. Please note that for security and other reasons, we may not approve comments containing links.