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.

456 Chapter 10 • References<br />

Solutions Fast Track<br />

Structured Query Language (<strong>SQL</strong>) Primer<br />

˛˛ <strong>SQL</strong> comprises a feature-rich set of statements, operators, <strong>and</strong> clauses designed to<br />

interact with a database server. The most common <strong>SQL</strong> statements are SELECT,<br />

INSERT, UPDATE, DELETE, <strong>and</strong> DROP. The majority of <strong>SQL</strong> injection<br />

vulnerabilities occur when user-supplied data is included with the WHERE clause<br />

portion of a SELECT statement.<br />

˛˛<br />

˛˛<br />

The UPDATE <strong>and</strong> DELETE statements rely on a WHERE clause to determine<br />

which records are modified or deleted. When injecting <strong>SQL</strong> into either an<br />

UPDATE or a DELETE statement it is important to underst<strong>and</strong> how your input<br />

could affect the database. Avoid injecting OR 1=1 or any other condition that<br />

returns true into either of these statements.<br />

The UNION operator is used to combine the results of two or more SELECT<br />

statements. UNION SELECT is frequently used to exploit <strong>SQL</strong> injection<br />

vulnerabilities.<br />

<strong>SQL</strong> <strong>Injection</strong> Quick Reference<br />

˛˛ Identifying the database platform is an important step when attempting to exploit<br />

an <strong>SQL</strong> injection vulnerability. Triggering a measurable time delay is a reliable<br />

method of accurately identifying the database platform.<br />

˛˛ When exploiting <strong>SQL</strong> injection vulnerabilities you are often restricted to returning<br />

one column from one row at a time. You can overcome this restriction by<br />

concatenating the results from multiple columns <strong>and</strong> rows into a single string.<br />

Bypassing Input Validation Filters<br />

˛˛ You often can circumvent input validation filters that are designed to h<strong>and</strong>le the<br />

single-quote character (‘) by representing string values using character functions.<br />

For example, char(65,66,67) is equivalent to ‘ABC’ on Microsoft <strong>SQL</strong> Server.<br />

˛˛ HTTP encoding variants such as Unicode <strong>and</strong> Overlong UTF-8 can sometimes be<br />

used to bypass input validation filters.<br />

˛˛ Input validation filters that rely on rejecting known bad data, often referred to as<br />

blacklisting, are frequently flawed.

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

Saved successfully!

Ooh no, something went wrong!