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

Create successful ePaper yourself

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

Exploiting Authenticated Vulnerabilities<br />

Advanced Topics • Chapter 7 337<br />

Many <strong>SQL</strong> injection vulnerabilities reside within authenticated functionality. In some cases,<br />

only privileged users, such as application administrators, can reach <strong>and</strong> exploit the vulnerability.<br />

Usually, this constraint reduces the impact of the vulnerability somewhat.<br />

If the administrator is completely trusted within the application, <strong>and</strong> is also able to<br />

perform arbitrary <strong>SQL</strong> queries directly in the database, one might suppose that <strong>SQL</strong><br />

injection flaws which only the administrator can access are completely inconsequential,<br />

<strong>and</strong> are not exploitable unless the attacker has already compromised the administrator’s<br />

account.<br />

However, this overlooks the possibility of cross-site request forgery. This attack<br />

technique can be combined with many kinds of authenticated vulnerabilities to make<br />

those vulnerabilities exploitable by an unprivileged attacker. Consider an administrative<br />

function which displays the account details of a selected user:<br />

https://www.example.org/admin/ViewUser.aspx?UID=123<br />

The UID parameter is vulnerable to <strong>SQL</strong> injection, but this can be directly exploited<br />

only by the administrator. However, an attacker who is aware of the vulnerability can use<br />

cross-site request forgery to exploit the bug indirectly. For example, if he creates a Web page<br />

containing the following HTML, <strong>and</strong> induces a logged-in administrator to visit it, his<br />

injected <strong>SQL</strong> query will be executed, creating a new administrative user that is controlled by<br />

the attacker:<br />

<br />

Note that cross-site request forgery is a one-way attack, <strong>and</strong> the attacker cannot<br />

trivially retrieve the application’s response to the attack request. Hence, the attacker<br />

must inject an <strong>SQL</strong> query which causes a useful side effect, rather than just seeking to<br />

read sensitive data.<br />

The moral of this story is that cross-site request forgery does not need to involve<br />

application functionality that was actually designed for performing sensitive actions. In the<br />

example described, the application is no less vulnerable than if it contained an explicit<br />

function for performing arbitrary <strong>SQL</strong> queries that was accessible only by administrators<br />

but not protected from request forgery. And because the example described is not actually<br />

designed for performing an action, it is much less likely to be included in the scope of any<br />

antirequest forgery defenses that are implemented within the application.

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

Saved successfully!

Ooh no, something went wrong!