Eliminating Bugs In MVC-Style Web Applications Tevfik Bultan Verification Lab (Vlab),

Slides:



Advertisements
Similar presentations
Advantage Data Dictionary. agenda Creating and Managing Data Dictionaries –Tables, Indexes, Fields, and Triggers –Defining Referential Integrity –Defining.
Advertisements

Eliminating Navigation Errors in Web Applications via Model Checking and Runtime Enforcement of Navigation State Machines Sylvain Halle, Taylor Ettema,
Software Engineering COMP 201
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
Database Management: Getting Data Together Chapter 14.
CS 290C: Formal Models for Web Software Lecture 9: MVC Architecture and Navigation Analysis Based on the MVC Architecture Instructor: Tevfik Bultan.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
CS 290C: Formal Models for Web Software Lecture 1: Introduction Instructor: Tevfik Bultan.
Leveraging User Interactions for In-Depth Testing of Web Applications Sean McAllister, Engin Kirda, and Christopher Kruegel RAID ’08 1 Seoyeon Kang November.
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
C++ fundamentals.
Leveraging User Interactions for In-Depth Testing of Web Application Sean McAllister Secure System Lab, Technical University Vienna, Austria Engin Kirda.
UNIT-V The MVC architecture and Struts Framework.
CS 290C: Formal Models for Web Software Lecture 9: Analyzing Data Models Using Alloy Analyzer and SMT-Solvers Instructor: Tevfik Bultan.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Data Model Analysis Tevfik Bultan University of California Santa Barbara Joint work with Jaideep Nijjar and Ivan Bocic.
A Scalable Application Architecture for composing News Portals on the Internet Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta Famagusta.
Aurora: A Conceptual Model for Web-content Adaptation to Support the Universal Accessibility of Web-based Services Anita W. Huang, Neel Sundaresan Presented.
Tutorial 14 Working with Forms and Regular Expressions.
Server-side Scripting Powering the webs favourite services.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
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.
Preventing SQL Injection Attacks in Stored Procedures Alex Hertz Chris Daiello CAP6135Dr. Cliff Zou University of Central Florida March 19, 2009.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
AMNESIA: Analysis and Monitoring for NEutralizing SQL- Injection Attacks Published by Wiliam Halfond and Alessandro Orso Presented by El Shibani Omar CS691.
Unbounded Data Model Verification Using SMT Solvers Jaideep NijjarTevfik Bultan University of California, Santa Barbara ASE 2012.
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
Lecture 16 Page 1 CS 236 Online SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages.
1 A Static Analysis Approach for Automatically Generating Test Cases for Web Applications Presented by: Beverly Leung Fahim Rahman.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Data Model Property Inference and Repair
CSC-682 Cryptography & Computer Security Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Pompi Rotaru Based on an article.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Interception and Analysis Framework for Win32 Scripts (not for public release) Tim Hollebeek, Ph.D.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Attacking Data Stores Brad Stancel CSCE 813 Presentation 11/12/2012.
Software Development. Software Developers Refresher A person or organization that designs software and writes the programs. Software development is the.
1 Welcome to CSC 301 Web Programming Charles Frank.
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
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.
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz.
Building Secure Web Applications With ASP.Net MVC.
ITGS Databases.
Model View Controller MVC Web Software Architecture.
By Davide Balzarotti Marco Cova Viktoria V. FelmetsgerGiovanni Vigna Presented by: Mostafa Saad.
WHAT IS SERVER SIDE SCRIPTING? Server-side scripting is a web server technology in which a user's request is verified by running a script directly on the.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Security Attacks CS 795. Buffer Overflow Problem Buffer overflow Analysis of Buffer Overflow Attacks.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
Winter 2007SEG2101 Chapter 121 Chapter 12 Verification and Validation.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Application architectures Advisor : Dr. Moneer Al_Mekhlafi By : Ahmed AbdAllah Al_Homaidi.
Testing Integral part of the software development process.
Group 18: Chris Hood Brett Poche
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Types for Programs and Proofs
Static Detection of Cross-Site Scripting Vulnerabilities
Automata Based String Analysis for Vulnerability Detection
Lecture 2 - SQL Injection
Lecture 34: Testing II April 24, 2017 Selenium testing script 7/7/2019
Exploring DOM-Based Cross Site Attacks
Presentation transcript:

