A Classification of SQL Injection Attack Techniques and Countermeasures



Similar documents
Detection and Prevention of SQL Injection Attacks

An analysis on Blocking of SQL Injection Attacks by Comparing Static and Dynamic Queries

How I hacked PacketStorm ( )

Web Services Based SQL Injection Detection and Prevention System for Web Applications

An Effective Approach for Detecting and Preventing Sqlinjection Attacks

Bayesian Classification for SQL Injection Detection

A Novel Approach to detect SQL injection in web applications

Intrusion Protection against SQL Injection Attacks Using a Reverse Proxy

Classification of SQL Injection Attacks Using SVM Classifier

How To Prevent An Sql Injection Attack

En efficient approaches for statistics Organization for SQL Injection Attacks Using SVM Classifier

A Simple and Fast Technique for Detection and Prevention of SQL Injection Attacks (SQLIAs)

Obfuscation-based Analysis of SQL Injection Attacks

Web Application Protection against SQL Injection Attack

Font Level Tainting: Another Approach for Preventing SQL Injection Attacks

INTRUSION PROTECTION AGAINST SQL INJECTION ATTACKS USING REVERSE PROXY

SQLAS: TOOL TO DETECT AND PREVENT ATTACKS IN PHP WEB APPLICATIONS

SQL INJECTION MONITORING SECURITY VULNERABILITIES IN WEB APPLICATIONS

Res. J. Appl. Sci. Eng. Technol., 8(5): , 2014

A Literature Review and Comparative Analyses on SQL Injection: Vulnerabilities, Attacks and their Prevention and Detection Techniques

CHAPTER 5 INTELLIGENT TECHNIQUES TO PREVENT SQL INJECTION ATTACKS

Sania: Syntactic and Semantic Analysis for Automated Testing against SQL Injection

Preventing SQL Injection through Automatic Query Sanitization with ASSIST

Toward A Taxonomy of Techniques to Detect Cross-site Scripting and SQL Injection Vulnerabilities

On Preventing SQL Injection Attacks

Classification of SQL Injection Attacks

A Tokenization and Encryption based Multi-Layer Architecture to Detect and Prevent SQL Injection Attack

Countering SQL Injection Attacks with a Database Driver 1,2

Detection of SQL Injection Attacks by Combining Static Analysis and Runtime Validation

Token Sequencing Approach to Prevent SQL Injection Attacks

Using Parse Tree Validation to Prevent SQL Injection Attacks

WEB APPLICATION VULNERABILITY DETECTION USING DYNAMIC ANALYSIS WITH PENETERATION TESTING

Protecting Database Centric Web Services against SQL/XPath Injection Attacks

A heuristic-based approach for detecting SQL-injection vulnerabilities in Web applications [Position paper]

Using Parse Tree Validation to Prevent SQL Injection Attacks

Information and Software Technology

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

AUTOMATE CRAWLER TOWARDS VULNERABILITY SCAN REPORT GENERATOR

HOD of Dept. of CSE & IT. Asst. Prof., Dept. Of CSE AIET, Lko, India. AIET, Lko, India

Approaches to detect SQL injection and XSS in web applications

EC-Council CAST CENTER FOR ADVANCED SECURITY TRAINING. CAST 619 Advanced SQLi Attacks and Countermeasures. Make The Difference CAST.

Securing Energy Metering Software with Automatic Source Code Correction

Application Design and Development

A Novel Frame Work to Detect Malicious Attacks in Web Applications

Advanced Detecting and Defensive Coding Techniques to prevent SQLIAs in Web Applications: A Survey

Securing Network Software using Static Analysis

Idea: Using System Level Testing for Revealing SQL Injection-Related Error Message Information Leaks

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

SQLProb: A Proxy-based Architecture towards Preventing SQL Injection Attacks

SQL Injection Prevention Using Runtime Query Modeling and Keyword Randomization

Address for Correspondence Department of Computer Science, Global Institute of Management and Emerging Technologies, Amritsar, Punjab, India

