SQL Injection Attacks.

Slides:



Advertisements
Similar presentations
Understand Database Security Concepts
Advertisements

Introduction The concept of “SQL Injection”
Structured Query Language - SQL Carol Wolf Computer Science.
SQL Injection Attacks Prof. Jim Whitehead CMPS 183: Spring 2006 May 17, 2006.
1. What is SQL Injection 2. Different varieties of SQL Injection 3. How to prevent it.
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
MIS2502: Data Analytics MySQL and SQL Workbench David Schuff
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
SQL Injection Attacks CS 183 : Hypermedia and the Web UC Santa Cruz.
+ Housekeeping Project/assignment 6/quiz 6 questions? Quiz 6: Query optimization, database security At 9:10, you’ll have 15 minutes to do on- line student.
EC500 Lecture Made By: Jiaxi Jin, Rashmi Shah, Ludovico Fontana Boston University.
Preventing SQL Injection ~example of SQL injection $user = $_POST[‘user’]; $pass = $_POST[‘pass’]; $query = DELETE FROM Users WHERE user = ‘$user’ AND.
Check That Input Preventing SQL Injection Attacks By Andrew Morton For CS 410.
MIS Week 11 Site:
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Lets Make our Web Applications Secure. Dipankar Sinha Project Manager Infrastructure and Hosting.
(CPSC620) Sanjay Tibile Vinay Deore. Agenda  Database and SQL  What is SQL Injection?  Types  Example of attack  Prevention  References.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 5 “Database and Cloud Security”.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Attacking Applications: SQL Injection & Buffer Overflows.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Copyright © 2013 Curt Hill Database Security An Overview with some SQL.
 Chapter 14 – Security Engineering 1 Chapter 12 Dependability and Security Specification 1.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.
Analysis of SQL injection prevention using a filtering proxy server By: David Rowe Supervisor: Barry Irwin.
CRUD Matrix Presented by Trisha Cummings. Background to a CRUD Matrix CRUD stands for :- Create, Read, Update and Delete. A CRUD Matrix is very useful.
SQL Injection Jason Dunn. SQL Overview Structured Query Language For use with Databases Purpose is to retrieve information Main Statements Select Insert.
ASP.NET More on searching databases 1ASP.NET, More on searching databases.
Sumanth M Ganesh B CPSC 620.  SQL Injection attacks allow a malicious individual to execute arbitrary SQL code on your server  The attack could involve.
SQL – Injections Intro. Prajen Bhadel College of Information Technology & Engeneering Kathmandu tinkune Sixth semister.
Security Considerations Steve Perry
Form Handling IDIA 618 Fall 2014 Bridget M. Blodgett.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
Security Issues With Web Based Systems. Security Issues Web Based Systems  Security can not be considered an add-on or afterthought  Security must be.
Secure Authentication. SQL Injection Many web developers are unaware of how SQL queries can be tampered with SQL queries are able to circumvent access.
Example – SQL Injection MySQL & PHP code: // The next instruction prompts the user is to supply an ID $personID = getIDstringFromUser(); $sqlQuery = "SELECT.
SQL Injection Attacks An overview by Sameer Siddiqui.
MYSQL AND MYSQL WORKBENCH MIS2502 Data Analytics.
ADVANCED SQL.  The SQL ORDER BY Keyword  The ORDER BY keyword is used to sort the result-set by one or more columns.  The ORDER BY keyword sorts the.
Programming for the Web MySQL Command Line Using PHP with MySQL Dónal Mulligan BSc MA
SQL Injection By: Ayman Mohamed Abdel Rahim Ali Ehab Mohamed Hassan Ibrahim Bahaa Eldin Mohamed Abdel Sabour Tamer Mohamed Kamal Eldin Jihad Ahmad Adel.
M M Waseem Iqbal.  Cause: Unverified/unsanitized user input  Effect: the application runs unintended SQL code.  Attack is particularly effective if.
SQL INJECTION Diwakar Kumar Dinkar M.Tech, CS&E Roll Diwakar Kumar Dinkar M.Tech, CS&E Roll
Cosc 5/4765 Database security. Database Databases have moved from internal use only to externally accessible. –Organizations store vast quantities of.
Database and Cloud Security
Database System Implementation CSE 507
Chapter 5 Introduction to SQL.
Homework 1 Hints.
Invoicing: Enter a PO-Based Invoice
SQL Injection.
ATS Application Programming: Java Programming
Database application MySQL Database and PhpMyAdmin
mysql and mysql workbench
Pengantar Keamanan Informasi
MIS Professor Sandvig MIS 324 Professor Sandvig
Intro to Ethical Hacking
SQL with PHP and SQL Injection Attacks.
How to Modify a Requisition Using Owl Link
PHP-language, database-programming
ISC440: Web Programming 2 Server-side Scripting PHP 3
PHP: Security issues FdSc Module 109 Server side scripting and
Chapter 13 Security Methods Part 3.
Lecture 2 - SQL Injection
MIS2502: Data Analytics MySQL and SQL Workbench
Chapter 7 Using SQL in Applications
Intro to Ethical Hacking
Security: Attacks & Countermeasures
Presentation transcript:

SQL Injection Attacks

What is a SQL Injection Attack? Many web applications take user input from a form Often this user input is used literally in the construction of a SQL query submitted to a database. For example: SELECT productdata FROM table WHERE productname = ‘user input product name’; A SQL injection attack involves placing SQL statements in the user input

An Example SQL Injection Attack Product Search: Creates the following SQL: SELECT prodinfo FROM prodtable WHERE prodname = ‘blah‘ OR ‘x’ = ‘x’ Attacker has now successfully caused the entire database to be returned. blah‘ OR ‘x’ = ‘x

A More Malicious Example What if the attacker had instead entered: blah‘; DROP TABLE prodinfo; -- Results in the following SQL: SELECT prodinfo FROM prodtable WHERE prodname = ‘blah’; DROP TABLE prodinfo; --’ Note how comment (--) consumes the final quote Causes the entire database to be deleted Depends on knowledge of table name This is sometimes exposed to the user in debug code called during a database error Use non-obvious table names, and never expose them to user Usually data destruction is not your worst fear, as there is low economic motivation

Other injection possibilities Using SQL injections, attackers can: Add new data to the database Could be embarrassing to find yourself selling politically incorrect items on an eCommerce site Perform an INSERT in the injected SQL Modify data currently in the database Could be very costly to have an expensive item suddenly be deeply ‘discounted’ Perform an UPDATE in the injected SQL

Defenses Use provided functions for escaping strings Many attacks can be thwarted by only allowing the SQL string escaping inputs for quotes and semicolons ‘  \’ and “  \” mysql_real_escape_string() is the preferred function for this Not a silver bullet! Consider: SELECT fields FROM table WHERE id = 23 OR 1=1 No quotes here!

More Defenses Check syntax of input for validity Many classes of input have fixed languages Email addresses, dates, part numbers, etc. Verify that the input is a valid string in the language Sometime languages allow problematic characters (e.g., ‘*’ in email addresses); may decide to not allow these If you can exclude quotes and semicolons that’s good Not always possible: consider the name Bill O’Reilly Want to allow the use of single quotes in names Have length limits on input Many SQL injection attacks depend on entering long strings

Even More Defenses Scan query string for undesirable word combinations that indicate SQL statements INSERT, DROP, etc. If you see these, can check against SQL syntax to see if they represent a statement or valid user input Limit database permissions and segregate users If you’re only reading the database, connect to database as a user that only has read permissions Never connect as a database administrator in your web application

More Defenses Configure database error reporting Default error reporting often gives away information that is valuable for attackers (table name, field name, etc.) Configure so that this information is never exposed to a user