Eliminating Bugs In MVC-Style Web Applications Tevfik Bultan Verification Lab (Vlab),

Joint work with my students & postdocs Fang Yu Muath Alkhalaf Jaideep Nijjar Sylvain Halle

Web software everywhere Commerce, entertainment, social interaction We will rely on web apps more in the future Web apps + cloud will make desktop apps obsolete

One major road block Web applications are not trustworthy –They are notorious for security vulnerabilities and unreliable behavior Web applications are hard to program –Distributed behavior, interaction among many components and many languages We applications are hard to test –Highly dynamic behavior and concurrency Testing accounts for 50% of the development costs and software failures cost USA 60 billion annually

Why are web applications error prone? Script-oriented programming –A collection of scripts with no explicit control flow Extensive string manipulation –User input comes in string form, output (html, SQL) is generated via string manipulation Complex interactions –User interaction via browsers, client-side server-side interaction, interaction with the backend database Distributed system –Many components have to coordinate

VLab Research Agenda Improve dependability of web applications –How? By eliminating bugs –How? »Use automated verification By eliminating bugs I do not mean debugging –Debugging is done after the bug is found Finding the bug is the hard part Our goal is to find the bugs automatically –and eliminate them before the software is deployed we do this using automated verification

We have a hammer Automated Verification

Actually, we have several hammers Automated Verification Techniques Bounded verification via SAT solvers Symbolic execution via SMT solvers String analysis Model checking

Unfortunately, life is complicated Automated verification techniques Web application problems

Automated verification is hard If it wasn’t, everybody would be using it It is hard because software systems are too complex In order to make automated verification feasible –we need to focus our attention

Making automated verification feasible We focus our attention by –Abstraction Hide details that do not involve the things we are checking –Modularity We focus on one part of the system at a time –Separation of concerns We focus on one property at a time It turns out these are also the main principles of software design –We should be able to exploit the design structure in automated verification!

Separation of concerns First, we need to identify our concerns –What should we be concerned with if we want to eliminate the bugs in web applications Here are some concerns: –Input validation Errors in input validation are a major cause of security vulnerabilities in web applications –Navigation Many web applications do not handle unexpected user requests appropriately –Data model Integrity of the data model is essential for correctness of web applications

Why care about input validation? String related web application vulnerabilities as a percentage of all vulnerabilities (reported by CVE) OWASP Top 10 in 2007: 1.Cross Site Scripting 2.Injection Flaws OWASP Top 10 in 2010: 1.Injection Flaws 2.Cross Site Scripting

Why care about navigation?

Why care about data model? The data in the back-end database is the most important resource for most web applications Integrity and consistency of this data is crucial for dependability of the web application

Separation of concerns By focusing on one problem at a time: –Input validation errors –Navigation errors –Data modeling errors We are more likely to develop feasible verification techniques Still, we need more help!

Modularity: Model-View-Controller Model-view-controller (MVC) architecture has become the standard way to structure web applications –Ruby on Rails, Zend Framework for PHP, CakePHP, Spring Framework for Java, Struts Framework for Java, Django for Python, … MVC architecture separates –where and how the data is stored (the model) – from how it is presented (the views)

Model-View-Controller (MVC) architecture MVC consists of three modules –Model represents the data –View is its presentation to the user –Controller defines the way the application reacts to user input a=50% b=30% c=20% model views

MVC framework for web applications Model: –An abstract representation of the data stored in the backend database –Uses an object-relational mapping to map the application class structure to the back-end database tables Views: –Responsible for rendering of the web pages, i.e., how is the data presented in user’s browser Controllers: –Event handlers that process incoming user requests –They can update the data model, and create a new view to be presented to the user

