HTML5 Security Realities Brad Hill, W3Conf: Practical standards for web professionals 21 -22 February 2013 San Francisco.

Slides:



Advertisements
Similar presentations
Web 2.0 Programming 1 © Tongji University, Computer Science and Technology. Web Web Programming Technology 2012.
Advertisements

Building Fast 3rd-Party Webapps O'Reilly Velocity Web Performance and Operations Conference 24 June Lessons.
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
EXtensible HyperText Markup Language Miruna Bădescu Finsiel Romania Copenhagen, 25 May 2004.
Cross Site Scripting (XSS)
What is code injection? Code injection is the exploitation of a computer bug that is caused by processing invalid data. Code injection can be used by.
The OWASP Foundation Web Application Security Host Apps Firewall Host Apps Database Host Web serverApp serverDB server Securing the.
Web Development & Design Foundations with XHTML
HI-TEC 2011 SQL Injection. Client’s Browser HTTP or HTTPS Web Server Apache or IIS HTML Forms CGI Scripts Database SQL Server or Oracle or MySQL ODBC.
Hands-on SQL Injection Attack and Defense HI-TEC July 21, 2013.
What is HTML5…?. ”…removes the need for plugins” ”…can handle multimedia directly” ”…enables rich, interactive clients” ”…enables advanced visual designs”
W3C Workshop on Web Services Mark Nottingham
HiveMind Distributed File Storage Using JavaScript Botnets Copyright 2013 Sean T. Malone.
Ideas to Layout Beginning web layout using Cascading Style Sheets (CSS). Basic ideas, practices, tools and resources for designing a tableless web site.
A really fairly simple guide to: mobile browser-based application development (part 1) Chris Greenhalgh G54UBI / Chris Greenhalgh
0 The Past, Present and Future of XSS Defense Jim Manico 2011 OWASP Brussels.
Copyright Justin C. Klein Keane HTML 5 Security Philadelphia OWASP August, 2013.
Using JavaScript in Linked Data Applications Oshani Seneviratne Oct 12, 2010.
OWASP Periodic Table of Vulnerabilities James Landis
I'll see your cross site scripting and raise you a Content Security Policy Lou Leone :: Rochester OWASP.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
An Evaluation of the Google Chrome Extension Security Architecture
Mitigating Malware Collin Jackson CS142 – Winter 2009.
EECS 354 Network Security Cross Site Scripting (XSS)
Blackbox Reversing of XSS Filters Alexander Sotirov ekoparty 2008.
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
COMPUTER TERMS PART 1. COOKIE A cookie is a small amount of data generated by a website and saved by your web browser. Its purpose is to remember information.
Security and JavaScript. Learning Objectives By the end of this lecture, you should be able to: – Describe what is meant by JavaScript’s same-origin security.
Subspace: Secure Cross-Domain Communication for Web Mashups In Proceedings of the 16th International World Wide Web Conference. (WWW), 2007 Collin Jackson,
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Workshop 3 Web Application Security Li Weichao March
Prevent Cross-Site Scripting (XSS) attack
CSCI 6962: Server-side Design and Programming Secure Web Programming.
BLUEPRINT: Robust Prevention of Cross-site Scripting Attacks for Existing Browsers Mike Ter Louw, V.N. Venkatakrishnan University of Illinois at Chicago.
Securing Web Applications. IE 7 significantly reduced attack surface against the browser and local machine…
.  Entertain  Inform  Educate  Blogs  Sell  Date  Gamble  Religion.
Project Proposal Interface Design Website Coding Website Testing & Launching Website Maintenance.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Krishna Mohan Koyya Glarimy Technology Services
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
Cross-Site Attacks James Walden Northern Kentucky University.
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 1 RubyJax Brent Morris/
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Cascading Style Sheets CSS. Source W3Schools
University of Central Florida The Postman Always Rings Twice: Attacking & Defending postMessage in HTML5 Websites Ankur Verma University of Central Florida,
Asstt. Prof Sonia Sharma Computer Dept 1 HTML ( Hypertext MarkUP Language ) HTML is the lingua franca for publishing hypertext on the World Wide Web.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Browser code isolation John Mitchell CS 155 Spring 2016.
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,
The OWASP Foundation OWASP XSS Remediation Cassia Martin Romain Gaucher April 7 th, 2011.
SECURE DEVELOPMENT. SEI CERT TOP 10 SECURE CODING PRACTICES Validate input Use strict compiler settings and resolve warnings Architect and design for.
Web Security (cont.) 1. Referral issues r HTTP referer (originally referrer) – HTTP header that designates calling resource  Page on which a link is.
Blackbox Reversing of XSS Filters
NodeJS Security Using PassportJS and HelmetJS:
An Introduction to Web Application Security
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Introduction to Silverlight
Less Known Web Application Vulnerabilities
Riding Someone Else’s Wave with CSRF
HTTP Security Headers Explained
Exploring DOM-Based Cross Site Attacks
HTTP Security Headers You Need To Know
Security and JavaScript
Cross-Site Scripting Attack (XSS)
Mike Ter Louw, V.N. Venkatakrishnan University of Illinois at Chicago
Presentation transcript:

HTML5 Security Realities Brad Hill, W3Conf: Practical standards for web professionals February 2013 San Francisco

“The reason that the Web browser is the principal entry point for malware is the number of choices that a browser offers up to whomever is at the other end. Evolving technologies like HTML5 promise to make this significantly worse.” – Dan Geer

In the next 30 minutes: Show you real code using new standards to: – Solve Script Injection Vulnerabilities – Build Secure Mashups HTML5 is a big step forward in security for the Web platform

Solving Script Injection

Script Injection, also known as Cross-Site Scripting or XSS, is the most common Web Application vulnerability. In 2007, WhiteHat estimated that 90% of sites were vulnerable.

XSS in a nutshell: If somebody else’s code gets to run in your WebApp, it’s not your WebApp anymore. + Same-Origin Policy = XSS anywhere on your domain is XSS everywhere on your domain.

“HTML5 broke my XSS filter!” Current defenses: Input filtering – Strip dangerous characters and tags from user data Output encoding – Encode user data so it isn’t treated as markup

YES. html5sec.org lists a dozen new XSS vectors in new tags and attributes in HTML5. But your filter was already broken.

1;--

XSS Filters Were Doomed Filters are a server-side attempt to simulate the client-side parser and execution environment. But… Every browser parser operated differently The algorithms were secret Every browser had proprietary features, tags and syntax Accepting bad markup was a feature

Generously coercing a shambling mound of line noise into an application is no longer a competitive feature.

By standardizing the technology for building Rich Web Applications, HTML5 began a fundamental shift in the security posture of the Web as a platform.

Proprietary platforms compete for developers by offering features. Open platform implementers compete for users by offering quality.

BACK TO SOLVING SCRIPT INJECTION And now,

New and Better Anti-XSS Approaches Even if we now have some hope of simulating the browser parser for HTML5… Not easy, definitely not future-proof. Misses client-only data flows. Why not get help from the client?

Content Security Policy HTTP header to enforce, in the client, a least- privilege environment for script and other content X-WebKit-CSP 6.0 X-Content-Security-Policy 10 (sandbox only)

Content-Security-Policy: default-src 'self'; object-src 'none'; img-src data:; script-src frame-src *.youtube.com; report-uri board.net/cspViolations.xyz

Content Security Policy 1.0 default-src Everything script-srcScripts object-srcPlugins style-srcCSS img-srcImages media-srcAudio + Video frame-srcFrame content font-srcFonts connect-srcScript-loaded content (e.g. XHR) sandboxSame as HTML5 iframe sandbox reporturiViolation reporting

The catch… CSP enforces code / data separation This means: NO inline script or css NO eval, even in libraries (can be disabled, but sacrifices many of the benefits of CSP)

function doSomething ()… Click Here!

function doSomething ()… Document.addEventListener(‘DOMContentLoader', function() { for var b in document.querySelectorAll('.clickme‘)) e.addEventListener('click', doSomething); }); Click Here!

Coming soon in CSP 1.1 Whitelisting of inline scripts and CSS More granular origins Better control of plugins and media types Control and reporting for reflected XSS filters META tag support policy/raw-file/tip/csp-specification.dev.html

