Aniket Joshi Justin Thomas

Post on 21-Feb-2016

37 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Aniket Joshi Justin Thomas. Agenda. Introduction to SQL Injection SQL Injection Attack SQL Injection Prevention Summary. What is SQL Injection?. It is a kind of web application attack where user supplied input coming from: URL : www.abc.com?id=1 Login forms: username=John Doe - PowerPoint PPT Presentation

Transcript

Aniket JoshiJustin Thomas

Agenda

• Introduction to SQL Injection

•SQL Injection Attack

•SQL Injection Prevention

•Summary

What is SQL Injection?

• It is a kind of web application attack where user supplied input coming from:

• URL: www.abc.com?id=1• Login forms: username=John Doe• Other elements such as cookie, HTTP headers

is manipulated so that vulnerable application executes SQL commands injected by attacker.

Methods of Injection

• Injection into source code of website

• Injection into the URL

SQL Injection cont.…•The injection process works by prematurely

terminating a text string and appending a new command.

•Because the inserted command may have additional strings appended to it before it is executed, the attacker terminates the injected string with a comment mark "--".

•Subsequent text is ignored at execution time.

Example:Statement=“SELECT * FROM users WHERE uname=‘ ”+username+” ’;”

username=‘ or ‘1’=‘1’- -’

SELECT * FROM users WHERE uname=‘ ‘ OR ‘1’=‘1’ - -’;

How to Defend?

How to avoid SQL Injection

•As long as injected SQL code is syntactically correct, tampering cannot be detected programmatically.

•Therefore, you must validate all user input and carefully review code that executes constructed SQL commands in the server that you are using.

Some tips:

•Filter and validate all input data

•Separating code from data by making use of prepared and stored procedures

•Making use of escape characters

1. Filter out character like single quote, double quote, slash, back slash, semi colon, extended character like NULL, carry return, new line

a. input from usersb. parameters from URLc. values from cookies

2. Convert all numeric values into integer before parsing into SQL statement.

Summary• Considered top 10 web application

vulnerabilities of 2007 and 2010 by the Open Web Application Security Project

•SQLIA’s has ▫Many sources▫Many Goals▫Many Types

•Prevention should not be developer dependent

Thank You

top related