Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Gary Wassermann Zhendong Su.

Slides:



Advertisements
Similar presentations
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Advertisements

Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
GATEKEEPER MOSTLY STATIC ENFORCEMENT OF SECURITY AND RELIABILITY PROPERTIES FOR JAVASCRIPT CODE Salvatore Guarnieri & Benjamin Livshits Presented by Michael.
Sania: Syntactic and Semantic Analysis for Automated Testing against SQL Injection Yuji Kosuga, Kenji Kono, Miyuki Hanaoka Keio University Miho Hishiyama,
The Essence of Command Injection Attacks in Web Applications Zhendong Su and Gary Wassermann Present by Alon Kremer April 2011.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
ReferencesReferences DiscussionDiscussion Vulnerability Example: SQL injection Auditing Tool for Eclipse LAPSE: a Security Auditing Tool for Eclipse IntroductionIntroductionResultsResults.
Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Gary Wassermann and Zhendong Su UC Davis Slides from
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
1 RAKSHA: A FLEXIBLE ARCHITECTURE FOR SOFTWARE SECURITY Computer Systems Laboratory Stanford University Hari Kannan, Michael Dalton, Christos Kozyrakis.
Automatic Creation of SQL Injection and Cross-Site Scripting Attacks 2nd-order XSS attacks 1st-order XSS attacks SQLI attacks Adam Kiezun, Philip J. Guo,
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Syntactic Analysis Dr. Hyunyoung Lee.
Analysis of SQL injection prevention using a proxy server By: David Rowe Supervisor: Barry Irwin.
(CPSC620) Sanjay Tibile Vinay Deore. Agenda  Database and SQL  What is SQL Injection?  Types  Example of attack  Prevention  References.
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.
Automatically Hardening Web Applications Using Precise Tainting Anh Nguyen-Tuong Salvatore Guarnieri Doug Greene Jeff Shirley David Evans University of.
AMNESIA: Analysis and Monitoring for NEutralizing SQL- Injection Attacks Published by Wiliam Halfond and Alessandro Orso Presented by El Shibani Omar CS691.
Exploitation: Buffer Overflow, SQL injection, Adobe files Source:
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 5 “Database and Cloud Security”.
Preventing Web Application Injections with Complementary Character Coding Raymond Mui Phyllis Frankl Polytechnic Institute of NYU Presented at ESORICS.
CSC-682 Cryptography & Computer Security Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Pompi Rotaru Based on an article.
Testing Grammars For Top Down Parsers By Asma M Paracha, Frantisek F. Franek Dept. of Computing & Software McMaster University Hamilton, Ont.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
An Analysis Framework for Security in Web Applications Gary Wassermann and Zhendong Su University of California, Davis.
Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.
Slide 1 Vitaly Shmatikov CS 380S Static Detection of Web Application Vulnerabilities.
Parsing Introduction Syntactic Analysis I. Parsing Introduction 2 The Role of the Parser The Syntactic Analyzer, or Parser, is the heart of the front.
By Davide Balzarotti Marco Cova Viktoria V. FelmetsgerGiovanni Vigna Presented by: Mostafa Saad.
Compiler Design Introduction 1. 2 Course Outline Introduction to Compiling Lexical Analysis Syntax Analysis –Context Free Grammars –Top-Down Parsing –Bottom-Up.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Michael Dalton, Christos Kozyrakis, and Nickolai Zeldovich MIT, Stanford University USENIX 09’ Nemesis: Preventing Authentication & Access Control Vulnerabilities.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Unit-3 Parsing Theory (Syntax Analyzer) PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Dynamic Taint Analysis for Automatic Detection, Analysis, and Signature Generation of Exploits on Commodity Software Paper by: James Newsome and Dawn Song.
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.
Overview of Previous Lesson(s) Over View 3 Model of a Compiler Front End.
Costas Busch - LSU1 Parsing. Costas Busch - LSU2 Compiler Program File v = 5; if (v>5) x = 12 + v; while (x !=3) { x = x - 3; v = 10; } Add v,v,5.
Saner: Composing Static and Dynamic Analysis to Validate Sanitization in Web Applications Davide Balzarotti, Marco Cova, Vika Felmetsger, Nenad Jovanovic,
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
Database and Cloud Security
Creating Database Objects
Group 18: Chris Hood Brett Poche
Describing Syntax and Semantics
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Automatic Web Security Unit Testing: XSS Vulnerability Detection Mahmoud Mohammadi, Bill Chu, Heather Richter, Emerson Murphy-Hill Presenter:
CS 326 Programming Languages, Concepts and Implementation
Static Detection of Cross-Site Scripting Vulnerabilities
Context-free grammars, derivation trees, and ambiguity
Syntax Specification and Analysis
Compiler Construction
Taint tracking Suman Jana.
Automata Based String Analysis for Vulnerability Detection
CS416 Compiler Design lec00-outline September 19, 2018
Introduction CI612 Compiler Design CI612 Compiler Design.
All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, Thanassis.
Lecture 4: Lexical Analysis & Chomsky Hierarchy
Chapter 13 Security Methods Part 3.
Parsing Costas Busch - LSU.
CS 3304 Comparative Languages
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
CS416 Compiler Design lec00-outline February 23, 2019
CSC-682 Advanced Computer Security
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
String Analysis for JavaScript Programs Using JSAI
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Automatically Hardening Web Applications Using Precise Tainting
Creating Database Objects
Presentation transcript:

Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Gary Wassermann Zhendong Su