Templating Templating is one of the oldest and most widely used Web application construction patterns. But it is a hive of XSS villainy because it has never been a first-class feature in the client.

HTML Templates New spec in progress in the WebApps WG: file/tip/spec/templates/index.htmlhttps://dvcs.w3.org/hg/webcomponents/raw- file/tip/spec/templates/index.html Declare templates as first-class client-side objects for increased performance, reduced XSS risk.

With CSP and a careful application architecture XSS can be solved today. In the near future it will be possible using more familiar and better performing idioms.

“HTML5 and CORS give new ways to bypass the Same-Origin Policy!” Secure Mashups

A “mashup” incorporates content from multiple origins under different administrative control. Today, more apps than not are authenticated mashups: ads, analytics, federated login How did we do this before HTML5?

Flash, with crossdomain.xml <allow-access-from domain=“

Jan’s Rule: “Give someone an ACL, and they’ll put in a *.”

A “*” in your master crossdomain.xml policy means your users’ information is vulnerable to any malicious SWF, anywhere on the Web

I can’t use Flash on iOS anyway… What about HTML-only methods?

example.com Browser example-2.com Same-Origin Loophole Origin=example.com <script src= (function( window, undefined ) {…

AKA – “JSONP” “JSON with padding” Returns JSON data “padded” with a call to the function you specified. You hope…it’s still script!

This pattern injects somebody else’s code into your application. Remember what the definition of XSS was?

W e can build it better. We have the technology.

Cross-Origin Resource Sharing (CORS) Voluntarily relax the Same-Origin Policy with an HTTP header to allow permissioned sharing on a resource-by-resource basis Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: someorigin.com

CORS Client Example var xhr = new XMLHttpRequest(); xhr.open(method, xDomainUrl, true); xhr.withCredentials = true; xhr.onload = function() { var responseText = xhr.responseText; validatedResponse = validate(responseText); }; xhr.onerror = function() { console.log('There was an error!'); }; xhr.send();

The difference: Script src gives you code you have no choice but toTRUST CORS gives you data you can VERIFY

What about the * in CORS? * cannot be used for a resource that supports credentials. * in Access-Control-Allow-Origin gives other origins only the same view they already have from their own server. Access-Control-Allow-Origin: * is actually one of the safest ways to use CORS!

What if you need data from somebody who doesn’t publish a CORS API?

sandboxed iframes and postMessage

trusted.mydomain.com/foo.html <iframe sandbox=“allow-scripts” src=“integration.mydomain.com/wrapLogin.html ”> By using a different domain name, many benefits of the sandbox can be achieved, even in browsers that don’t support it.

integration.mydomain.com/wrapLogin.html window.parent.postMessage(loginName, “trusted.mydomain.com”);

trusted.mydomain.com/foo.html window.addEventListener("message", receiveMessage, false); receiveMessage = function(event) { if(event.origin == “untrusted.mydomain.com”) { var data = sanitizeData(event.data); }

But wait, there’s more! What if you do this to your own code?

/papers/LeastPrivileges.pdf

Hackers HATE Him!!!! Reduce your Trusted Computing Base by 95% with this one simple HTML5 trick!!!

Summary: HTML5 HTML5 and the Open Web Platform are improving the security of the Web ecosystem. Rich Web Apps are not new, and HTML5 offers big security improvements compared to the proprietary plugin technologies it’s actually replacing.

Summary: Script Injection Script Injection, aka XSS, can be a solved problem with proper application architecture and new client-side technologies. Avoid incomplete server-side simulation, solve it directly in the client environment: – Content Security Policy – HTML Templates

Summary: Mashups Use CORS to get (and validate) data, not code Use iframes and postMessage to isolate legacy mashup APIs Treat your own code like a mashup: Use the Same-Origin Policy as a powerful privilege separation technique for secure application architecture in HTML5

Ongoing work in WebAppSec WG: Content Security Policy 1.1 User Interface Security to Kill Clickjacking Sub-Resource Integrity More important work underway in the Web Cryptography WG

Thank you! Questions? Brad Hill, W3Conf: Practical standards for web professionals February 2013 San Francisco