University of Illinois at Chicago

Slides:



Advertisements
Similar presentations
Sania: Syntactic and Semantic Analysis for Automated Testing against SQL Injection Yuji Kosuga, Kenji Kono, Miyuki Hanaoka Keio University Miho Hishiyama,
Advertisements

The Essence of Command Injection Attacks in Web Applications Zhendong Su and Gary Wassermann Present by Alon Kremer April 2011.
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.
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
ReferencesReferences DiscussionDiscussion Vulnerability Example: SQL injection Auditing Tool for Eclipse LAPSE: a Security Auditing Tool for Eclipse IntroductionIntroductionResultsResults.
Leveraging User Interactions for In-Depth Testing of Web Applications Sean McAllister, Engin Kirda, and Christopher Kruegel RAID ’08 1 Seoyeon Kang November.
SQL Injection and Buffer overflow
Sara SartoliAkbar Siami Namin NSF-SFS workshop July 14-18, 2014.
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.
Check That Input Preventing SQL Injection Attacks By Andrew Morton For CS 410.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Secure Software Engineering: Input Vulnerabilities
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
Analysis of SQL injection prevention using a proxy server By: David Rowe Supervisor: Barry Irwin.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
Preventing SQL Injection Attacks in Stored Procedures Alex Hertz Chris Daiello CAP6135Dr. Cliff Zou University of Central Florida March 19, 2009.
AMNESIA: Analysis and Monitoring for NEutralizing SQL- Injection Attacks Published by Wiliam Halfond and Alessandro Orso Presented by El Shibani Omar CS691.
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 5 “Database and Cloud Security”.
Lecture 16 Page 1 CS 236 Online SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages.
XSS-GUARD : Precise Dynamic Prevention of Cross Site Scripting (XSS) Attacks Prithvi Bisht ( Joint work with : V.N. Venkatakrishnan.
CSC-682 Cryptography & Computer Security Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Pompi Rotaru Based on an article.
Analysis of SQL injection prevention using a proxy server By: David Rowe Supervisor: Barry Irwin.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
CANDID : Preventing SQL Injection Attacks Using Dynamic Candidate Evaluations V. N. Venkatakrishnan Assistant Professor, Computer Science University of.
Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflows can be triggered by inputs that are designed to execute code, or alter the way the program.
C ANDID : P REVENTING SQL I NJECTION A TTACKS U SING D YNAMIC C ANDIDATE E VALUATIONS Presented by Jeong-hoon, Park 1.
Aniket Joshi Justin Thomas. Agenda Introduction to SQL Injection SQL Injection Attack SQL Injection Prevention Summary.
Building Secure Web Applications With ASP.Net MVC.
WEB SECURITY WEEK 2 Computer Security Group University of Texas at Dallas.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflow Analysis of Buffer Overflow Attacks.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
CSC 2720 Building Web Applications Accessing MySQL from PHP.
Module: Software Engineering of Web Applications Chapter 3 (Cont.): user-input-validation testing of web applications 1.
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.
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 Wenonah Abadilla. Topics What is SQL What is SQL Injection Damn Vulnerable Web App SQLI Demo Prepared Statements.
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.
Web Security (cont.) 1. Referral issues r HTTP referer (originally referrer) – HTTP header that designates calling resource  Page on which a link is.
SQL Injection By Wenonah Abadilla.
Database and Cloud Security
Database System Implementation CSE 507
Module: Software Engineering of Web Applications
Module: Software Engineering of Web Applications
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
SQL Injection.
SQL INJECTION ATTACKS.
SQL Injection Attacks Many web servers have backing databases
Secure Software Development: Theory and Practice
Un</br>able’s MySecretSecrets
PHP: Security issues FdSc Module 109 Server side scripting and
Teaching slides Chapter 8.
University of Illinois at Chicago
University of Illinois at Chicago
Chapter 13 Security Methods Part 3.
Lecture 2 - SQL Injection
Web Hacking: Beginners
Web Security CS 136 Computer Security Peter Reiher March 11, 2010
SQL Injection Attacks John Sweetnam
CS5123 Software Validation and Quality Assurance
Exploring DOM-Based Cross Site Attacks
SQL Injection Attack.
Presentation transcript:

University of Illinois at Chicago CANDID : Preventing SQL Injection Attacks Using Dynamic Candidate Evaluations V. N. Venkatakrishnan Assistant Professor, Computer Science University of Illinois at Chicago Joint work with: Sruthi Bandhakavi (UIUC) Prithvi Bisht (UIC) and P. Madhusudan (UIUC)

SQL Injection : Typical Query SELECT * FROM phonebook WHERE username = ‘John’ AND password = ‘open_sesame’ Phonebook Record Manager John open_sesame Username Password Submit Delete Display John’s phonebook entries are displayed Application Server SQL injection are attacks on web applications launched through specifically crafted user inputs. Lets first see how an SQL injection attack looks like. The user types in his input in a form in a web browser, which sends it over to an application server. The application server inserts the user data into a query and sends it over to a database. The database returns the results for the query, which in turn are displayed to the user in a web page. This slide shows an example of a simple phone book manager, where the application returns the phonebook entries of a particular user, given the username and the appropriate password. Web browser User Input Query Database Web Page Result Set

SQL Injection : Typical Query SELECT * FROM phonebook WHERE username = ‘John’ OR 1=1 --AND password = ‘not needed’ Phonebook Record Manager John’ OR 1=1 -- not needed Username Password Submit Delete Display All phonebook entries are displayed Application Server SQL injection are attacks on web applications launched through specifically crafted user inputs. Lets first see how an SQL injection attack looks like. The user types in his input in a form in a web browser, which sends it over to an application server. The application server inserts the user data into a query and sends it over to a database. The database returns the results for the query, which in turn are displayed to the user in a web page. This slide shows an example of a simple phone book manager, where the application returns the phonebook entries of a particular user, given the username and the appropriate password. Web browser User Input Query Database Web Page Result Set

SQL Injection Attacks are a Serious Threat XSS XSS SQL Injection Recent vulnerability statistics show that the percentage of SQL injection attacks discovered increased drastically. This drastic increase can be attributed to the fact that the attacks are easy to engineer and the deployment of firewalls and other perimeter defenses can be defeated easily by simple script injection attacks. The CardSystems security breach where 263 thousand customer credit card numbers were stolen illustrates how serious the threat could be. CVE Vulnerabilities (2006) CVE Vulnerabilities (2004) CardSystems security breach(2006): 263,000 customer credit card numbers stolen, 40 Million more exposed

Talk Overview [ACM CCS’07] CANDID Program Safe Web Transformer Web Application Web Application [ACM CCS’07]

SQL Injection Most systems separate code from data SQL queries can be constructed by arbitrary sequences of programming constructs that involve string operations Concatenation, substring …. Such construct also involve (untrusted) user inputs Inputs should be mere “data”, but in case of SQL results in “code” Result: Queries intended by the programmer can be “changed” by untrusted user input

Parse Structure for a Benign Query <sql_query> <where_clause> <cond_term> <cond_term> <cond> <cond> Select * from Table Conditions have two parts, joined by AND. <id> <lit> <lit> <id> WHERE username = ‘John’ AND password = ‘os’

Parse Structure for a Attack Query <sql_query> <where_clause> <comment> <cond_term> <cond_term> <cond> Select * from Table <cond> <id> <lit> Query structure changes. <lit> <lit> WHERE username = ‘John’ OR 1=1 -- AND …

Attacks Change Query Structure Boyd et. al [BK 04], ANCS ; Buehrer et. al. [BWS 05], SEM; Halfond et. al.[HO 05], ASE; Nguyen-Tuong et. al. [NGGSE 05], SEC; Pietraszek et. al[PB 05], RAID; Valeur et. al. [VMV 05], DIMVA; Su et. al. [SW 06], POPL ... <sql_query> <sql_query> <where_clause> <comment> <where_clause> <cond_term> <cond_term> <cond_term> <cond_term> <cond> <cond> <cond> <cond> <literal> <id> Colour change Leave with a strong stmt: Therefore, there has been a lot of research in this area to counter this problem. One important observation made by the previous researchers is that the structure of the malicious query is different from that of the benign query. The programmer, when writing the program has an idea about how the query’s structure should be for benign inputs. If we can find the programmer intended query structure, we can compare it with the query produced by the user input and find out if it is benign or not. <id> <lit> <lit> <lit> <id> <lit> WHERE username = ‘John’ OR 1=1 --’ AND ... WHERE username = ‘John’ AND password = ‘os’ Benign Query Attack Query

<where_clause> WHERE username = ‘?’ AND password = ‘?’ Prepared Statements <lit> <sql_query> <where_clause> <cond_term> <cond> <id> WHERE username = ‘?’ AND password = ‘?’ mysql> PREPARE stmt_name FROM " SELECT * FROM phonebook WHERE username = ? AND password = ?” placeholder for input Separates query structure from data Statements are NOT parsed for every user input Allow programmer to declare and finalize the structure of every query

Legacy Applications For existing applications adding PREPARE statements will prevent SQL injection attacks Hard to do automatically with static techniques Need to guess the structure of query at each query issue location Query issued at a location depends on path taken in program Human assisted efforts can add PREPARE statements Costly effort Problem: Is it possible to dynamically infer the benign query structure?

How can we guess benign candidate inputs for every execuction? High level idea : Dynamic Candidate Evaluations Create benign sample inputs (Candidate Inputs) for every user input Execute the program simultaneously over actual inputs and candidate inputs Generate a candidate query along with the actual query The candidate query is always non-attacking Actual query is possibly malicious Issue the actual query only if parse structures match Similarly, even in the case of benign inputs, benign candidate inputs are produced for each input variable. In this case, however, the query structures would match and the user query is sent to the database. . Actual I/P Actual Query Match Application SQL Parser DB Candidate I/P No Match Candidate Query How can we guess benign candidate inputs for every execuction?

Finding Benign Candidate Inputs Have to create a set of candidate inputs which Are Benign Issue a query at the same query issue location By following the same path in the program Candidate Path Actual Path Finding the benign candidate inputs, however, is not so straightforward. This is because the benign candidate inputs may follow a different path from the real path. This is possible in the case where the value of a conditional in the path of the program depends on the input. Therefore, we not only have to take care that the candidate inputs are benign, but also make sure that those inputs follow the same path as the real inputs. Finding the benign inputs which take the same path as the real inputs is difficult. Instead, we force the candidate inputs to follow the same path as the real inputs. We do this by executing the conditional only on the real inputs and forcing the candidate inputs to follow the same path as that of the reals. Problem: Hard In the most general case it is undecidable Query Issue Location

Our Solution : Use Manifestly benign inputs For every string create a sample string of ‘a’ s having the same length Candidate Input: uname = ‘aaaa’ pwd = ‘aa’ Shadow every intermediate string variable that depends on input For integer or boolean variable, use the originals Follow the original control flow Phonebook Record Manager John os User Name Password Submit Delete Display

Evaluate conditionals only on actual inputs Candidate Input : uname = “aaaa” pwd = “aa” display = true input str uname, str pwd, bool display User Input : uname = “john” pwd = “os” display = false Candidate Input : uname = “aaaa” pwd = “aa” true false display? query = ‘SELECT * from phonebook WHERE username = ‘ + uname + ’ AND password = ’ + pwd +’ Now assume that the delete button is selected making the real value of the delete variable true. The candidate input can be either true or false. Let’s assume that it is false, then the real and candidate inputs will take different paths and result in different queries. To avoid that, we force the candidate inputs to follow the same path as the real inputs by executing the conditional only on the real inputs and forcing the candidate inputs to take the same path. In this example, both the candidate and the real inputs form the DELETE query in the end. Forcing the candidate inputs to follow the real path may seem ad hoc, but it has a sound theoretical basis. query = ‘DELETE * from phonebook WHERE username = ‘ + uname + ’ AND password = ’ + pwd +’ Actual Query: DELETE * from phonebook WHERE username = ‘john’ AND password = ’ os’ Candidate Query: DELETE * from phonebook WHERE username = ‘aaaa’ AND password = ’aa’

CANDID Program Transformation Example i/p str uname; i/p str pwd; i/p bool delete; str uname_c; str pwd_c; uname = input_1, pwd = input_2, delete = input_3; uname_c = createSample(uname) , pwd_c = createSample(pwd); false true display? query = DELETE * from phonebook WHERE username = ‘ + uname + ’ AND password = ’ + pwd +’ query_c = DELETE * from phonebook WHERE username = ‘ + uname_c + ’ AND password = ’ + pwd_c +’; query = DELETE * from phonebook WHERE username = ‘ + uname + ’ AND password = ’ + pwd +’ Only strings are transformed Benign inputs are the same size as user input Method call duplicatedls query = SELECT * from phonebook WHERE username = ‘ + uname + ’ AND password = ’ + pwd +’ ; query = SELECT * from phonebook WHERE username = ‘ + uname + ’ AND password = ’ + pwd +’ ; query_c = SELECT * from phonebook WHERE username = ‘ + uname_c + ’ AND password = ’ + pwd_c +’; if(match_queries(query,query_c) == true) execute_query(query) execute_query(query)

Resilience of CANDID Input Splitting “Alan Turing” “aaaaaaaaaaa” Input space_index = 4 Instrumented Input Splitting Function Input Splitting Function space_index = 4 fn = input[0..3] = “Alan” fn_c = input_c[0..3] = “aaaa” ln = input[5..9] = “Turing” ln_c = input_c[5..9] = “aaaaaa” Although the CANDID transformation is very simple, it is resilient to various scenarios, two of which I will discuss in the next two slides. In the first scenario, using an example we demonstrate that the candid approach is resilient to the input splitting functions that may be used by the application program before the input is sent to the query. If the application has a filter function which splits the name into first and last names, the CANDID transformation would transform the function to also split the candidate inputs into two strings having the same length as the first and last names. Query SELECT ... WHERE first_name = “Alan” AND last_name = “Turing” SELECT ... WHERE first_name = “aaaa” AND last_name = “aaaaaa”

CANDID Implementation Architecture Offline View Online View java bytecode Java Bytecode transformer Instrumented Web Application Original Program Tomcat server Web Server SQL Parse Tree Checker The CANDID architecture consists of two views. In the offline view the application programs are transformed according to the CANDID transformation we have just seen. In the online view, the transformed application is deployed on the web server, where it dynamically detects and prevents the SQL injection attacks. The details of our implementation are in the paper. java DB Instrumented Web Application MySql Browser java bytecode

Acknowledgments: xkcd.com Thank You Questions? Acknowledgments: xkcd.com