Automatic Web Security Unit Testing: XSS Vulnerability Detection Mahmoud Mohammadi, Bill Chu, Heather Richter, Emerson Murphy-Hill Presenter:

Slides:



Advertisements
Similar presentations
Chapter 25 Perl and CGI (Common Gateway Interface)
Advertisements

Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems © 2002, Predictive Systems.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
By Philipp Vogt, Florian Nentwich, Nenad Jovanovic, Engin Kirda, Christopher Kruegel, and Giovanni Vigna Network and Distributed System Security(NDSS ‘07)
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
Input Validation For Free Text Fields Project Members: Hagar Offer &Ran Mor Academic Advisor: Dr Gera Weiss Technical Advisors: Raffi Lipkin & Nadav Attias.
Information Technology Center Hany Abdelwahab Computer Specialist.
 Using Microsoft Expression Web you can: › Create Web pages and Web sites › Set what you site will look like as you design it › Add text, images, multimedia.
Secure Software Engineering: Input Vulnerabilities
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Prevent Cross-Site Scripting (XSS) attack
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
VEX: VETTING BROWSER EXTENSIONS FOR SECURITY VULNERABILITIES XIANG PAN.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
16-1 The World Wide Web The Web An infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that information.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Chapter 8 Cookies And Security JavaScript, Third Edition.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
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.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
EECS 354: Network Security Group Members: Patrick Wong Eric Chan Shira Schneidman Web Attacks Project: Detecting XSS and SQL Injection Vulnerabilities.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Section 10.1 Define scripting
Introduction to.
Group 18: Chris Hood Brett Poche
Module: Software Engineering of Web Applications
CSCE 548 Student Presentation Ryan Labrador
Unit 20 - Client Side Customisation of Web Pages
An Introduction to Web Application Security
In this session, you will learn to:
Topic: Python’s building blocks -> Variables, Values, and Types
“Under the hood”: Angry Birds Maze
Software Testing.
Security: Exploits & Countermeasures
Security: Exploits & Countermeasures
World Wide Web policy.
Static Detection of Cross-Site Scripting Vulnerabilities
Section 17.1 Section 17.2 Add an audio file using HTML
A Security Review Process for Existing Software Applications
Introduction to Scripting
Cross Sight scripting: Type-2
Intro to PHP & Variables
Dynamic Web Pages (Flash, JavaScript)
Chapter 27 WWW and HTTP.
Part of the Multilingual Web-LT Program
PHP: Security issues FdSc Module 109 Server side scripting and
WEB PROGRAMMING JavaScript.
CSC 495/583 Topics of Software Security Intro to Web Security
Topics Introduction Hardware and Software How Computers Store Data
T. Jumana Abu Shmais – AOU - Riyadh
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Tutorial 7 – Integrating Access With the Web and With Other Programs
Security: Exploits & Countermeasures
CS5123 Software Validation and Quality Assurance
Security: Exploits & Countermeasures
An Introduction to JavaScript
Security: Exploits & Countermeasures
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Security: Attacks & Countermeasures
Exploring DOM-Based Cross Site Attacks
Presentation transcript:

Automatic Web Security Unit Testing: XSS Vulnerability Detection Mahmoud Mohammadi, Bill Chu, Heather Richter, Emerson Murphy-Hill Presenter: Deepthi Gangala

Introduction Web Security Unit Testing Software Development Cycle Web application security is a branch of Information Security that deals specifically with security of websites, web applications and web services. Software Development Cycle Unit Testing Unit testing is a software development process in which the smallest testable parts of an application, called units, are individually and independently scrutinized for proper operation Software Development Cycle The systems development life cycle (SDLC), is a term used in systems engineering, information systems and software engineering to describe a process for planning, creating, testing, and deploying an information system.

Cross-site scripting (XSS) GET /log?s=01a4b8 Attacker injects malicious code into vulnerable web server Victim visits vulnerable web server Malicious code is served to victim by web server Malicious code executes on the victims with web server’s privileges

XSS Example <% String pid=(String)request.getParameter(“pid”);%> <% String x=(String)request.getParameter(“addr”);%> <a href=“javascript:void(0)” onclick=“action(<%=escapeHtml(pid)%>’);:>mylink</a> <p><%=escapeHtml(x)%>

Existing Approaches for XSS prevention: Templates or HandleBars Limitations: First, a template language covers a subset of available web technologies. Second, there are many web applications that do not use template languages at all. Third, type inference is not fully successful.

Approach Three Key Steps in the approach Unit Test Extraction Attack Evaluation Generation of Attack Strings

