SQL Injection Attacks An overview by Sameer Siddiqui.

Slides:



Advertisements
Similar presentations
MSc IT UFCE8K-15-M Data Management Prakash Chatterjee Room 2Q18
Advertisements

Understand Database Security Concepts
Web Pricing User Manual
SQL’s Data Definition Language (DDL) n DDL statements define, modify and remove objects from data dictionary tables maintained by the DBMS n Whenever you.
Introduction The concept of “SQL Injection”
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
NAVY Research Group Department of Computer Science Faculty of Electrical Engineering and Computer Science VŠB-TUO 17. listopadu Ostrava-Poruba.
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.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
Fundamentals, Design, and Implementation, 9/e Chapter 7 Using SQL in Applications.
SQL Injection and Buffer overflow
Introduction to Structured Query Language (SQL)
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.
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.
Chapter 6: Integrity and Security Thomas Nikl 19 October, 2004 CS157B.
Lets Make our Web Applications Secure. Dipankar Sinha Project Manager Infrastructure and Hosting.
By Daniel Siassi.  XHTML  For Structure  CSS  For Stylization of Structure  SQL Database  Store Customer, Calendar, and Order Data  PHP  Server-side.
(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 14 – Web Security SFDV3011 – Advanced Web Development 1.
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 5 “Database and Cloud Security”.
Attacking Applications: SQL Injection & Buffer Overflows.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Chapter 2. Core Defense Mechanisms. Fundamental security problem All user input is untrusted.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
(Chapter 10 continued) Our examples feature MySQL as the database engine. It's open source and free. It's fully featured. And it's platform independent.
Discovering Computers Fundamentals Fifth Edition Chapter 9 Database Management.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
1 IT420: Database Management and Organization Database Security 5 April 2006 Adina Crăiniceanu
Copyright © 2013 Curt Hill Database Security An Overview with some SQL.
Drinking Water Infrastructure Needs Survey and Assessment 2007 Website.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.
SQL Injection Introduction, Demo and Overview. What is SQL Injection? Insertion of SQL statements into application inputs to corrupt, exploit, or otherwise.
SQL Injection Jason Dunn. SQL Overview Structured Query Language For use with Databases Purpose is to retrieve information Main Statements Select Insert.
SQL INJECTIONS Presented By: Eloy Viteri. What is SQL Injection An SQL injection attack is executed when a web page allows users to enter text into a.
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
Database Security Lesson Introduction ●Understand the importance of securing data stored in databases ●Learn how the structured nature of data in databases.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
Form Handling IDIA 618 Fall 2014 Bridget M. Blodgett.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
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.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 1: Introduction to IS2803 Rob Gleasure
SQL Injection Anthony Brown March 4, 2008 IntroductionQuestionsBackgroundTechniquesPreventionDemoConclusions.
Secure Authentication. SQL Injection Many web developers are unaware of how SQL queries can be tampered with SQL queries are able to circumvent access.
By Collin Donaldson. Hacking is only legal under the following circumstances: 1.You hack (penetration test) a device/network you own. 2.You gain explicit,
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.
SQL Injection By: Ayman Mohamed Abdel Rahim Ali Ehab Mohamed Hassan Ibrahim Bahaa Eldin Mohamed Abdel Sabour Tamer Mohamed Kamal Eldin Jihad Ahmad Adel.
CS422 Principles of Database Systems Stored Procedures and Triggers Chengyu Sun California State University, Los Angeles.
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.
SQL Injection Attacks.
Database and Cloud Security
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Pengantar Keamanan Informasi
Intro to Ethical Hacking
Lecture 2 - SQL Injection
Intro to Ethical Hacking
Presentation transcript:

SQL Injection Attacks An overview by Sameer Siddiqui

Agenda What is a SQL Injection Attack? An Example SQL Injection Attack Defenses Database Practice Infrastructure Practice Short Live DEMO

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: This input is put directly into the SQL statement within the Web application: –$query = “SELECT prodinfo FROM prodtable WHERE prodname = ‘”. $_POST[‘prod_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 –Often can gain access to other user’s system capabilities by obtaining their password

Defenses Use provided functions for escaping strings –Many attacks can be thwarted by simply using the SQL string escaping mechanism ‘  \’ 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 addresses, dates, part numbers, etc. Verify that the input is a valid string in the language Sometime languages allow problematic characters (e.g., ‘*’ in 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 Never display SQL errors or other raw system errors back to the user. Can provide additional attack vectors for hackers. Whenever an exception occurs, display a generic message, and log the actual error and user input. Whenever a request fails validation or sanitation checks, use a generic response, terminate the user’s session, and log the error in detail.

Use Detailed Logs Detailed logging introduces additional storage and process overhead, but it is invaluable in debugging and in identifying security weaknesses. Unexpected conditions, rejected requests, and similar errors are usually the first sign your web application is under attack.

Database Practice Create Two accounts: –Database Owner Has rights over all the objects in a database or schema. Equivalent to DBA level access for a database/schema. Used to build out and maintain an application database. Never used by web applications. –Application Account/Database proxy account Has minimal rights needed for application: –All rights to each object are explicitly declared. –Owns no objects directly. –No access to metadata in db platform. –Restricted login locations if possible.

Database Practices-Strong Typing Columns must be strongly typed: –Numbers as Numbers. –Characters limited to the exact maximum required. –Dates stored as dates If performance is acceptable use check constraints or triggers: –Force format masks and character ranges such as 0-9 for SSN, etc. Use look up tables for reference values and enforce foreign keys.

Infrastructure Practice Use a central logging tool looking for SQL Injection behavior: –SQL Errors –Queries against metadata from web apps Use manual scanning tools such as grep, awk, and log parsers to look for unauthorized queries/sql requests

Infrastructure Practice The best security measure is one that catches problems before they are revealed. As part of QAT or UAT testing, applications must be automatically scanned for vulnerabilities. Reveals vulnerabilities above and beyond simple penetration testing. Many excellent products: –Rational APPSCAN from IBM (was Watchfire) –Acunetix –NTO Spider

References CS 183 : Hypermedia and the Web UC Santa Cruz OWASP SQLzoo.net

Be careful out there!