Mike Ter Louw V.N. Venkatakrishnan University of Illinois at Chicago

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Ben Livshits and Úlfar Erlingsson Microsoft Research.
Cross Site Scripting (XSS)
Appeared in 30 th IEEE Symposium on Security and Privacy, May Authors: Mike Ter Louw and V.N. Venkatakrishnan Dept. of Computer Science: University.
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
HTTP Request/Response Process 1.Enter URL ( in your browser’s address bar. 2.Your browser uses DNS to look up IP address of server.com.
0 The Past, Present and Future of XSS Defense Jim Manico 2011 OWASP Brussels.
Developing a Web Site: Links Using a link is a quicker way to access information at the bottom of a Web page than scrolling down A user can select a link.
Document Object Model (DOM) JavaScript manipulation of the DOM.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
WEB BROWSER SECURITY By Robert Sellers Brian Bauer.
1 Yinzhi Cao, Zhichun Li *, Vaibhav Rastogi, Yan Chen, and Xitao Wen Labs of Internet Security and Technology Northwestern University * NEC Labs America.
The XSS Files Find, Exploit, and Eliminate. Josh Little Security Engineer at global vertical market business intelligence company. 9 years in application.
An Evaluation of the Google Chrome Extension Security Architecture
Blackbox Reversing of XSS Filters Alexander Sotirov ekoparty 2008.
1 Chapter 12 Working With Access 2000 on the Internet.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
1 Document Structure Integrity: A Robust Basis for Cross-Site Scripting Defense Prateek Saxena UC Berkeley Yacin Nadji Illinois Institute Of Technology.
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Chapter 14 Introduction to HTML
D ATABASE S ECURITY Proposed by Abdulrahman Aldekhelallah University of Scranton – CS521 Spring2015.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
4.1 JavaScript Introduction
Prevent Cross-Site Scripting (XSS) attack
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
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.
BLUEPRINT: Robust Prevention of Cross-site Scripting Attacks for Existing Browsers Mike Ter Louw, V.N. Venkatakrishnan University of Illinois at Chicago.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
Programming in HTML.  Programming Language  Used to design/create web pages  Hyper Text Markup Language  Markup Language  Series of Markup tags 
Preventing Web Application Injections with Complementary Character Coding Raymond Mui Phyllis Frankl Polytechnic Institute of NYU Presented at ESORICS.
XSS-GUARD : Precise Dynamic Prevention of Cross Site Scripting (XSS) Attacks Prithvi Bisht ( Joint work with : V.N. Venkatakrishnan.
CSC-682 Cryptography & Computer Security Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Pompi Rotaru Based on an article.
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 1 RubyJax Brent Morris/
XHTML By Trevor Adams. Topics Covered XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)
Session I Chapter 1 - Introduction to Web Development
Overview Web Session 3 Matakuliah: Web Database Tahun: 2008.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
High Points CSCI 1710 Fall The Internet Packet switching Arpanet Cold War.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Session 1 Chapter 1 - Introduction to Web Development ITI 133: HTML5 Desktop and Mobile Level I
Introduction to HTML. _______________________________________________________________________________________________________________ 2 Outline Key issues.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
Trevor Jim Nikhil Swamy Michael Hicks Defeating Script Injection Attacks with Browser-Enforced Embedded Policies Jason FroehlichSeptember 24, 2008.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
By Collin Donaldson. Hacking is only legal under the following circumstances: 1.You hack (penetration test) a device/network you own. 2.You gain explicit,
DHTML.
Google’s Gruyere1 : An XSS Example Presented by: Terry Gregory
Blackbox Reversing of XSS Filters
An Introduction to Web Application Security
Web Technologies Computing Science Thompson Rivers University
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Static Detection of Cross-Site Scripting Vulnerabilities
High Points CSCI 1710 Spring 2016.
BrowserShield: Vulnerability-Driven Filtering of Dynamic HTML
Document Object Model (DOM): Objects and Collections
Essentials of Web Pages
High Points CSCI 1710 Fall 2017.
HTML5 Level I Session I Chapter 1 - Introduction to Web Development
Web Technologies Computing Science Thompson Rivers University
Exploring DOM-Based Cross Site Attacks
Mike Ter Louw, V.N. Venkatakrishnan University of Illinois at Chicago
High Points CSCI 1210.
Presentation transcript:

Mike Ter Louw V.N. Venkatakrishnan University of Illinois at Chicago BLUEPRINT: Robust Prevention of Cross-site Scripting Attacks for Existing Browsers Mike Ter Louw V.N. Venkatakrishnan University of Illinois at Chicago

Outline Intro to Cross-site Scripting Objective Approach Technical details Evaluation Related work

Cross-site scripting (XSS) A widespread web application vulnerability In the last few weeks… Time magazine “Top 100 influential people” poll defaced by XSS (Apr 2009) Twitter XSS worm (Apr 2009) McAfee web site attacked (May 2009) The #1 threat on the Internet (OWASP)

Problem: Malicious user created content! Benign comment “Pete is…” Malicious comment “<script>doEvil()</script>”

Our Objective To develop a robust defense for cross-site scripting attacks

Typical Web Application Goals Allow user created content to be expressive, containing rich HTML content Format text (<b>bold</b>, <i>italics</i>) Hyperlinks (<a href=“http://g.com”>…</a>) Embedded images Prevent scripts in user created content Today’s web browsers / standards do not easily facilitate these goals to be met simultaneously

Content Isolation User-created content should always be treated as “data”, never as “code” Need to isolate user created content as “data only” Trying to talk about hypertext isolation here.

Content Isolation for Browsers Content Isolation can be achieved for future browsers Requires changes to standards and browser parser implementations Standards / Browsers’ revision cycles may take several years Today’s browsers continue to remain vulnerable to XSS in the near term

Our Goal Construct a robust defense for cross-site scripting attacks that permits rich HTML content works on today’s browsers configured to default settings without requiring changes of any form, including patches, plug-ins, add-ons, etc.

Most popular defense: Content filtering Involves sanitization of untrusted HTML by removing script content Mainly done using regular expressions / parsing HTML Absence of strong isolation facilities for HTML has made content filtering the current main line of defense

Problem with Content Filtering The web application’s interpretation of sanitized content may differ from the browser’s interpretation Example: +ADw-SCRIPT+AD4-attack(); Web Application’s understanding : raw text Browser’s understanding: “<SCRIPT>attack();”

The parsing “gap” Server intended parse tree Browser generated Parse Tree div text script div text XSS Cheat Sheet provides approx. 100 examples of such browser “quirks”

Our Approach: Reproduce on Browser Server intended parse tree of untrusted content div text div text Challenge : Parsers on existing browsers are unreliable

The Blueprint Approach Take control content interpretation process on the browser Avoid untrusted content parsing by browser No parsing of untrusted content by browser No scripts identified in untrusted content! Robust XSS Prevention

High level overview Generate a parse tree of untrusted content on the server Remove script content by applying whitelist of known-static content types Automatically generate a (trusted) JavaScript program to reconstruct this parse tree on the browser

Approach Overview HTML parse tree via document.createElement() et al. Javascript DOM API provides fine grained control needed to construct parse tree HTML parse tree via document.createElement() et al.

Problem: Transporting data without invoking browser’s parser Parse tree is constructed using both JavaScript code and data Code constructs various tree nodes (e.g. <div>) Data that annotates tree nodes (e.g. text content) Exposing raw data to browser parser may lead to unpredictable behavior Our Solution: Encode data using safe alphabet E.g. “a-z” transport encoded data to the JavaScript interpreter

Transporting data Text node String variable Plain text HTML parse tree via document. createElement() et al.

DOM API used createElement() createTextNode() getElementById() document. createElement() createTextNode() getElementById() element. appendChild() insertBefore() parentNode() removeChild() setAttribute() style[ ] style.setExpression()

Instrumenting web application with Blueprint <?php foreach ($comments as $comment): ?> <li><?php echo($comment); ?></li> <?php endforeach; ?> <li><?php $model = Blueprint::cxPCData($comment); echo($model); ?></li>

Transformed web application output

XSS Vector II: Cascading Style Sheets

CSS without XSS Use style object to apply style rules element.style['width'] = decode( untrusted ); Dynamic properties not allowed by whitelist element.style['behavior'] = … element.style['-moz-binding'] = …

CSS expression vector Any “static” property can be promoted to dynamic via expression() syntax element.style[“width”] = “expression( attack())”; Threat exists only on Internet Explorer IE has no DOM interface to directly force static value

Protection against CSS expressions Use setExpression( … ) to apply style rules Forces all CSS rules to be dynamic Trusted script invoked to retrieve property value Script looks up untrusted value in array, then returns it Returned value observed to be static Evaluated unobfuscated expression() for all allowed CSS properties

XSS vector III: Uniform Resource Identifiers (URI)

URI http://www.example.com/a.html?param#a URI scheme indicates static / dynamic nature Static: http:, https:, ftp:, mailto: Dynamic: javascript: No direct interface to URI parser to enforce a particular (whitelisted) scheme We use a 3-tiered defense

Evaluation

Evaluation Effectiveness at preventing XSS attacks on existing browsers Compatibility with common use cases Performance overhead on server and browser

Browser evaluation Chrome 1 Firefox 3 Firefox 2 IExplorer 7 8 browsers tested Total over 96% market share of browsers in active use Chrome 1 Firefox 3 Firefox 2 IExplorer 7 Internet Explorer 6 Opera 9.6 Safari 3.2 Safari 3.1

Defense effectiveness XSS Cheat Sheet [Ha09] 94 XSS attack examples Designed to target server-side defenses Embedded in several syntactic contexts Developed automated test platform Identified which attacks successful on which browser Evaluated defense effectiveness All 94 attacks successfully defended on all 8 evaluated browsers

Compatibility Modified source code for two popular web applications: WordPress MediaWiki Modified output of two popular websites NY Times blog Slashdot.org

WordPress (compatibility) Added protection for 3 low integrity outputs (per user comment to blog article) Name (plain text) Website link (anchor element) Comment body (mixed HTML) Allows testing of pages with hundreds of (relatively simple) models Tested real-world blogs, 23—516 comments No negative compatibility impact observed

MediaWiki (compatibility) Added protection for 2 low integrity outputs Article (i.e., web page) title Article content Allows testing of large, complex models Tested “Featured” article from Wikipedia Content rendered very faithfully to original Problems: <imagemap> not in whitelist Relocate trusted script

Performance overhead measurements Server page generation latency Browser memory overhead Browser page rendering latency Combined effect of server and browser latencies

WordPress page generation latency Measured significant overhead Partly due to redundant content filter (KSES)

MediaWiki page generation latency Better performance than WordPress Redundant intermediate HTML stage

Client memory overhead Minor overhead

WordPress page rendering latency

MediaWiki page rendering latency

User experience impact of combined latencies Tested with Firefox 2 (mid-road performance) WordPress with 100 blog comments Low perception of delays for common case

Related Work Server-side (XSS-Guard, NeatHTML) Prevent injected scripts in final output Vulnerable to attacks exploiting parsing differences Client-side (NoMoXSS, Noxes) Identification and prevention of data leaks Cannot detect XSS within same origin Black box / proxy (XSS-DS, Taint inference) Server: Detect and prevent reflected scripts Client: Detect and prevent data leaks

Related work (cont.) Server and browser collaboration (BEEP, DSI, Noncespaces) Server: Identify policy regions and declare policies Client: Enforce policies over policy regions Require browser changes Systems supporting benign scripts in user-created content Caja, Web Sandbox, Facebook Complimentary to our approach

Conclusion Cross-site scripting attacks can be prevented entirely if browsers and web applications can come to a common understanding of the structure of untrusted content Blueprint faciliates this goal and provides a novel defense for XSS Project page: http://www.sisl.rites.uic.edu/blueprint

References [Ha09] Hansen, Robert. XSS Cheat Sheet [Di07] Di Paola, Stefano. Preventing XSS with Data Binding

XSS Detail Challenge for attacker: Embed content the browser will interpret as script Many vectors Script tags <script> attack(); </script> Script attributes: onmousemove=“attack();” CSS Style rules: “width: expression( attack() );” URI: src=“javascript:void attack()”

Encoding Search engine optimization (SEO) Screen readers View source Solutions: Less destructive encoding Modify reader Add feature to browser

Dynamic attacks UCC added to a page dynamically must also be protected Current implementation requires remote procedure call (via XHR / AJAX) to request model Blueprint can ensure a base document free of user-embedded scripts Trusted code must then take precautions to maintain security

Whitelist Whitelist can be site-specific Whitelist can be grown, gradually adding content known to be static Used off-the-shelf whitelist from HTMLPurifier

URI Defense 3-tiered defense: 1. Character-level whitelist Only allow syntactically-inert untrusted chars 2. Parse behavior sensing a.protocol DOM property [Di07] Assumes URI parsing same for all contexts a.href, img.src, url() 3. Impact mitigation Rewrite URI pointing to redirection service Attacks execute in different origin, void of sensitive data

Eliminate dependency on browser parser Transform user-created content into static content models on web server Model reflects approved content parse tree Propagate static content models into JavaScript interpreter of web browser Reconstruct server-approved parse tree using client-side model interpreter

Create static content model Parse untrusted HTML Prune resulting parse tree in accordance with whitelist of known-static node types Serialize parse tree into stream of benign data characters Wrap in <code> … </code> tags Attach trusted script for invoking model interpreter

Model interpreter Interprets model as stream of declarative statements Uses reliable DOM API to generate content document.createElement( … ) element.appendChild( … ) Enforces server-intended parse tree in browser