Criteria for web application security check. Version

Database security issues PETRA BILIĆ ALEXANDER SPARBER

Detection of DOM-based Cross-Site Scripting by Analyzing Dynamically Extracted Scripts

A Detailed Survey on Various Aspects of SQL Injection in Web Applications: Vulnerabilities, Innovative Attacks, and Remedies

Protocol Based Approach on Vulnerability Detection Tools of SQLIA along with Monitoring Tools D. Naga Swetha 1, B. Shyam Kumar 2

A Multi agent Scanner to Detect Stored XSS Vulnerabilities

AUTOMATICALLY HARDENING WEB APPLICATIONS USING PRECISE TAINTING

Design and Implementation of Open Source Web Application Security Tool

How To Prevent A Cross Site Scripting Attack On A Web Browser From Being Successful

Enterprise Application Security Workshop Series

External Network & Web Application Assessment. For The XXX Group LLC October 2012

The Top Web Application Attacks: Are you vulnerable?

METHODS FOR DETECTION AND PREVENTION OF SQL ATTACKS IN ANALYSIS OF WEB FIELD DATA

Maintaining Stored Procedures in Database Application

IJMIE Volume 2, Issue 9 ISSN:

Enhanced Model of SQL Injection Detecting and Prevention

Check list for web developers

Analysis of SQL injection prevention using a proxy server

Automated Technique for detecting and preventing SQL Injection in stored procedure

<Insert Picture Here> Oracle Web Cache 11g Overview

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Oracle Corporation

Protecting the Cloud from Inside

Data Breaches and Web Servers: The Giant Sucking Sound

SQL Injection January 23, 2013

SECURING WEB APPLICATIONS FROM APPLICATION-LEVEL ATTACK. A thesis submitted. to Kent State University in. partial fulfillment of the requirements

Learning SQL for Database Intrusion Detection using Context-sensitive Modelling

What is Web Security? Motivation

SQL Injections Attacks and Aversion Techniques

Agenda. SQL Injection Impact in the Real World Attack Scenario (1) CHAPTER 8 SQL Injection

Towards Client-side HTML Security Policies

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

Still Aren't Doing. Frank Kim

A B S T R A C T. Index Terms: DoubleGuard; database server; intruder; web server I INTRODUCTION

Retrofitting Existing Web Applications with Effective Dynamic Protection Against SQL Injection Attacks

Automatic Creation of SQL Injection and Cross-Site Scripting Attacks

Mobile Application Hacking for Android and iphone. 4-Day Hands-On Course. Syllabus

Double guard: Detecting Interruptions in N- Tier Web Applications

Automated Detection System for SQL Injection Attack

Cyber Exploits: Improving Defenses Against Penetration Attempts

Penetration Testing with Improved Input Vector Identification

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

SQL Injection Vulnerabilities in Desktop Applications

SMask: Preventing Injection Attacks in Web Applications by Approximating Automatic Data/Code Separation

Java Program Vulnerabilities

THE SMARTEST WAY TO PROTECT WEBSITES AND WEB APPS FROM ATTACKS

SQL Injection. Slides thanks to Prof. Shmatikov at UT Austin

SQL injection: Not only AND 1=1. The OWASP Foundation. Bernardo Damele A. G. Penetration Tester Portcullis Computer Security Ltd

Transcription:

A Classification of SQL Injection Attack Techniques and Countermeasures William G.J. Halfond, Jeremy Viegas & Alessandro Orso Georgia Institute of Technology This work was partially supported by DHS contract FA8750-05-2-0214 and NSF award CCR-0209322 to Georgia Tech.

Vulnerable Application String querystring = "SELECT info FROM usertable WHERE "; if ((! login.equals("")) && (! pin.equals(""))) { querystring += "login='" + login + "' AND pin=" + pin ; } else { } querystring+="login='guest'"; ResultSet tempset = stmt.execute(querystring);

