Blackbox Reversing of XSS Filters



Similar documents
CSE598i - Web 2.0 Security OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities

Cross Site Scripting Prevention

Input Validation Vulnerabilities, Encoded Attack Vectors and Mitigations OWASP. The OWASP Foundation. Marco Morana & Scott Nusbaum

Still Aren't Doing. Frank Kim

Web-Application Security

Detect and Sanitise Encoded Cross-Site Scripting and SQL Injection Attack Strings Using a Hash Map

What about MongoDB? can req.body.input 0; var date = new Date(); do {curdate = new Date();} while(curdate-date<10000)

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

Universal XSS via IE8s XSS Filters

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

Check list for web developers

(WAPT) Web Application Penetration Testing

Revisiting SQL Injection Will we ever get it right? Michael Sutton, Security Evangelist

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

Document Structure Integrity: A Robust Basis for Cross-Site Scripting Defense

Cross-Site Scripting

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

Adobe Systems Incorporated

Web Application Firewalls: What the vendors do NOT want you to know SHAKACON III

A Server and Browser-Transparent CSRF Defense for Web 2.0 Applications. Slides by Connor Schnaith

Institutionen för datavetenskap

10CS73:Web Programming

Complete Cross-site Scripting Walkthrough

Application Security Testing. Erez Metula (CISSP), Founder Application Security Expert

Acunetix Website Audit. 5 November, Developer Report. Generated by Acunetix WVS Reporter (v8.0 Build )

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

Chapter 1 Web Application (In)security 1

Network Security Web Security

The Top Web Application Attacks: Are you vulnerable?

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

HTML5. Eoin Keary CTO BCC Risk Advisory.

Web Application Worms & Browser Insecurity

Project 2: Web Security Pitfalls

Bypassing Web Application Firewalls (WAFs) Ing. Pavol Lupták, CISSP, CEH Lead Security Consultant

XSS Lightsabre techniques. using Hackvertor

A Tale of the Weaknesses of Current Client-Side XSS Filtering

Finding and Preventing Cross- Site Request Forgery. Tom Gallagher Security Test Lead, Microsoft

Enterprise Application Security Workshop Series

Security Model for the Client-Side Web Application Environments

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

XSS PROTECTION CHEATSHEET FOR DEVELOPERS V1.0. Author of OWASP Xenotix XSS Exploit Framework opensecurity.in

Penetration Testing with Kali Linux

Relax Everybody: HTML5 Is Securer Than You Think

Hack-proof Your Drupal App. Key Habits of Secure Drupal Coding

Attacks on Clients: Dynamic Content & XSS

Developing ASP.NET MVC 4 Web Applications MOC 20486

CROSS-SITE SCRIPTING BROWSERS PROTECTION ANALYSIS

The Dark Side of Ajax. Jacob West Fortify Software

National Information Security Group The Top Web Application Hack Attacks. Danny Allan Director, Security Research

Security Research Advisory IBM inotes 9 Active Content Filtering Bypass

Hack Yourself First. Troy troyhunt.com

1 Web Application Firewalls implementations, common problems and vulnerabilities

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

PST_WEBZINE_0X04. How to solve XSS and mix user's HTML/JavaScript code with your content with just one script

Web Application Security

Bug Report. Date: March 19, 2011 Reporter: Chris Jarabek

Finding XSS in Real World

Web Application Guidelines

Smashing Web Apps Applying Fuzzing to Web Applications and Web Services. Michael Sutton, Security Evangelist

NoSQL, But Even Less Security Bryan Sullivan, Senior Security Researcher, Adobe Secure Software Engineering Team

Web Application Security

Web and Security 1 / 40

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

Finding Your Way in Testing Jungle. A Learning Approach to Web Security Testing.

Integrating Web Application Security into the IT Curriculum

SECURE APPLICATION DEVELOPMENT CODING POLICY OCIO TABLE OF CONTENTS

