Slide 1 Vitaly Shmatikov CS 380S Static Detection of Web Application Vulnerabilities.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

Hossain Shahriar Mohammad Zulkernine. One of the worst vulnerabilities in web applications It involves the generation of dynamic HTML contents with invalidated.
Semantics Static semantics Dynamic semantics attribute grammars
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
Type-based Taint Analysis for Java Web Applications Wei Huang, Yao Dong and Ana Milanova Rensselaer Polytechnic Institute 1.
Part 2 Authors: Marco Cova, et al. Presented by Brett Parker.
The Web Warrior Guide to Web Design Technologies
By Philipp Vogt, Florian Nentwich, Nenad Jovanovic, Engin Kirda, Christopher Kruegel, and Giovanni Vigna Network and Distributed System Security(NDSS ‘07)
The Essence of Command Injection Attacks in Web Applications Zhendong Su and Gary Wassermann Present by Alon Kremer April 2011.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Gary Wassermann Zhendong Su.
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.
Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Gary Wassermann and Zhendong Su UC Davis Slides from
Guide To UNIX Using Linux Third Edition
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
Slide 1 0x1A Great Papers in Computer Security Vitaly Shmatikov CS 380S
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,
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Preventing SQL Injection ~example of SQL injection $user = $_POST[‘user’]; $pass = $_POST[‘pass’]; $query = DELETE FROM Users WHERE user = ‘$user’ AND.
MS3304: Week 4 PHP & HTML Forms. Overview HTML Forms elements refresher Sending data to a script via an HTML form –The post vs. get methods –Name value.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
PHP Security.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
NDSS 2007 Philipp Vogt, Florian Nentwich, Nenad Jovanovic, Engin Kirda, Christopher Kruegel, Giovanni Vigna.
Pixy: A Static Analysis Tool for Detecting Web Application Vulnerabilities Nenad Jovanovic, Christopher Kruegel, Engin Kirda Secure Systems Lab Vienna.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
OSI and TCP/IP Models And Some Vulnerabilities AfNOG th May 2011 – 10 th June 2011 Tanzania By Marcus K. G. Adomey.
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.
Web-Based Database Programming with PHP. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn PHP Basics PHP functions –To.
Web Database Programming Week 3 PHP (2). Functions Group related statements together to serve “a” specific purpose –Avoid duplicated code –Easy maintenance.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
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.
Finding Security Vulnerabilities in Java Applications with Static Analysis Reviewed by Roy Ford.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
By Davide Balzarotti Marco Cova Viktoria V. FelmetsgerGiovanni Vigna Presented by: Mostafa Saad.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Introduction into JavaScript Java 1 JavaScript JavaScript programs run from within an HTML document The statements that make up a program in an HTML.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
EECS 354: Network Security Group Members: Patrick Wong Eric Chan Shira Schneidman Web Attacks Project: Detecting XSS and SQL Injection Vulnerabilities.
PHP Reusing Code and Writing Functions 1. Function = a self-contained module of code that: Declares a calling interface – prototype! Performs some task.
Creating FunctionstMyn1 Creating Functions Function can be divided into two groups: –Internal (built in) functions –User-defined functions.
Saner: Composing Static and Dynamic Analysis to Validate Sanitization in Web Applications Davide Balzarotti, Marco Cova, Vika Felmetsger, Nenad Jovanovic,
Chapter 4 Static Analysis. Summary (1) Building a model of the program:  Lexical analysis  Parsing  Abstract syntax  Semantic Analysis  Tracking.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Radoslav Georgiev Telerik Corporation
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Web Security (cont.) 1. Referral issues r HTTP referer (originally referrer) – HTTP header that designates calling resource  Page on which a link is.
Detecting Vulnerabilities in Web Code with concolic execution
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:
Introduction to Dynamic Web Programming
Static Detection of Cross-Site Scripting Vulnerabilities
Function There are two types of Function User Defined Function
Automata Based String Analysis for Vulnerability Detection
PHP.
Web DB Programming: PHP
CS5123 Software Validation and Quality Assurance
Presentation transcript:

slide 1 Vitaly Shmatikov CS 380S Static Detection of Web Application Vulnerabilities

slide 2 Reading Assignment uJovanovic et al. “Pixy: A Static Analysis Tool for Detecting Web Application Vulnerabilities.” uWassermann and Su. “Sound and Precise Analysis of Web Applications for Injection Vulnerabilities” (PLDI 2007).

slide 3 Pixy uUses static analysis to detect cross-site scripting and SQL injection vulnerabilities in PHP apps Same ideas apply to other languages uBasic idea: identify whether “tainted” values can reach “sensitive” points in the program Tainted values: inputs that come from the user (should always be treated as potentially malicious) Sensitive “sink”: any point in the program where a value is displayed as part of HTML page (XSS) or passed to the database back-end (SQL injection) [Jovanovic, Kruegel, Kirda]

slide 4 Example of Injection Vulnerabilities tainted sensitive sink