Exploiting MVC for verification Modularity provided by MVC can be exploited in verification For checking navigation properties –Focus on controllers For checking input validation –Focus on controllers For checking data model properties –Focus on the model

Still, need more help Even with –the separation of concerns check one type of property at a time (navigation, input validation, data model) –and modularity focus on only one component at a time (controller or the model) we still need more help! To completely automate the verification process –We need to find a way to map the code written in a programming language to something that an automated verification tool can check We have a verification model problem!

How to get verification models? The verification model is an abstraction of the behavior of the application We obtain this abstraction using two basic approaches: 1.When possible we automatically extract a verification model from the code using automated abstraction + static analysis Automated model extraction 2.If we cannot automatically extract the model, we ask the developer to write a model. In this case we have to enforce the specified model at runtime Automated model enforcement

Three verification techniques 1.Concern: Input validation checking –Module: Controller –Verification model extraction via abstraction: Dependency analysis to extract dependency graph –Verification technique: String analysis 2.Concern: Navigation correctness –Module: Controller –Verification model specification by developer: Automated enforcement of navigation model at runtime –Verification technique: Model checking 3.Concern: Data model integrity –Module: Data model –Verification model extraction via abstraction: –Verification technique: Bounded SAT based verification

Making it work String analysis Input validation Separation of concerns + modularity + abstraction Model checking Bounded SAT based verification Navigation correctness Data integrity

Input validation verificationParser/ Taint Analysis Vulnerability Analysis Signature Generation Attack Patterns Application/ Scripts Vulnerability Signature (Tainted) Dependency Graphs Patch Synthesis Sanitization Statements Reachable Attack Strings

An example XSS vulnerability A PHP Example: 1:<?php 2: $www = $_GET[”www”]; 3: $l_otherinfo = ”URL”; 4: $www = 5: echo ” ”. $l_otherinfo. ”: ”. $www. ” ”; 6:?> Line 4 removes all characters that are not in However, denotes all characters between “.” and (including “ ”) Our string analysis automatically detects that there is a XSS vulnerability in line 5

Automatically generated patch Our string analysis generates a vulnerability signature that characterizes all possible input strings that can exploit the vulnerability Our patch generation algorithm automatically generates a patch that removes the vulnerability 1: <?php P: if(preg match(’/[^ <]*<.*/’,$_GET[”www”])) $_GET[”www”] = preg replace(<,””,$_GET[”www”]); 2: $www = $_GET[”www”]; 3: $l_otherinfo = ”URL”; 4: $www = 5: echo ” ”. $l_otherinfo. ”: ”.$www. ” ”; 6: ?>

Experiments We applied our analysis to three open source PHP applications Webches (a server for playing chess over the internet) EVE 1.0 (a tracker for player activity for an online game) Faqforge (a document management tool) Attack patterns: –Σ ∗ <script Σ ∗ (for XSS) –Σ ∗ or 1=1 Σ ∗ (for SQLI) Application#FilesLOC# XSS Sinks # SQLI Sinks 1Webchess EVE Faqforge

Verification Results Type# Vulnerabilities (single, 2, 3, 4) Time (s) total fwdbwdrelational Memory (KB) average 1. XSS SQL (24, 3, 0, 0) (43, 3, 1, 2 ) XSS SQL (0, 0, 8, 0) (8, 3, 0, 0) XSS SQL (20, 0, 0, 0) (0, 0, 0, 0) <1  We use (single, 2, 3, 4) indicates the number of detected vulnerabilities that have single input, two inputs, three inputs and four inputs

Making it work String analysis Input validation Separation of concerns + modularity + abstraction Model checking Bounded SAT based verification Navigation correctness Data integrity

