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.

338 Chapter 9 n Attacking Data Stores<br />

(continued)<br />

Oracle: ORA-00900: invalid SQL statement<br />

MS-SQL: Msg 170, Level 15, State 1, Line 1<br />

Line 1: Incorrect syntax near foo<br />

MySQL:<br />

Translation:<br />

You have an error in your SQL syntax. Check <strong>the</strong><br />

manual that corresponds to your MySQL server version<br />

for <strong>the</strong> right syntax to use near XXXXXX<br />

A general error message. The error messages listed previously all take<br />

precedence, so something else went wrong. It’s likely you can try<br />

alternative input and get a more meaningful message.<br />

Oracle:<br />

MS-SQL:<br />

MySQL:<br />

Translation:<br />

ORA-03001: unimplemented feature<br />

N/A<br />

N/A<br />

You have tried to perform an action that Oracle does not allow. This<br />

can happen if you were trying to display <strong>the</strong> database version string<br />

from v$version but you were in an UPDATE or INSERT query.<br />

Oracle:<br />

MS-SQL:<br />

MySQL:<br />

Translation:<br />

ORA-02030: can only select from fixed tables/views<br />

N/A<br />

N/A<br />

You were probably trying to edit a SYSTEM view. This can happen<br />

if you were trying to display <strong>the</strong> database version string from<br />

v$version but you were in an UPDATE or INSERT query.<br />

Preventing SQL Injection<br />

Despite all its different manifestations, and <strong>the</strong> complexities that can arise in its<br />

exploitation, SQL injection is in general one of <strong>the</strong> easier vulnerabilities to prevent.<br />

Never<strong>the</strong>less, discussion about SQL injection countermeasures is frequently misleading,<br />

and many people rely on defensive measures that are only partially effective.<br />

Partially Effective Measures<br />

Because of <strong>the</strong> prominence of <strong>the</strong> single quotation mark in <strong>the</strong> standard explanations<br />

of SQL injection flaws, a common approach to preventing attacks is to<br />

escape any single quotation marks within user input by doubling <strong>the</strong>m. You<br />

have already seen two situations in which this approach fails:<br />

n If numeric user-supplied data is being embedded into SQL queries, this<br />

is not usually encapsulated within single quotation marks. Hence, an

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

Saved successfully!

Ooh no, something went wrong!