Vulnerability Model: variable x as tainted, if it is assigned a value from untrusted inputs such as request.getParameter(). a security sink as a Java statement generating output containing a tainted variable in JSP(can be easily identified as they are marked by tags). Encoder f is safe for context C means for all possible input x such that x contains unsafe characters in context C, f(x) doesn’t contain unsafe characters in context C (this implies f(x)!=x). Encoder f is vulnerable for a context C means there is an input x such that f(x)=x ( from the browser’s view), and x contains a JavaScript program that can be successfully executed in C .

Unit Test Extraction

Attack Evaluation The goal of attack evaluation is to assess whether the extracted unit test is vulnerable to any of the generated attack strings. JWebUnit features is used to test web page and check the result of invoked web page to verify whether each attack string generated is successful. Attack payload changes the title of the web page if it is successfully executed. So if a change in title is detected, then the attack string is successful.

Attack Evaluation

Attack Generation The goal of attack generation is to generate attack strings with JavaScript programs as input to the security unit tests. attack string is composed of pre-escaping characters, attack payload, and post-escaping characters substrings. Figure 5 shows an example of this pattern.

Attack Generation

An attack string can appear in one of three contexts: as part of attValue, part of content, or part of a JavaScript program. Attacks cannot be part of the ETag because it does not allow any attributes. These three options are refer to as attribute values, tag bodies and JavaScript. Attack strings must be generated for all three contexts.

Context Switching An attack string in either the attribute context or tag body context thus uses a sequence of pre-escaping characters to manipulate the browser to invoke the JavaScript interpreter. If the attack string is already in a JavaScript context, it uses a sequence of pre-escaping characters to insert the attack payload as an additional JavaScript statement. Figure 7 illustrates context switching using an example. Suppose an interpreter has already consumed characters t1t2t3 and currently is in context C1. The goal of attack string, t4t5…tn, is to change the context using the single quote character to indicate the end of an attribute value, followed by inserting a tag event key word (onclick) which switches to a JavaScript context. After that switch, a JavaScript program can be inserted

In the state machine for attack generation, states correspond to states of an interpreter. Starting states corresponds to the three contexts where attack scripts can be injected: attribute value, tag body, and JavaScript. The state machine is built with the objective of enumeration all possible transitions from a start state to a context where a JavaScript program can be executed. A token list is associated with each transition, representing possible input tokens that can take the interpreter from one state to another state along the path to the objective. Final states, indicated by small bold circles, represent completion of an attack string

An attack script is generated by traversing the state machine while appending tokens associate with transition link to the output string. The number of tokens in transition lists determines number of different combinations or attack vectors.

Attribute Value Context This part of the state machine considers the situation where an attack string is injected in the middle of a tag definition.

Attribute Value Context

Attack Generation State Machine

Tag Content Context This part of the state machine considers the situation where an attack string is injected in the middle of a tag body corresponding to content rule in XML grammar definition of 6. Table 3 summarizes all the states related to this scenario.

Tag Content Context

JavaScript Context An attacker will have to insert pre-escaping characters to end the current JavaScript statement and insert an attack statement. Tables 4 and 5 summarize states and transition labels for this attack category. In this paper two common types of attacks in the JavaScript context: the attack string is part of an expression on the right hand side of an assignment statement, or the attack string is part of an expression that is parameter to a function call.

JavaScript Context

Empirical Evaluation First this approach is tested on one module of an open source project iTrust, a medical record management system with over 112K lines of Java/JSP code. Several XSS vulnerabilities were found. These vulnerabilities all stem from using html escaping for JavaScript context. The experiments were performed on an iMac computer with a 2.8 GHz Intel core i7 with 8GB RAM. A total of 497 different attack strings can be generated based on the state machine in Figure 9. Generating and evaluating all these attack strings for a unit case takes 8.1 seconds of total execution time Randomly selecting 400 attack scripts from a well-known repository of successful XSS attacks reported by penetration testers, xssed.com. Selected scripts represent one percent of scripts in the repository. comparisons show 334 (83.5%) attack scripts corresponds exactly to at least one of the attack strings generated by the current approach.

Empirical Evaluation

Conclusion This paper talks about a unit test based approach to detect a large class of common cross-site scripting vulnerability caused by applying a wrong output encoder for a given application context. First the unit test approach can be easily integrated into integrated development environments and the software development process to detect security vulnerabilities early in the development. Most software developers would be able to detect and correct these problems without engaging security experts. This can save valuable security testing resources to focus on other types of vulnerabilities. Second this approach can be applied to all web applications as well as newer applications written in template languages. Third this approach has the potential to be applied to detect other types of injection attacks. Evaluation report shows that the approach can be applied efficiently to detect vulnerabilities in large open source applications. Empirical study suggests this approache has good coverage of possible attacks.

Questions?