Navigation verification We ask developer to specify the high level navigation behavior as a navigation state machine MVC frameworks typically use a hierarchical structure where actions are combined in the controllers and controllers are grouped into modules –We exploit this hierarchy to specify the navigation state machines as hierarchical state machines

Navigation verification Navigation Properties Static Verification Runtime Enforcement Navigation State Machine Translator SMV Verified Counter-example behavior NSM Plugin (NSM Interpreter)

Navigation verification experiments We studied three real-world, freely available web applications: –BambooInvoice: invoice management application 159,000 lines of code, 60 actions –Capstone: student project management system 41,000 lines of code, 33 actions –Digitalus: content management system 401,000 lines of code, 26 actions

Specifying the NSM We specified the NSMs manually, by exploring potential error sequences in applications –Amount of effort: Half a day per application (including taking screenshots, drawing the graph, etc.) ApplicationStatesTransitionsVariables Digitalus32487 BambooInvoice63808 Capstone8161

Model checking NSMs We used an existing model checker (SMV) to statically check navigation properties of NSMs Some example navigation properties: –Once you login, the only way to go back to the login page is by traversing the logout page –Each controller has the 'index' action as its only entry point from other controllers We can statically verify the NSMs with SMV model checker –Verification uses less than 4.4 MB of memory and takes less than 1 second

Runtime enforcement of NSMs PHP plugin for enforcement of NSMs at runtime –Intercepts page requests in an MVC application and validates them against the NSM –One line of code to insert in the application –Simple: 1,100 lines of PHP code (3% of the smallest application) Average processing time when an action conforms to the NSM: ApplicationTime without plugin (ms) Time with plugin (ms) Digitalus1112 BambooInvoice Capstone90122

Runtime enforcement of NSMs Processing time when an action provokes a PHP warning (which the NSM-enabled application blocks):...and when an action provokes a PHP error: ApplicationActionTime without plugin (ms) Time with plugin (ms) DigitalusCreate folder2826 DigitalusUpload media1832 BambooInvoiceNew invoice ApplicationActionTime without plugin (ms) Time with plugin (ms) DigitalusEdit page41632 DigitalusDelete folder42436 BambooInvoiceView invoice564594

Making it work String analysis Input validation Separation of concerns + modularity + abstraction Model checking Bounded SAT based verification Navigation correctness Data integrity

Data model verification We worked on verification of static data model properties in Ruby-on-Rails applications Rails uses active records for object-relational mapping There are many options in active records declarations that can be used to specify constraints about the data model Our goal: –Automatically analyze the active records files in Rails applications to check if the data model satisfies some properties that we expect it to satisfy Approach: –Bounded SAT based verification –We automatically search for data model errors within a given scope

Data Model VerificationTranslator Data Model Properties Active Records Alloy Specification Alloy Analyzer Verified Counter-example data model instance

Data Model Verification Experiments We used two open source Rails applications in our experiments: –TRACKS: An application to manage things-to-do lists 6062 lines of code, 44 classes, 13 data model classes Alloy translation: 301 lines –Fat Free CRM: Customer Relations Management software lines of code, 54 classes, 20 data model classes Alloy translation: 1082 lines

Types of properties we checked Relationship cardinality –Is it possible to have two accounts for one user? Transitive relations –A book’s author is the same as the book’s edition’s author Deletion properties –Deleting a user does not create orphan orders We wrote 10 properties for TRACKS and 20 properties for Fat Free CRM

Data Model Verification Experiments Of the 30 properties we checked 7 of them failed For example, in TRACKS Note’s User can be different than Note’s Project’s User

Conclusions Web application dependability is a very important problem Using automated verification we can find and remove errors in web application before they are deployed In order to develop feasible automated verification techniques we exploit the MVC architecture and the principles of modularity, abstraction and separation of concerns At minimum, the developer has to specify the correctness properties (e.g. attack patterns) –In some cases, the developer may also need to specify desired behavior (e.g. navigation)

Future work Handle more concerns Maximize automation Mobile applications