EC500 Lecture Made By: Jiaxi Jin, Rashmi Shah, Ludovico Fontana Boston University.

Slides:



Advertisements
Similar presentations
Module XIV SQL Injection
Advertisements

Introduction The concept of “SQL Injection”
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.
SQL Injection and Buffer overflow
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Dec 13 th CS555 presentation1 Yiwen Wang --“Securing the DB may be the single biggest action an organization can take to protect its assets” David C. Knox.
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.
Check That Input Preventing SQL Injection Attacks By Andrew Morton For CS 410.
SQL Injection Timmothy Boyd CSE 7330.
MIS Week 11 Site:
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
Analysis of SQL injection prevention using a proxy server By: David Rowe Supervisor: Barry Irwin.
SQL INJECTION COUNTERMEASURES &
Hamdi Yesilyurt, MA Student in MSDF & PhD-Public Affaris SQL Riji Jacob MS Student in Computer Science.
(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.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
Introduction to SQL Steve Perry
Introduction to databases and SQL. What is a database?  A database is an organized way of holding together pieces of information  A database refers.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.
SQL Injection Jason Dunn. SQL Overview Structured Query Language For use with Databases Purpose is to retrieve information Main Statements Select Insert.
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.
Aniket Joshi Justin Thomas. Agenda Introduction to SQL Injection SQL Injection Attack SQL Injection Prevention Summary.
By Sean Rose and Erik Hazzard.  SQL Injection is a technique that exploits security weaknesses of the database layer of an application in order to gain.
SQL – Injections Intro. Prajen Bhadel College of Information Technology & Engeneering Kathmandu tinkune Sixth semister.
Security Considerations Steve Perry
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
WEB SECURITY WEEK 2 Computer Security Group University of Texas at Dallas.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
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.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
SQL Injection Attacks An overview by Sameer Siddiqui.
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.
SQL Basics Review Reviewing what we’ve learned so far…….
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
SQL Injection Attacks S Vinay Kumar, 07012D0506. Outline SQL Injection ? Classification of Attacks Attack Techniques Prevention Techniques Conclusion.
Introduction to Database Programming with Python Gary Stewart
Introduction SQL Injection is a very old security attack. It first came into existence in the early 1990's ex: ”Hackers” movie hero does SQL Injection.
SQL INJECTION Diwakar Kumar Dinkar M.Tech, CS&E Roll Diwakar Kumar Dinkar M.Tech, CS&E Roll
SQL Injection Attacks.
Database System Implementation CSE 507
Group 18: Chris Hood Brett Poche
Web Systems & Technologies
SQL INJECTION ATTACKS.
Pengantar Keamanan Informasi
Computer Security Fundamentals
MIS Professor Sandvig MIS 324 Professor Sandvig
ISC440: Web Programming 2 Server-side Scripting PHP 3
Defense in Depth Web Server Custom HTTP Handler Input Validation
PHP: Security issues FdSc Module 109 Server side scripting and
Structured Query Language
Lecture 2 - SQL Injection
Structured Query Language
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

EC500 Lecture Made By: Jiaxi Jin, Rashmi Shah, Ludovico Fontana Boston University

 SQL Background  SQL Syntax  What is SQL Injection? (What?)  What kind of information can we get from it? (why?)  Real world examples  How does it work (How?)  SQL Injection Types  Scripts - Tools  Detection Techniques  Prevention Techniques  Prevention Techniques

 SQL stands for Structured Query Language  a programming language designed for managing data in relational database management systems (RDBMS).  Allows us to define and manipulate data in a database.  Used for relational databases.  ANSI and ISO standard computer language Although the standards have been enhanced several times, SQL portability between major RDBMs differ on implementation.

 There are many different versions of the SQL language  They support the same major keywords in a similar manner (such as SELECT, UPDATE, DELETE, INSERT, WHERE, and others).  Most of the SQL database programs also have their own proprietary extensions in addition to the SQL standard!

A database contains one or more tables Each table is identified by a name. E.g. customers, orders Table contains records (rows) with data Example of a table contains “customers” and passwords: userfirst_namelast_namepassword johnsjohnsmith e99a18ac428cb38d5 administratoradmin f e034 Ken_87kenandersonfg9a76518ac428cb3

SELECT UPDATE DELETE INSERT INTO UNION

SELECT first_name, last_name FROM users Users: Result: usernamefirst_namelast_namepassword johnsjohnsmith e99a18ac428cb38d 5 administrat or admin f e034 Ken_87kenandersonfg9a76518ac428cb3 first_namelast_name johnsmith admin kenanderson

SELECT * FROM users WHERE username = ‘johns’ Users: Result: usernamefirst_namelast_namepassword johnsjohnsmith e99a18ac428cb38d 5 administrat or admin f e034 Ken_87kenandersonfg9a76518ac428cb3 usernamefirst_namelast_namepassword johnsjohnsmith e99a18ac428cb38d 5

Insert INTO orders VALUES (3, 67, ‘Kindle Touch’, 99) orders: Result: Order_idProduct_idProduct_nameprice 134Back to basics: Java Biography: Steve Jobs15 Order_idProduct_idProduct_nameprice 134Back to basics: Java Biography: Steve Jobs15 367Kindle Touch99

Update users SET first_name = Kenneth, last_name = Lee WHERE user_id = 3 Users: Result: User_idusernamefirst_namelast_namepassword 1johnsjohnsmith e99a18ac428cb38d5 2administratoradmin f e034 3Ken_87kenAndersonfg9a76518ac428cb3 User_idusernamefirst_namelast_namepassword 1johnsjohnsmith e99a18ac428cb38d5 2administratoradmin f e034 3Ken_87KennethLeefg9a76518ac428cb3

DELETE FROM users WHERE user_id = 1 Users: Result: User_idusernamefirst_namelast_namepassword 1johnsjohnsmith e99a18ac428cb38d5 2administratoradmin f e034 3Ken_87kenAndersonfg9a76518ac428cb3 User_idusernamefirst_namelast_namepassword 2administratoradmin f e034 3Ken_87KennethLeefg9a76518ac428cb3

SELECT first_name, last_name FROM users WHERE user_id = 1 UNION SELECT product_name, price FROM orders WHERE user_id = 1

Users: Orders: Result: User_idusernamefirst_namelast_name 1johnsjohnsmith 2administratoradmin 3Ken_87kenAnderson First_namelast_name johnsmith Back to basics: Java 50 Order_iduser_idProduct_nameprice 11Back to basics: Java 50 22Biography: Steve Jobs15 Maintains header from first query but appends results from the second query.

COMMENTS: # or -- Example: SELECT * FROM ‘table’ #selects everything LOGIC: ‘a’=‘a’ Example: SELECT * FROM ‘table’ WHERE ‘a’=‘a’ MULTI STATEMENTS: S1; S2 Example: SELECT * FROM ‘table’; DROP TABLE ‘table’;

 Code Injection Technique  placing SQL codes in the user input  Exploits Security Vulnerability  Website/server 's software is not safe  Targets User Input Handlers  Incorrect type handling: supplied field is not strongly typed / not checked for type constraints

 We can execute queries against a database to:  retrieve data from a database  update records in a database  delete records from a database  insert new records in a database  Attacker can then do through SQL Injection:  Reveal others' usernames and/or passwords  Collect personal/corporate information (credit card, etc.)  Change/Delete information (sabotage)  Gain access to the host  Plant data/code  Create backdoors

Product Search: blah‘ OR ‘x’ = ‘x  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.

 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

 On August 17, 2009, the United States Justice Department charged an American citizen Albert Gonzalez and two unnamed Russians with the theft of 130 million credit card numbers using an SQL injection attack.  In 2008 a sweep of attacks began exploiting the SQL injection vulnerabilities of Microsoft's IIS web server and SQL database server. Over 500,000 sites were exploited.  More examples available at: world_examples

First Order Attack First Order Attack o The attacker can simply enter a malicious string and cause the modified code to be executed immediately. o Blind Attack  When the attacker can't receive feedback of his actions. o Error Based Attack  When the attacker gets information through the database error messages. Ref: Oracle Learning Library - Defending Against SQL Injection Attacks

Second Order Attack Second Order Attack o The attacker injects into persistent storage (such as a table row) which is deemed as a trusted source. An attack is subsequently executed by another activity. o The attacker creates functions for later use. o The attacker creates functions that will execute when a timer goes off. Ref: Oracle Learning Library - Defending Against SQL Injection Attacks

SQLMap SQLMap o Open source penetration testing tool, detecting and exploiting SQL injection flaws. SQLBrute SQLBrute o Brute forcing data out of databases using blind SQL injection vulnerabilities. Time based and error based exploit, written in Python. SQLNinja SQLNinja o Specifically targeted to Microsoft SQL Server. BSQL Hacker BSQL Hacker o Automatic deep blind time-based SQL injector. Mini Mysqlat0r Mini Mysqlat0r o Written in Java.

 SQL String Escaping  Many attacks can be thwarted by simply using the SQL string escaping mechanism  ‘ becomes \’ and “ becomes \”  mysql_real_escape_string() is a function that does that for you.

 Input Validation  Many classes of input have fixed formats.  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  Exclude quotes and semicolons.  Not always possible: consider the name Shaq O’Neal  Want to allow the use of single quotes in names  Use of Prepared statements (Parametrized Queries)  A function to tell the DBMS which part is fixed and which part is an user input. That way commands from the input are ignore.

 READ ONLY  READ ONLY database access.  Configure different users in the DBMS. SERVER SIDE.  Always enforce the strongest constraint at: SERVER SIDE.  Never trust any input from clients  Always Remember: IT IS NOT SAFE OUT THERE!!!

THANK YOU

 Oracle Learning Library: curriculum.oracle.com/tutorial/SQLInjection/html/le sson1/les01_tm_attacks.htmhttp://st- curriculum.oracle.com/tutorial/SQLInjection/html/le sson1/les01_tm_attacks.htm  SecuriTeam - SQL Injection Walkthrough : 1P76E.html  Friedl, S. (2009, 10 26). SQL Injection Attacks by Example.  OWASP - SQL Injection: (

 SQL Manipulation  Modify the original SQL query by including additional queries  Inclusion of conditional statement in where clause  “Select * from Table where Username=’ ‘ and password=’ ‘”  “Select * from Table where Username=’ ‘or ‘c’=’c’ -- and password=’ ‘”  Use UNION, INTERSECT  Select * from projects where projecttype=’ ‘  Select * from project where projecttype=’ ‘ UNION Select * from school

 Code Injection  Insert new SQL commands into the original SQL query  Select * from users where username=’ ‘can be modified to  Select * from users where username =’ ‘; drop table faculty

 Incorrect Queries  By inserting logical errors into the query, attackers get hold of the error information  The error information often reveal names of the tables and columns that caused the error  ”Microsoft OLE DB Provider for SQL Server (0x80040E07) Error converting nvarchar value ’CreditCards’ to a column of data type int.”

 Function Call Injection  An attacker can inject different database and operating system functions in a SQL statement  “Select * from Table where Username=’ ‘ and password=’ ‘” can be modified to  “Select * from Table where Username=’ ‘shutdown with nowait; -- and password=’ ‘”  SHUTDOWN WITH NO WAIT causes SQL server to shut down, stopping Windows Service