Attack Scenario String querystring = "SELECT info FROM usertable WHERE "; if ((! login.equals("")) && (! pin.equals(""))) { querystring += "login='" + login + "' AND pin=" + pin ; } else { querystring+="login='guest'"; } ResultSet tempset = stmt.execute(querystring); Normal Usage User submits login doe and pin 123 SELECT info FROM users WHERE login= `doe AND pin= 123

Attack Scenario String querystring = "SELECT info FROM usertable WHERE "; if ((! login.equals("")) && (! pin.equals(""))) { querystring += "login='" + login + "' AND pin=" + pin ; } else { querystring+="login='guest'"; } ResultSet tempset = stmt.execute(querystring); Malicious Usage Attacker submits admin -- and pin of 0 SELECT info FROM users WHERE login= admin -- AND pin=0

Presentation Outline SQL Injection Attacks Intent Input Source Type Countermeasures Evaluation of countermeasures Lessons learned

Intent Extracting data Adding or modifying data Performing denial of service Bypassing authentication Executing remote commands

Sources of SQL Injection Injection through user input Malicious strings in web forms. Injection through cookies Modified cookie fields contain attack strings. Injection through server variables Headers are manipulated to contain attack strings. Second-order injection Trojan horse input seems fine until used in a certain situation.

Second-Order Injection Attack does not occur when it first reaches the database, but when used later on. Input: admin -- ===> admin\ -- querystring = "UPDATE users SET pin=" + newpin + " WHERE username= " + username + " AND pin=" + oldpin; querystring = UPDATE users SET pin= 0 WHERE username= admin -- AND pin=1 ;

Types of SQL Injection Piggy-backed Queries Tautologies Alternate Encodings Inference Illegal/Logically Incorrect Queries Union Query Stored Procedures

Type: Piggy-backed Queries Insert additional queries to be executed by the database. querystring = SELECT info FROM usertable WHERE + login= + login + ' AND pin= + pin; Input pin as 0; DROP database webapp querystring = SELECT info FROM usertable WHERE login= name' AND pin=0; DROP database webapp

Type: Tautologies Create a query that always evaluates to true for entries in the database. querystring = SELECT info FROM usertable WHERE + login= + login + ' AND pin= + pin; Input login as user or 1=1 -- querystring = SELECT info FROM usertable WHERE login= user or 1=1 --' AND pin=

Type: Alternate Encodings Encode attacks in such a way as to avoid naïve input filtering. querystring = SELECT info FROM usertable WHERE + login= + login + ' AND pin= + pin; Input pin as 0; declare @a char(20) select @a=0x73687574646f776e exec(@a) SELECT info FROM usertable WHERE login= user' AND pin= 0; declare @a char(20) select @a=0x73687574646f776e exec(@a)

Type: Alternate Encodings SHUTDOWN

Countermeasures Prevention Detection Augment Code Detect vulnerabilities in code Safe libraries Detect attacks at runtime Technique X DB

Prevention Techniques Defensive Coding Best Practices Penetration Testing Static Analysis of Code Safe Development Libraries Proxy Filters

Detection Techniques Anomaly Based Intrusion Detection Network DB

Detection Techniques Anomaly Based Intrusion Detection Instruction Set Randomization SELECT4287 Decrypt Proxy Server SELECT DB

Detection Techniques Anomaly Based Intrusion Detection Instruction Set Randomization Dynamic Tainting Model-based Checkers

Dynamic Tainting login = doe pin = 123 Taint Policy Checker DB SELECT info FROM users WHERE login= `doe AND pin= 123 login = admin -- pin = 0 Taint Policy Checker X DB SELECT info FROM users WHERE login= admin -- AND pin=0

Model-based Checkers: AMNESIA Basic Insights 1. Code contains enough information to accurately model all legitimate queries. 2. A SQL Injection Attack will violate the predicted model. Solution: Static analysis => build query models Runtime analysis => enforce models

