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.

Contents<br />

Chapter 1 What Is <strong>SQL</strong> <strong>Injection</strong>?. ................................. 1<br />

Introduction .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2<br />

Underst<strong>and</strong>ing How Web Applications Work.............................2<br />

A Simple Application Architecture. ................................4<br />

A More Complex Architecture.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5<br />

Underst<strong>and</strong>ing <strong>SQL</strong> <strong>Injection</strong>. ......................................6<br />

High-Profile Examples.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10<br />

Underst<strong>and</strong>ing How It Happens.....................................13<br />

Dynamic String Building .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13<br />

Incorrectly H<strong>and</strong>led Escape Characters...........................14<br />

Incorrectly H<strong>and</strong>led Types.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15<br />

Incorrectly H<strong>and</strong>led Query Assembly............................17<br />

Incorrectly H<strong>and</strong>led Errors. ..................................18<br />

Incorrectly H<strong>and</strong>led Multiple Submissions .. . . . . . . . . . . . . . . . . . . . . . . 19<br />

Insecure Database Configuration..................................21<br />

Summary. ....................................................24<br />

Solutions Fast Track.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24<br />

Frequently Asked Questions.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26<br />

Chapter 2 Testing for <strong>SQL</strong> <strong>Injection</strong>................................ 29<br />

Introduction .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30<br />

Finding <strong>SQL</strong> <strong>Injection</strong>............................................30<br />

Testing by Inference.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31<br />

Identifying Data Entry.......................................31<br />

GET Requests .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31<br />

POST Requests .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32<br />

Other Injectable Data .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35<br />

Manipulating Parameters .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36<br />

Information Workf low. .....................................39<br />

Database Errors .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40<br />

Commonly Displayed <strong>SQL</strong> Errors .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41<br />

Microsoft <strong>SQL</strong> Server Errors.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41<br />

My<strong>SQL</strong> Errors.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

Oracle Errors .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49<br />

ix

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

Saved successfully!

Ooh no, something went wrong!