“Reverse” SQL Injection Using HTTP Headers
I’ve been doing a good deal of research on HTTP Headers recently and was intrigued when I saw the following tweet last week.

The link takes you to a list of hosts that respond with the value “DROP TABLE” somewhere within the servers HTTP headers.
In case you aren’t already familiar with the HTTP protocol, when you make a request to a web site, lets say logrhythm.com, something like this is going on in the background.

In this case, we place a GET request for logrhythm.com and everything after the “HTTP/1.1 200 OK” are the HTTP header fields that the remote server server sent back to us. As we can see above, the server claims to be IIS/6.0. Based off of other returned header data, “X-powered-By:PleskWin, ASP.NET” for example, it’s probably a safe bet that it’s a windows server. Back to the point though, in the case of Mikko’s example, the servers listed don’t respond with a know server type, instead the following text:
Server: ‘; DROP TABLE servertypes; –
Clearly, this is not an actual server type, instead a SQL injection command.
Why would someone configure a server to respond this way?
Well, if we read the SQL it’s pretty simple. It’s telling the server to delete/remove the table servertypes. So who would be inserting HTTP Header response codes into a DB and would have a table named servertypes? Spiders, bots and crawlers of course! Well i’m guessing that’s the idea anyway.
So a bot hits your site, parses your header responses and tries to insert the value from “Server:” into a DB . If it happens to have a table named, servertype and SQL the statements aren’t being prepared or sanitized properly, then the table gets dropped.
Ultimately, it’s probably a joke more than anything but it’s interesting to think about. This assessment seems to be pretty accurate based on a Reddit mod’s explanation of why Reddit does it here. At this point I will have to also admit that this is not really “reverse” SQLi because that doesn’t really add up technically.
In event that you would like to configure your servers to reply with different responses, check out the following links:
Apache: http://httpd.apache.org/docs/2.0/mod/mod_headers.html
IIS7:http://technet.microsoft.com/en-us/library/cc753133(v=ws.10).aspx
NginX:http://blog.secaserver.com/2012/03/customize-server-header-nginx/
Also, I like this site for viewing HTTP headers where standard proxy means are not ideal. http://pgl.yoyo.org/http/server-headers.php
Tags: apache, DROP TABLES, http headers, IIS, NginX, sql injection, sqli
LogRhythm wins "Innovator of the Year" from SC Magazine. "This is not your father's log manager."