Model-based Checkers: AMNESIA = guest login SELECT info FROM usertable WHERE login = β AND pin = β String querystring = "SELECT info FROM usertable WHERE "; if ((! login.equals("")) && (! pin.equals(""))) { querystring += "login='" + login + "' AND pin=" + pin ; } else { } querystring+="login='guest'"; ResultSet tempset = stmt.execute(querystring);

Model-based Checkers: AMNESIA = guest login SELECT info FROM usertable WHERE login = β AND pin = β Normal Usage: SELECT info FROM usertable WHERE login = doe AND pin = 123

Model-based Checkers: AMNESIA = guest login SELECT info FROM usertable WHERE login = β AND pin = β Malicious Usage: SELECT info FROM usertable WHERE login = admin -- AND pin = 0

Evaluation Qualitative vs. Quantitative Evaluate technique with respect to 1. Injection Sources 2. SQLIA Types 3. Deployment Requirements 4. Degree of automation

Summary of Results Prevention Techniques Most effective: Java Static Tainting [livshits05] and WebSSARI [Huang04] Not completely automated Runner-ups: Safe Query Objects [cook05], SQL DOM [mcclure05] (Safe development libraries) Require developers to learn and use new APIs Effective techniques automated enforcement of Best Practices

Summary of Results Detection Techniques Problems caused by Stored Procedures, Alternate Encodings Most accurate: AMNESIA [halfond05], SQLCheck [su06], SQLGuard [buehrer05] (Model-based checkers) Of those, only AMNESIA is fully automated Runner-ups: CSSE [pietraszek05], Web App. Hardening [nguyen-tuong05] (Dynamic tainting) Fully automated Require custom PHP runtime interpreter

Conclusions and Lessons Learned 1. SQLIAs have: a) Many sources b) Many goals c) Many types 2. Detection techniques can be effective, but limited by lack of automation. 3. Prevention techniques can be very effective, but should move away from developer dependence.

Questions Thank you.

References V. B. Livshits and M. S. Lam. Finding Security Errors in Java Programs with Static Analysis. In Proceedings of the 14th Usenix Security Symposium, pages 271 286, Aug. 2005. Y. Huang, F. Yu, C. Hang, C. H. Tsai, D. T. Lee, and S. Y. Kuo. Securing Web Application Code by Static Analysis and Runtime Protection. In Proceedings of the 12th International World Wide Web Conference (WWW 04), May 2004. W. R. Cook and S. Rai. Safe Query Objects: Statically Typed Objects as Remotely Executable Queries. In Proceedings of the 27th International Conference on Software Engineering (ICSE 2005), 2005. R. McClure and I. Kr uger. SQL DOM: Compile Time Checking of Dynamic SQL Statements. In Proceedings of the 27th International Conference on Software Engineering (ICSE 05), pages 88 96, 2005. W. G. Halfond and A. Orso. AMNESIA: Analysis and Monitoring for NEutralizing SQL-Injection Attacks. In Proceedings of the IEEE and ACM International Conference on Automated Software Engineering (ASE 2005), Long Beach, CA, USA, Nov 2005. Z. Su and G. Wassermann. The Essence of Command Injection Attacks in Web Applications. In The 33rd Annual Symposium on Principles of Programming Languages (POPL 2006), Jan. 2006. G. T. Buehrer, B. W. Weide, and P. A. G. Sivilotti. Using Parse Tree Validation to Prevent SQL Injection Attacks. In International Workshop on Software Engineering and Middleware (SEM), 2005. A. Nguyen-Tuong, S. Guarnieri, D. Greene, J. Shirley, and D. Evans. Automatically Hardening Web Applications Using Precise Tainting Information. In Twentieth IFIP International Information Security Conference (SEC 2005), May 2005. T. Pietraszek and C. V. Berghe. Defending Against Injection Attacks through Context-Sensitive String Evaluation. In Proceedings of Recent Advances in Intrusion Detection (RAID2005), 2005.