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.

272 Chapter 6 • Exploiting the Operating System<br />

Introduction<br />

One of the things mentioned in the introduction to Chapter 1 was the concept of utilizing<br />

functionality within the database to access portions of the operating system. Most databases<br />

ship with a wealth of useful functionality for database programmers, including interfaces for<br />

interacting with the database, or for extending the database with user-defined functionality.<br />

In some cases, such as for Microsoft <strong>SQL</strong> Server <strong>and</strong> Oracle, this functionality has provided<br />

a rich hunting ground for security researchers looking for bugs in these two database servers.<br />

In addition, a lot of this functionality can also be employed as exploit vectors in <strong>SQL</strong> injections<br />

ranging from the useful (reading <strong>and</strong> writing files) to the fun but useless (making the database<br />

server speak).<br />

In this chapter, we will discuss how to access the file system to perform useful tasks such<br />

as reading data <strong>and</strong> uploading files. We will also discuss a number of techniques for executing<br />

arbitrary comm<strong>and</strong>s on the underlying operating system, which could allow someone to<br />

extend his reach from the database <strong>and</strong> conduct an attack with a much wider scope.<br />

Before we begin, it is a good idea to discuss why someone would be interested in going<br />

down this rabbit hole at all. The ostensible answer, of course, is the universal one: because<br />

it is there. Beyond the trite sound byte, however, there a several reasons why someone would<br />

want to use <strong>SQL</strong> injection to attack the host.<br />

For instance, attacking the base host may allow the attacker to extend his reach. This means<br />

that a single application compromise can be extended to target other hosts in the vicinity of<br />

the database server. This ability to use the target database server as the pivot host bears promise,<br />

especially since the database server has traditionally resided deep within the network in what is<br />

most often a “target-rich” environment.<br />

Using <strong>SQL</strong> injection attacks to target the underlying host is also attractive because it<br />

presents an attacker with the somewhat rare opportunity to slide into a crevice where the lines<br />

between traditional unauthenticated <strong>and</strong> authenticated attacks reside. Overburdened system<br />

administrators <strong>and</strong> database administrators (DBAs) will often prioritize patching based on<br />

whether a vulnerability can be exploited by an anonymous user. In addition, exploits that<br />

require an authenticated user are sometimes put on the back burner while other, more urgent<br />

fires receive attention. An attacker exploiting an <strong>SQL</strong> injection bug effectively transforms his<br />

role from that of the unauthenticated anonymous user to the authenticated user being used<br />

by the application for the database connection. We will examine all of these cases both in this<br />

chapter <strong>and</strong> in Chapter 7.

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

Saved successfully!

Ooh no, something went wrong!