Web Application Security

Team Members: Christopher Copper Philip Eittreim Jeremiah Jekich Andrew Reisdorph. Client: Brian Krzys

Sichere Webanwendungen mit Java

WEB ATTACKS AND COUNTERMEASURES

Introduction to Computer Security

Pwning Intranets with HTML5

The Image that called me

Developing ASP.NET MVC 4 Web Applications

Hacking Web Apps. Detecting and Preventing Web Application Security Problems. Jorge Blanco Alcover. Mike Shema. Technical Editor SYNGRESS

Client vs. Server Implementations of Mitigating XSS Security Threats on Web Applications

Web Application Firewalls: What the vendors do NOT want you to know. The OWASP Foundation

Protection, Usability and Improvements in Reflected XSS Filters

Website Report: To-Do Tasks: 0. Speed SEO SCORE: 73 / 100. Load time: 0.268s Kilobytes: 1 HTTP Requests: 0

Step into the Future: HTML5 and its Impact on SSL VPNs

Are AJAX Applications Vulnerable to Hack Attacks?

Website Report: To-Do Tasks: 11 SEO SCORE: 79 / 100. Missing heading tag: H5. Missing heading tag: H6

Software Assurance Tools: Web Application Security Scanner Functional Specification Version 1.0

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

Web application security: Testing for vulnerabilities

How To Fix A Web Application Security Vulnerability

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Practical Exploitation Using A Malicious Service Set Identifier (SSID)

Secure Coding. External App Integrations. Tim Bach Product Security Engineer salesforce.com. Astha Singhal Product Security Engineer salesforce.

How To Protect A Web Application From Attack From A Trusted Environment

Transcription:

Blackbox Reversing of XSS Filters Alexander Sotirov alex@sotirov.net

Introduction Web applications are the future Reversing web apps blackbox reversing very different environment and tools Cross-site scripting (XSS) the strcpy of web app development reversing and bypassing XSS filters

Overview User generated content and Web 2.0 Implementing XSS filters Reversing XSS filters XSS in Facebook

Part I User generated content and Web 2.0

Web 2.0 User generated content APIs Mashups Aggregation of untrusted content Significantly increased attack surface

User generated content Text Plaintext Lightweight markup (BBcode, Wikipedia) Limited HTML Full HTML and JavaScript Images, sound, video Flash

Attacker generated content Social networking Samy s MySpace worm multiple Orkut worms, stealing bank info Webmail Hotmail and Yahoo Mail cross-site scripting worm written by SkyLined in 2002 many SquirrelMail cross-site scripting bugs Blogs hacking WordPress with XSS

Cross site scripting (XSS) Request: http://www.example.com/?name=<script>alert('xss')</script> Response: <html> <body> <p>hello <script>alert('xss')</script></p> </body> </html>

Web security model Same origin policy Prevents scripts from one domain from manipulating documents loaded from other domains Cross site scripting allows us to execute arbitrary scripts on a page loaded from another domain

What can XSS do? Stealing data from web pages Capturing keystrokes on a web page Stealing authentication cookies Arbitrary HTTP requests with XMLHttpRequest

Part II Implementing XSS filters

XSS filters Goal: Remove all scripts from untrusted HTML Challenges: Many HTML features that allow scripting Proprietary extensions to HTML Parsing invalid HTML Browser bugs

Features that allow scripting Script tags <script src="http://www.example.com/xss.js"> Event handler attributes <body onload="alert('xss')"> CSS <p style="background:url('javascript:alert(1)')"> URLs <img src="javascript:alert('xss')">

Proprietary extensions to HTML XML data islands (IE) <xml src="http://www.example.com/xss.xml" id="x"> <span datasrc="#x" datafld="c" dataformatas="html"> JavaScript expressions in attribute (NS4) <p id="&{alert('xss')}"> Conditional comments (IE) <!--[if gte IE 4]> <script>alert('xss')</script> <![endif]-->

