28.10.2014 Views

SQL Injection Attacks and Defense - 2009

SQL Injection Attacks and Defense - 2009

SQL Injection Attacks and Defense - 2009

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

406 Chapter 9 • Platform-Level <strong>Defense</strong>s<br />

Use an Empty Default Web Site<br />

The HTTP/1.1 protocol requires HTTP clients to send the Host header in the request to<br />

the Web server. To access a specific Web site, the header value must match the host name in<br />

the Web server’s virtual host configuration. If a match is not found, the default Web site<br />

content will be returned. For example, attempting to connect to a Web site by Internet<br />

Protocol (IP) address will result in the content of the default Web site being returned.<br />

Consider the following example:<br />

GET / HTTP/1.1<br />

Host: 64.233.169.104<br />

…<br />

Google<br />

Here a request has been made to 64.223.169.104, which is actually an IP address<br />

of a Google Web server. What is returned by default is the familiar Google search page.<br />

This configuration makes sense for Google because Google likely doesn’t care whether it<br />

is being accessed by IP address or host name; Google wants everyone on the Internet to<br />

use its service. As the owner of an enterprise Web application, you may prefer a little more<br />

anonymity <strong>and</strong> would like to avoid discovery by attackers scanning your IP address range<br />

for ports 80 <strong>and</strong> 443. To ensure that users are connecting to your Web application by host<br />

name only, which usually takes the attacker more time <strong>and</strong> effort to dig up (but is known<br />

to your users), configure the Web server’s default Web site to return a blank default Web<br />

page. Given that legitimate users usually prefer easy-to-remember host names, access<br />

attempts via IP address could be a good way to detect potential intrusion attempts. Lastly,<br />

it’s worth pointing out that this is a defense-in-depth mechanism <strong>and</strong> is not sufficient to<br />

prevent unwanted discovery, but it can be especially effective against automated scanning<br />

programs (such as vulnerability scanners or even <strong>SQL</strong> injection worms) looking to identify<br />

vulnerable Web sites by IP address.<br />

Use Dummy Host Names<br />

for Reverse DNS Lookups<br />

I mentioned previously that it takes a little more work to discover valid host names before a<br />

Web site can be accessed if all you have is an IP address. One way to do this is to perform<br />

a reverse domain name system (DNS) lookup on the IP address. If the IP address resolves<br />

to a host name that is also valid on the Web server, you now have the information you need<br />

to connect to that Web site. However, if the reverse lookup returns something a little more<br />

generic, such as ool-43548c24.companyabc.com, you can keep unwanted attackers from discovering<br />

your Web site via reverse DNS lookups. If you’re using the dummy host name technique,<br />

ensure that the default Web site is also configured to return a blank default Web page.<br />

Again, this is a defense-in-depth mechanism <strong>and</strong> is not sufficient to prevent unwanted

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!