web applications are used extensively in many areas
play

Web applications are used extensively in many areas: We will rely - PowerPoint PPT Presentation

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


  1. 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

  2. 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 3

  4. 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

  5. Web applications use the 3-tier Javascript • architecture Client Side Most web applications check the • inputs both on the client side and the server-side PHP Java 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 DB and performance of the application 5

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

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

  8. function validateEmail(form) { var emailStr = form["email"].value; if(emailStr.length == 0) { return true; } var r1 = new RegExp("( )|(@.*@)|(@\\.)"); var r2 = new RegExp("^[\\w]+@([\\w]+\\. [\\w]{2,4})$"); if(!r1.test(emailStr) && r2.test(emailStr)) { return true; } return false; } 8

  9. public boolean validateEmail(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)) && u.match("/^[\\w]+@([\\w]+\\.[\\w]{2,4})$/”, val)){ return true; } else { return false; } } return true; } 9

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

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

  12. 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

  13. 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

  14. Request http://site.com/unsubscribe.jsp?email=john.doe@mail.com Web application (server side) public class FieldChecks { ... public boolean validateRequired (Object bean, Field field, ..){ String value = evaluateBean(bean, Internet field); if( (value==null) || (value.trim ().length()==0) ){ return false; } else{ return true; } } Confirmation Page ... } Java servlet Congratulations! Your account has been unsubscribed unsubscribe.jsp ... Submit HTML page Web server

  15. Request http://site.com/unsubscribe.jsp?email=john.doe@mail.com Web application (server side) public class FieldChecks { ... public boolean validateRequired (Object bean, Field field, ..){ String value = evaluateBean(bean, Reject Internet field); if( (value==null) || (value.trim ().length()==0) ){ return false; } else{ return true; } } Confirmation Page Confirmation Page ... ERROR } Java servlet Congratulations! Congratulations! Your account has been unsubscribed Your account has been unsubscribed unsubscribe.jsp ... ... Submit HTML page HTML page Web server

  16. Client Validation Server Validation Function Function Good True True input input False False Bad input ¡ 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 16

  17. Reject Web application (server side) public class FieldChecks { ... public boolean validateRequired (Object bean, Field field, ..){ String value = evaluateBean(bean, Internet field); if( (value==null) || (value.trim ().length()==0) ){ return false; } else{ return true; } } ... } Java servlet unsubscribe.jsp Submit Web server

  18. Client Validation Server Validation Function Function Good True True input input False False ¡ 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? 18

  19. Request …<script…>… http://site.com/unsubscribe.jsp?email=john.doe@mail.com Web application (server side) Submit public class FieldChecks { ... public boolean validateRequired (Object bean, Attac Field field, ..){ String value = evaluateBean(bean, Internet field); if( (value==null) || (value.trim ().length()==0) ){ return false; k } else{ return true; } } ... } Java servlet unsubscribe.jsp Web server

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

  21. JS Task 2: Task 1: Client side Input validation Input validation mapping and modeling Java extraction using DFAs Server side Input validation operations Web application Task 3: Inconsistency Counter example identification and reporting Input validation DFAs

  22. JS Task 1: Client side Input validation mapping and Java extraction Server side Input validation operations Web application

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

  24. ¡ 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

  25. Exec Path Dynamic Slice Run Application Dep Analysis Input ¡ 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 25

  26. Parsing and CFG Transformations Construction and Slicing (uses Soot) Input validation routines Static Slice Control flow graph ¡ 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 26

  27. Task 2: Input validation modeling using DFAs Input validation DFAs

  28. 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

  29. Static string analysis determines all possible values that a string l 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

  30. Symbolic DFA representation Explicit DFA representation . 1 . . 0 2 30

  31. Σ * Due to . . . Lattice with . . . loops we . . . infinite height need fixpoint computation Ø 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 31

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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend