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.

326 Chapter 7 • Advanced Topics<br />

Notes from the Underground…<br />

Other Truncation <strong>Attacks</strong><br />

Truncation of user-supplied input in <strong>SQL</strong> queries can lead to vulnerabilities even<br />

when pure <strong>SQL</strong> injection is not possible. In Microsoft <strong>SQL</strong> Server, parameterized queries<br />

must specify a maximum length for each string parameter, <strong>and</strong> if longer input is<br />

assigned to the parameter it is truncated to this length. Furthermore, <strong>SQL</strong> Server<br />

ignores trailing whitespace when comparing strings within a WHERE clause. These<br />

features can lead to a range of problems in vulnerable applications. For example,<br />

suppose an application allows users who have forgotten their password to submit their<br />

e-mail address <strong>and</strong> receive their forgotten password via e-mail. If the application<br />

accepts overly long input which gets truncated within the <strong>SQL</strong> query, an attacker can<br />

submit the following input:<br />

victim@example.org [many spaces]; evil@attacker.org<br />

In the resultant query, this input will retrieve the password for victim@example.<br />

org, because the trailing whitespace in the truncated input is ignored:<br />

SELECT password FROM tblUsers WHERE email = 'victim@example.org'<br />

When the application then sends the password to the originally supplied e-mail<br />

address, a copy is also sent to the attacker, enabling him to compromise the victim’s<br />

account. For further details of this <strong>and</strong> similar attacks, see the paper “Buffer Truncation<br />

Abuse in .NET <strong>and</strong> Microsoft <strong>SQL</strong> Server,” written by Gary O’Leary-Steele <strong>and</strong> available<br />

at www.scoobygang.org/HiDDenWarez/bta.pdf.<br />

Bypassing Custom Filters<br />

Web applications are extremely varied, <strong>and</strong> you are likely to encounter all kinds of weird <strong>and</strong><br />

wonderful input filters in the wild. You frequently can bypass these filters with a little<br />

imagination.<br />

Oracle Application Server provides a useful case study in poorly devised custom filters.<br />

This product provides a Web interface to database procedures, enabling developers to<br />

quickly deploy a Web application based on functionality that is already implemented

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

Saved successfully!

Ooh no, something went wrong!