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.

Advanced Topics • Chapter 7 327<br />

within a database. To prevent attackers from leveraging the server to access the powerful<br />

procedures that are built into the Oracle database, the server implements an exclusion list,<br />

<strong>and</strong> blocks access to packages such as SYS <strong>and</strong> OWA.<br />

Blacklist-based filters of this kind are, of course, notoriously susceptible to bypasses,<br />

<strong>and</strong> Oracle’s exclusion list is no exception. In the early 2000s, David Litchfield discovered<br />

a series of defects in the filter, each involving ways of representing blocked packages that<br />

appear benign to the front-end filter but are still processed as intended by the back-end<br />

database.<br />

For instance, whitespace can be placed before the package name:<br />

https://www.example.com/pls/dad/%0ASYS.package.procedure<br />

The Y character in SYS can be replaced with a URL-encoded ÿ character:<br />

https://www.example.com/pls/dad/S%FFS.package.procedure<br />

The package name can be placed within quotation marks:<br />

https://www.example.com/pls/dad/"SYS".package.procedure<br />

A programming goto label can be placed before the package name:<br />

https://www.example.com/pls/dad/SYS.package.procedure<br />

Although these examples are specific to a particular product, they illustrate the kinds of<br />

issues that can arise with custom input filters, <strong>and</strong> the techniques that you need to try<br />

when attempting to circumvent them.<br />

Using Non-St<strong>and</strong>ard Entry Points<br />

Sometimes you will encounter situations where application-wide defenses are in place<br />

(such as WAFs) which implement effective input filters <strong>and</strong> prevent the usual means of<br />

exploiting vulnerable code. In this situation, you should look for non-st<strong>and</strong>ard entry<br />

points into the application, which may be vulnerable to <strong>SQL</strong> injection <strong>and</strong> which the<br />

applicationwide filters may have overlooked.<br />

Many WAFs inspect the values of every request parameter, but do not validate the<br />

parameter names. You can, of course, add arbitrary parameter names to any request. If the<br />

application incorporates arbitrary parameter names into dynamic <strong>SQL</strong> queries, you may be<br />

able to perform <strong>SQL</strong> injection despite the presence of the filter.<br />

Consider an application function which saves user preferences. The preferences page has<br />

a large number of input fields, which are submitted to a URL such as the following:<br />

https://www.example.org/Preferences.aspx?lang=en&region=uk&currency=gbp...

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

Saved successfully!

Ooh no, something went wrong!