slide 5 Main Static Analysis Issues uTaint analysis Determine, at each program point, whether a given variable holds unsanitized user input uData flow analysis Trace propagation of values through the program uAlias analysis Determine when two variables refer to the same memory location (why is this important?) uPixy: flow-sensitive, context-sensitive, interprocedural analysis (what does this mean?)

slide 6 Handling Imprecision uStatic data flow analysis is necessarily imprecise (why?) uMaintain a lattice of possible values Most precise at the bottom, least precise (  ) at the top uExample from the paper v = 3; if (some condition on user input) v = 3; elsev = 4;

slide 7 Annotated Control-Flow Graph Carrier lattice

slide 8 Data Flow Analysis in PHP uPHP is untyped; this makes things difficult uHow do we tell that a variable holds an array? Natural: when it is indexed somewhere in program What about this code? $a[1] = 7; $b = $a; $c = $b; echo $c[1]; uAssignments to arrays and array elements $a = $b; // … where $a is an array $a[1][2][3] = … $a[1][$b[$i]] = …

slide 9 Other Difficulties uAliases (different names for same memory loc) $a = 1; $b = 2; $b =& $a; $a=3; // $b==3, too! uInterprocedural analysis How to distinguish variables with the same name in different instances of a recursive function? What is the depth of this recursion?

slide 10 Modeling Function Calls uCall preparation Formal parameter  actual argument –Similar to assignment Local variables  default values uCall return Reset local variables For pass-by-reference parameters, actual argument  formal parameter –What if the formal parameter has an alias inside function? What about built-in PHP functions? –Model them as returning , set by-reference params to 

slide 11 Taint Analysis uLiteral – always untainted uVariable holding user input – tainted Use data flow analysis to track propagation of tainted values to other variables uA tainted variable can become untainted $a = ; $a = array(); Certain built-in PHP functions –htmlentities(), htmlspecialchars() – what do they do?

slide 12 False Positives in Pixy uDynamically initialized global variables When does this situation arise? Pixy conservatively treats them as tainted uReading from files Pixy conservatively treats all files as tainted uGlobal arrays sanitized inside functions Pixy doesn’t track aliasing for arrays and array elements uCustom sanitization PhpNuke: remove double quotes from user-originated inputs, output them as attributes of HTML tags – is this safe? why?

slide 13 Wassermann-Su Approach uFocuses on SQL injection vulnerabilities uSoundness Tool is guaranteed to find all vulnerabilities Is Pixy sound? uPrecision Models semantics of sanitization functions Models the structure of the SQL query into which untrusted user inputs are fed How is this different from tools like Pixy?

slide 14 “Essence” of SQL Injection uWeb app provides a template for the SQL query uAttack = any query in which user input changes the intended structure of SQL query uModel strings as context-free grammars (CFG) Track non-terminals representing tainted input uModel string operations as language transducers Example: str_replace(“ ’ ’ “, “ ’ “, $input) A matches any char except “ ’ “

slide 15 Phase One: Grammar Production uGenerate annotated CFG representing set of all query strings that program can generate Direct: data directly from users (e.g., GET parameters) Indirect: second-order tainted data (means what?)

slide 16 String Analysis + Taint Analysis uConvert program into static single assignment form, then into CFG Reflects data dependencies uModel PHP filters as string transducers Some filters are more complex: preg_replace(“/a([0-9]*)b/”, “x\\1\\1y”, “a01ba3b”) produces “x0101yx33y” uPropagate taint annotations

slide 17 Phase Two: Checking Safety uCheck whether the language represented by CFG contains unsafe queries Is it syntactically contained in the language defined by the application’s query template? This non-terminal represents tainted input For all sentences of the form  1 GETUID  2 derivable from query, GETUID is between quotes in the position of an SQL string literal (means what?) Safety check: Does the language rooted in GETUID contain unescaped quotes?

slide 18 Tainted Substrings as SQL Literals uTainted substrings that cannot be syntactically confined in any SQL query Any string with an odd # of unescaped quotes (why?) uNonterminals that occur only in the syntactic position of SQL string literals Can an unconfined string be derived from it? uNonterminals that derive numeric literals only uRemaining nonterminals in literal position can produce a non-numeric string outside quotes Probably an SQL injection vulnerability Test if it can derive DROP WHERE, --, etc.

slide 19 Taints in Non-Literal Positions uRemaining tainted nonterminals appear as non- literals in SQL query generated by the application This is rare (why?) uAll derivable strings should be proper SQL statements Context-free language inclusion is undecidable Approximate by checking whether each derivable string is also derivable from a nonterminal in the SQL grammar –Variation on a standard algorithm

Evaluation uTesting on five real-world PHP applications uDiscovered previously unknown vulnerabilities, including non-trivial ones Vulnerability in e107 content management system: a field is read from a user-modifiable cookie, used in a query in a different file u21% false positive rate What are the sources of false positives?

slide 21 Example of a False Positive