Parsing invalid HTML <<scr\0ipt/src=http://xss.com/xss.js></script extra '<' before opening tag NULL byte inside tag name '/' separator between tag and attribute no quotes around attribute value missing '>' in closing tag Browser behavior is not documented or standardized. IE7 parses this as: <script src="http://xss.com/xss.js"></script>

Browser bugs Invalid UTF8 handling in Internet Explorer 6 <body foo="\xc0" bar=" onload=alert(1);//"> Firefox and IE7: <body foo="?" bar=" onload=alert(1);//"> IE6: <body foo="? bar=" onload=alert(1);//"> Attribute parsing in Firefox < 2.0.0.2 <body onload!#$%&()*~+-_.,:;?@[/ \]^`=alert("xss")>

Implementing XSS filters String matching filters HTML DOM parsers Canonicalization Whitelisting

String matching filters Remove all script tags: s/<script>//g; Bypasses: Invalid HTML accepted by browsers Encoding of attribute values and URLs Using the filter against itself: <scr<script>ipt> Incomplete blacklists

HTML DOM parsers <body onload="alert(1)"> <script>alert(2)</script> <p>hello</p> </body>

Canonicalization 1. Build a DOM tree from the input stream handle invalid UTF8 sequences Apply XSS filters to the DOM tree Output the DOM tree in a canonical form escape special characters add closing tags where necessary

Whitelisting Blacklisting remove known bad tags and attributes must be 100% complete to be safe Whitelisting allow only known safe tags and attributes safer than blacklisting

Part III Reversing XSS filters

Reversing XSS filters Remote web applications no access to source code or binaries Fuzzing limited by bandwidth and request latency draws attention Blackbox reversing send input and inspect the output build a filter model based on its behavior

Iterative model generation 1. Build an initial model of the filter 2. Generate a test case 3. Send test case and inspect the result 4. Update the model 5. Go to step 2

Example of parser reversing Test case: (1..0xFF).each { x data << "<p #{x.chr}a=''></p>" } Results: whitespace regexp [\x08\t\r\n "'/]+ attribute name regexp [a-za-z0-9:-_]+

refltr.rb Framework for XSS filter reversing run a set of tests against a web application store the results manual analysis of the output result diffing Application modules abstract application specific details sending data, result parsing, error detection Test modules test generation functions

Using the model Grammar based analysis build a grammar for the filter output build a grammar for the browser parser find a valid sentence in both grammars that includes a <script> tag Reimplement the filter and fuzz it locally

Part IV XSS in Facebook

Facebook platform Third party applications application pages content in user profiles message and wall post attachments FBML HTML with a few restrictions limited style sheet and scripting support FBJS sandboxed JavaScript

FBML processing GET /funapp/foo.html GET /foo.html browser apps.facebook.com funapp.example.com HTML FBML Facebook serves as a proxy for application content FBML processing: special FBML tags are replaced with HTML non-supported HTML tags are removed scripts are sandboxed

Reversing the FBML parser refltr.rb HTML apache write test case in /var/www FBML apps.facebook.com HTML DOM parser Accepts and fixes invalid input Canonicalized output Whitelist of tags, blacklist of attributes

Facebook XSS Invalid UTF8 sequences input is parsed as ASCII HTTP response headers specify UTF8 encoding affects only IE6 ode: img src=" " foo="\xc0" bar="onload=alert(1);//"> eported and fixed in February.

This is where I drop the 0day Attribute name parsing mismatch between Facebook and Firefox parsers affects only Firefox < 2.0.0.2 ode: img src=" " onload:="alert(1)"> ot reported, Facebook is still vulnerable.

Facebook Demo

Part V Conclusion

Conclusion Web 2.0 sites are totally screwed broken web security model undocumented browser behavior no programming language support Blackbox reversing the only way to reverse most web apps we need better tools and automation

Questions? alex@sotirov.net