What is SQL injection attack ? An attacker exploits faulty application code to execute maliciously crafted database queries. In 2006, 14% of the reported vulnerabitilities were SQLCIVs, making SQL injection the second most frequently reported security threat.

An example $userid= “ 1';DROP TABLE unp_user; -- ” Executed query : SELECT * FROM `unp_user` WHERE userid='1'; DROP TABLE unp_user; --'

Existing Approaches Tainted information flow tracking  do not model the precise semantics of input sanitization routines  require manually written specifications  not fully automated and may require user intervention (e.g dynamic include in PHP) String analysis- based techniques  do not track the source of string values and therefore require specifications

Context Free Grammar (CFG) denotes “ derives in one step ” for example : if denotes “ drives in finite number of steps ”

Definition of web application

Definition of syntactic confinement

Definition of SQLCIV

The article ’ s approach 1)Model string values as CFG 2)Label nonterminals as “ direct ” or “ indirect ” if needed 3)Checks if all string in the language of the CFG are not SQLCIV according to definition

General scheme of implementation

Illustration of the algorithm For all sentential forms derivable from query GETuid is between quotes in a syntactic position of a string literal

Building the CFG (1)

Building the CFG (2) Not all string operations are concatenation and assignments what about x=escape_quotes(x) ? We need to model x escape_quotes(y) In order to model those cases we use Finite State Transducers (FST)

FST Finite-state machine whose output values are determined both by its current state and by the values of its inputs Has one or more final states May be non-deterministic

Example :modeling str_repalce with FST str_replace( “ ‘ ‘ “, “ ‘ “, $B)

The Problem with FST Cannot model all string functions in PHP –Preg_replace(pattern, replacement, subject ) Mohri and Sproat describe how approximate those functions using two FST

Intersection between FST and CFG

General scheme of implementation

Policy Conformance Analysis (1) If an untrusted substring has and odd number of quotes it cannot be syntactically confined. For each labeld X if Then X is not safe

Policy Conformance Analysis (2) If labeld X only occur in the syntactic position of string literals : –If any form that derives from X has unescaped quotes in it then X derives unconfined strings and X is not safe –Else X is safe

Policy Conformance Analysis (3) If X only derives numeric literals Then X is safe

Policy Conformance Analysis (4) If X can produce a non numeric string outside of quotes it likely represents an SQLCIV. To confirm this we check whether X derive any string that cannot be confined (e.g. “ drop where, ” “ -- “ ). If it can then X is unsafe

Policy Conformance Analysis (5) If each string, derives from the remaining labeld nonterminals, is derivable from some nonterminal in the SQL grammar then the remaining labeld nonterminals are safe.

Implementation Using modified Minamide ’ s String analyzer –Specifications for 243 PHP functions were added –Improvement in PHP dynamic includes support Check derivability using an extension of Earley ’ s parsing algorithm

Results False positive rate = 20.8% False negative rate = 0%

explanations for false positive rate Insufficient precision through type conversions ASCII functions

Future improvements Improve analyzing of helper functions in other files Analyzing only strings which affect the data base

Conclusions 1.Catch all SQLCIV 2.Could be very slow (but future improvements will make it faster ) 3.False positive rate a bit high but will be improved in next version