Muath Alkhalaf 1 Shauvik Roy Choudhary 2 Mattia Fazzini 2 Tevfik Bultan 1 Alessandro Orso 2 Christopher Kruegel 1 1 UC Santa Barbara 2 Georgia Tech.

Slides:



Advertisements
Similar presentations
Dataflow Analysis for Datarace-Free Programs (ESOP 11) Arnab De Joint work with Deepak DSouza and Rupesh Nasre Indian Institute of Science, Bangalore.
Advertisements

Context-Sensitive Auto-Sanitization In Web Templating Languages Using Type Qualifiers Prateek Saxena UC Berkeley Mike Samuel Google Dawn Song UC Berkeley.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
GATEKEEPER MOSTLY STATIC ENFORCEMENT OF SECURITY AND RELIABILITY PROPERTIES FOR JAVASCRIPT CODE Salvatore Guarnieri & Benjamin Livshits Presented by Michael.
Presented by Vaibhav Rastogi.  Advent of Web 2.0 and Mashups  Inclusion of untrusted third party content a necessity  Need to restrict the functionality.
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
SOFTWARE SECURITY JORINA VAN MALSEN 1 FLAX: Systematic Discovery of Client-Side Validation Vulnerabilities in Rich Web Applications.
Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Gary Wassermann Zhendong Su.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Multiple Tiers in Action
Apache Tomcat Server Typical html Request/Response cycle
CS 290C: Formal Models for Web Software Lecture 1: Introduction Instructor: Tevfik Bultan.
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
JavaScript Demo Presented by … Jaisingh Sumit jain Sudhindra Taran Deep arora.
INTRODUCTION TO WEB DATABASE PROGRAMMING
JSP Standard Tag Library
JavaScript Form Validation
CS 290C: Formal Models for Web Software Lectures 17: Analyzing Input Validation and Sanitization in Web Applications Instructor: Tevfik Bultan.
WAPTEC: Whitebox Analysis of Web Applications for Parameter Tampering Exploit Construction Prithvi Bisht ( + Timothy Hinrichs*
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Introduction to ASP.NET. Prehistory of ASP.NET Original Internet – text based WWW – static graphical content  HTML (client-side) Need for interactive.
Component-Based Software Engineering Internet Applications Paul Krause.
JavaScript JavaScript is a scripting language that is most commonly used to add client- side programming to a web page. Some of the things it is used for.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Prithvi Bisht, Timothy Hinrichs, Nazari Skrupsky, Radoslaw Bobrowicz, V.N. Venkatakrishnan University of Illinois at Chicago, USA ACM CCS (Oct,2010) Prithvi.
VEX: VETTING BROWSER EXTENSIONS FOR SECURITY VULNERABILITIES XIANG PAN.
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.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
AMNESIA: Analysis and Monitoring for NEutralizing SQL- Injection Attacks Published by Wiliam Halfond and Alessandro Orso Presented by El Shibani Omar CS691.
1 A Static Analysis Approach for Automatically Generating Test Cases for Web Applications Presented by: Beverly Leung Fahim Rahman.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Server & Client  Client: Your computer  Server: Powerful & Expensive computer. Requires network access.
Chapter 8 Cookies And Security JavaScript, Third Edition.
CSC-682 Cryptography & Computer Security Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Pompi Rotaru Based on an article.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Interfaces, Forms & Databases Databases Snyder p HTML Basics Snyder p JavaScript Snyder Chapter 18.
OWASP Top Ten #1 Unvalidated Input. Agenda What is the OWASP Top 10? Where can I find it? What is Unvalidated Input? What environments are effected? How.
1 Welcome to CSC 301 Web Programming Charles Frank.
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.
SQL INJECTIONS Presented By: Eloy Viteri. What is SQL Injection An SQL injection attack is executed when a web page allows users to enter text into a.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
JSTL The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
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.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Differential String Analysis Tevfik Bultan (Joint work with Muath Alkhalaf, Fang Yu and Abdulbaki Aydin) 1 Verification Lab Department.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Servers- Apache Tomcat Server Server-side scripts- Java Server Pages.
CS 267: Automated Verification Lectures 16: String Analysis Instructor: Tevfik Bultan.
Automatic Repair for Input Validation and Sanitization Bugs 1.
Saner: Composing Static and Dynamic Analysis to Validate Sanitization in Web Applications Davide Balzarotti, Marco Cova, Vika Felmetsger, Nenad Jovanovic,
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Tutorial 10 Programming with JavaScript
String Analysis for Dependable Input Validation
Automata Based String Analysis for Vulnerability Detection
Tutorial 10: Programming with javascript
Presentation transcript:

Muath Alkhalaf 1 Shauvik Roy Choudhary 2 Mattia Fazzini 2 Tevfik Bultan 1 Alessandro Orso 2 Christopher Kruegel 1 1 UC Santa Barbara 2 Georgia Tech

 Web applications are used extensively in many areas:  We will rely on web applications more in the future:  Web software is also rapidly replacing desktop applications 2

3 IBM X-force report

 The user input comes in string form and must be validated before it can be used  Input validation uses string manipulation which is error prone  We need to verify input validation to assure:  Correctness  Security  Consistency 4

DB Client Side Javascript Web applications use the 3-tier architecture Most web applications check the inputs both on the client side and the server-side This redundancy is necessary for security reasons (client-side checks can be circumvented by malicious users) Not having client-side input validation results in unnecessary communication with the server, degrading the responsiveness and performance of the application Server Side JavaPHP 5

 Size of Client Side code is growing rapidly  Over 90% of web sites use javascript source: W3Techs Source: According to an IBM study performed in Salvatore Guarnieri 6

7 True (valid) False (Invalid) Input Validation Function Input

8 function validate (form) { var Str = form[" "].value; if( Str.length == 0) { return true; } var r1 = new RegExp("( var r2 = new [\\w]{2,4})$"); if(!r1.test( Str) && r2.test( Str)) { return true; } return false; }

public boolean validate (Object bean, Field f,..) { String val = ValidatorUtils.getValueAsString(bean, f); Perl5Util u = new Perl5Util(); if (!(val == null || val.trim().length == 0)) { if ((!u.match("/( val)) && val)){ return true; } else { return false; } return true; } 9

True (valid) False (Invalid) 10 Good input Bad input A function that accepts some bad input values

True (valid) False (Invalid) 11 Good input Bad input A function that rejects some good input values

 How can we check the validation functions?  One approach that has been used in the past:  Specify the input validation policy as a regular expression (attack patterns, max & min policies) and then use string analysis to check that validation functions conform to the given policy.  Someone has to manually write the input validation policies  If the input validation policies are specific for each web application, then the developers have to write different policies for each application, which could be error prone 12

 The approach we present in this paper does not require developers to write specific policies  Basic idea: Use the inherent redundancy in input validation to check the correctness of the input validation functions 13

Submit

ERROR Reject

16 Client Validation Function True False Good input True False Bad input Server Validation Function  Two problems may occur:  Either the client side input validation function was under constrained and accepted bad inputs  Or the server side input validation function was over constrained and rejected some good input

Submit Reject

18 Client Validation Function True False Good input True False input Server Validation Function  A problem may occur:  the client side input validation function was over constrained and rejected some good input  What happens when Input value is bad and the server accepts this value?

Submit … Attac k

20 Client Validation Function True False True False Bad input Server Validation Function  The server side input validation function was under constrained and accepted bad inputs  Serious security problem

23 Web Deployment Descriptor J2EE Web App Web Application Analyzer Web Application Analyzer For each input, we obtain  Domain information  Multiple parameterized validation functions with parameter values  Path to access the web application form Dynamic Extraction for JavaScript Static Extraction for Java Routines Per Input Validation Configuration

 Why extraction  Lots of event handling, error reporting and rendering code  Why dynamic?  Javascript is very dynamic  Object oriented  Prototype inheritance  Closures  Dynamically typed  eval 24

 Number of valid inputs  Inputs are selected heuristically  Instrument execution  HtmlUnit: browser simulator  Rhino: JS interpreter  Convert all accesses on objects and arrays to accesses on memory locations Input Run ApplicationDep Analysis Exec PathDynamic Slice 25

26  Transformations  Library call and parameter inlining  Framework specific modeling and transformation  Constant propagation and Dead code elimination  Slicing (PDG based)  Forward slicing on input parameter  Backward slicing for the true path Input validation routines Static Slice Control flow graph Transformations and Slicing Parsing and CFG Construction (uses Soot)

 Compute two automata for each input field:  Client-Side DFA A c ▪L(A c ) Over approximation of set of values accepted by client-side input validation function  Server-Side DFA A s ▪L(A s ) Over approximation of set of values accepted by server-side input validation function  We use automata based static string analysis to compute L(A c ) and L(A s ) 28

Static string analysis determines all possible values that a string expression can take during any program execution  We use automata based string analysis  Associate each string expression in the program with an automaton  The automaton accepts an over approximation of all possible values that the string expression can take during program execution  We built our javascript string analysis on Closure compiler from Google and java string analysis on Soot  Flow sensitive, intraprocedural and path sensitive 29

Explicit DFA representation Symbolic DFA representation

 We use an automata based widening operation to over-approximate the fixpoint  Widening operation over-approximates the union operations and accelerates the convergence of the fixpoint computation Ø Σ*Σ* Due to loops we need fixpoint computation Lattice with infinite height

 Modeling string operations  CONCATENATION ▪ y = x + “b”  REPLACEMENT ▪Language based replacement ▪ replace(x, “a”, “d”)  RESTRICTION ▪ If (x = “a”){ … } Input Output Input Output a b ba aad d d, a a Input Output c c c 32

33 var Str = form[" "].value; Str.length == 0 return true !r1.test( Str) && r2.test( Str) !r1.test( Str) && r2.test( Str) return true return false Σ* Σ+Σ+ Σ+Σ+ ε ε (( (Σ + \ (( (Σ + \ L(A c ) = (Σ* \ (( ((Σ + \ (( ((Σ + \ (( Yes No if (Pred ≡ var.length == intlit) return Σ intlit ; if (Pred ≡ regexp.test(var)) if (checkregexp(regexp)=partialmatch) return CONCAT(CONCAT(Σ ∗, L(regexp)), Σ ∗ ); else return L(regexp);

34 String val = ValidatorUtils.getValueAsString(bean, f); !(val == null || val.trim().length == 0) !(val == null || val.trim().length == 0) return true !u.match("/( val)) && [\\w]{2,4})$/”, val) !u.match("/( val)) && [\\w]{2,4})$/”, val) return false Σ* [^ ] + ( *) ([^ ] + \ (( ([^ ] + \ (( No Yes if (Pred ≡ regexp.match(var)) if (checkregexp(regexp)=partialmatch) return CONCAT(CONCAT(Σ ∗, L(regexp)), Σ ∗ ); else return L(regexp); if (Pred ≡ var.length == intlit) return Σ intlit ; Σ* ([^ ] + \ $))) ([^ ] + \ $))) L(A s ) = ([^ ] + \ ((

 Compute two difference signatures:  L(A s-c ) = L(A s ) \ L(A c )  L(A c-s ) = L(A c ) \ L(A s )  If L(A s-c ) ≠ Ø  If L(A c-s ) ≠ Ø 36

37 Server Client Server Client Server Client Server Five possible relationships between L(A c ) and L(A s ) L(A c ) = L(A s ) L(A s ) L(A c ) L(A c ) L(A s ) L(A c ) L(A s ) ≠ Ø L(A c ) L(A s ) = Ø

38 We compute L(A s-c ) Server Client Server Client Server Client Server Client L(A s-c ) = Ø L(A s-c ) ≠ Ø

39 We compute L(A c-s ) Client Server server client Client Server Client Server Client Server L(A c-s ) = Ø L(A c-s ) ≠ Ø

 Compute two difference signatures:  L(A c-s ) = L(A c ) \ L(A s ) = Ø  L(A s-c ) = L(A s ) \ L(A c ) 40 L(A s ) = ([^ ] + \ (( L(A c ) = (Σ* \ (( \ L(A s-c ) = [ ]+ = Counter Example = “ “

 Analyzed a number of Java EE web applications 41 NameURL JGOSSIP VEHICLE MEODIST MYALUMNI CONSUMER TUDU JCRBIB

42

43

44

 String Analysis  String analysis based on context free grammars: [Christensen et al., SAS’03] [Minamide, WWW’05]  Application of string analysis to web applications : [Wassermann and Su, PLDI’07, ICSE’08] [Halfond and Orso, ASE’05, ICSE’06]  Automata based string analysis: [Xiang et al., COMPSAC’07] [Shannon et al., MUTATION’07]  Input Validation Verification  FLAX [ P. Saxena et al., NDSS’10 ]  Kudzu [ P. Saxena et al., SSP’10 ]  NoTamper [ P. Bisht et al., CCS’10 ]  WAPTEC [ P. Bisht et al., CCS’11 ]  [ M. Alkhalaf et al., ICSE’12 ] 45

Extensive string manipulation:  Web applications use extensive string manipulation  To construct html pages, to construct database queries in SQL, to construct system commands, etc.  The user input comes in string form and must be validated before it can be used  String manipulation is error prone 47