19.09.2017 Views

the-web-application-hackers-handbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9 n Attacking Data Stores 325<br />

Beyond SQL Injection: Escalating <strong>the</strong> Database Attack<br />

A successful exploit of a SQL injection vulnerability often results in total compromise<br />

of all <strong>application</strong> data. Most <strong>application</strong>s employ a single account for<br />

all database access and rely on <strong>application</strong>-layer controls to enforce segregation<br />

of access between different users. Gaining unrestricted use of <strong>the</strong> <strong>application</strong>’s<br />

database account results in access to all its data.<br />

You may suppose, <strong>the</strong>refore, that owning all <strong>the</strong> <strong>application</strong>’s data is <strong>the</strong><br />

finishing point of a SQL injection attack. However, <strong>the</strong>re are many reasons<br />

why it might be productive to advance your attack fur<strong>the</strong>r, ei<strong>the</strong>r by exploiting<br />

a vulnerability within <strong>the</strong> database itself or by harnessing some of its built-in<br />

functionality to achieve your objectives. Fur<strong>the</strong>r attacks that can be performed<br />

by escalating <strong>the</strong> database attack include <strong>the</strong> following:<br />

n If <strong>the</strong> database is shared with o<strong>the</strong>r <strong>application</strong>s, you may be able to escalate<br />

privileges within <strong>the</strong> database and gain access to o<strong>the</strong>r <strong>application</strong>s’ data.<br />

n You may be able to compromise <strong>the</strong> operating system of <strong>the</strong> database server.<br />

n You may be able to gain network access to o<strong>the</strong>r systems. Typically, <strong>the</strong><br />

database server is hosted on a protected network behind several layers<br />

of network perimeter defenses. From <strong>the</strong> database server, you may be in<br />

a trusted position and be able to reach key services on o<strong>the</strong>r hosts, which<br />

may be fur<strong>the</strong>r exploitable.<br />

n You may be able to make network connections back out of <strong>the</strong> hosting<br />

infrastructure to your own computer. This may enable you to bypass <strong>the</strong><br />

<strong>application</strong>, easily transmitting large amounts of sensitive data ga<strong>the</strong>red<br />

from <strong>the</strong> database, and often evading many intrusion detection systems.<br />

n You may be able to extend <strong>the</strong> database’s existing functionality in arbitrary<br />

ways by creating user-defined functions. In some situations, this may enable<br />

you to circumvent hardening that has been performed on <strong>the</strong> database by<br />

effectively reimplementing functionality that has been removed or disabled.<br />

There is a method for doing this in each of <strong>the</strong> mainstream databases,<br />

provided that you have gained database administrator (DBA) privileges.<br />

COMMON MYTH<br />

Many database administrators assume that it is unnecessary to defend <strong>the</strong> database<br />

against attacks that require au<strong>the</strong>ntication to exploit. They may reason<br />

that <strong>the</strong> database is accessed by only a trusted <strong>application</strong> that is owned by <strong>the</strong><br />

same organization. This ignores <strong>the</strong> possibility that a flaw within <strong>the</strong> <strong>application</strong><br />

may enable a malicious third party to interact with <strong>the</strong> database within <strong>the</strong><br />

<strong>application</strong>’s security context. Each of <strong>the</strong> possible attacks just described should<br />

illustrate why databases need to be defended against au<strong>the</strong>nticated attackers.

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

Saved successfully!

Ooh no, something went wrong!