I'll see your cross site scripting and raise you a Content Security Policy Lou Leone :: Rochester OWASP.

Slides:



Advertisements
Similar presentations
Building Fast 3rd-Party Webapps O'Reilly Velocity Web Performance and Operations Conference 24 June Lessons.
Advertisements

Protecting Browser State from Web Privacy Attacks Collin Jackson, Andrew Bortz, Dan Boneh, John Mitchell Stanford University.
Enabling Secure Internet Access with ISA Server
The OWASP Foundation Web Application Security Host Apps Firewall Host Apps Database Host Web serverApp serverDB server Securing the.
0 The Past, Present and Future of XSS Defense Jim Manico 2011 OWASP Brussels.
Pushing CSP to PROD Case Study of a Real-World Content- Security Policy Implementation.
17 th ACM CCS (October, 2010).  Introduction  Threat Model  Cross-Origin CSS Attacks  Example Attacks  Defenses  Experiment  Related Work 2 A Presentation.
Presented by Vaibhav Rastogi.  Advent of Web 2.0 and Mashups  Inclusion of untrusted third party content a necessity  Need to restrict the functionality.
An Evaluation of the Google Chrome Extension Security Architecture
Site and user security concerns for real time content serving Chris Mejia, IAB Sean Snider, Yahoo! Prabhakar Goyal, Microsoft.
Web Security Model CSE 591 – Security and Vulnerability Analysis Spring 2015 Adam Doupé Arizona State University
New Computer Security Threat - ClickJacking Ehab Ashary CS591-F2010 University of Colorado, Colorado Springs Dr. C.Edward Chow.
Javascript Document Object Model. How to use JavaScript  JavaScript can be embedded into your html pages in a couple of ways  in elements in both and.
Chapter 14 Introduction to HTML
WEB SECURITY WORKSHOP TEXSAW 2013 Presented by Joshua Hammond Prepared by Scott Hand.
Phu H. Phung Chalmers University of Technology JSTools’ 12 June 13, 2012, Beijing, China Joint work with Lieven Desmet (KU Leuven)
1 Subspace: Secure Cross Domain Communication for Web Mashups Collin Jackson and Helen J. Wang Mamadou H. Diallo.
Subspace: Secure Cross-Domain Communication for Web Mashups Collin Jackson Stanford University Helen J. Wang Microsoft Research ACM WWW, May, 2007 Presenter:
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)
D ATABASE S ECURITY Proposed by Abdulrahman Aldekhelallah University of Scranton – CS521 Spring2015.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Using HTML 5.  HTML 5 uses a standard method to embed audio into Web pages.  Prior to HTML 5, browser plug-ins or separate applications such as Windows.
Computer Concepts 2014 Chapter 7 The Web and .
4.1 JavaScript Introduction
Online Chapter 1 4 th Edition.  Review elements  Whitespace handling  Rule structure  Linking to an external style sheet  Alternate Style Sheets.
Ajax Basics The XMLHttpRequest Object. Ajax is…. Ajax is not…. Ajax is not a programming language. Ajax is not a programming language. Ajax is a methodology.
JavaScript & jQuery the missing manual Chapter 11
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
Prevent Cross-Site Scripting (XSS) attack
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
Using Styles and Style Sheets for Design
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Krishna Mohan Koyya Glarimy Technology Services
1 Internet Browsing Vulnerabilities and Security ECE4112 Final Lab Ye Yan Frank Park Scott Kim Neil Joshi.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Cross Site Integration “mashups” cross site scripting.
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 1 RubyJax Brent Morris/
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
XHTML By Trevor Adams. Topics Covered XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
audio video object Options: controls autoplay Need to define height and width Options: controls autoplay.
THE DEVIL IS IN THE (IMPLEMENTATION) DETAILS: AN EMPIRICAL ANALYSIS OF OAUTH SSO SYSTEMS SAN-TSAI SUN & KONSTANTIN BEZNOSOV PRESENTED BY: NAZISH KHAN COMPSCI.
University of Central Florida The Postman Always Rings Twice: Attacking & Defending postMessage in HTML5 Websites Ankur Verma University of Central Florida,
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
Safe browsing - is an ad-blocker extension enough? AIMILIOS TSOUVELEKAKIS IT-DI-CSO IT LIGHTNING TALK – 12/
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
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.
Objective: To describe the evolution of the Internet and the Web. Explain the need for web standards. Describe universal design. Identify benefits of accessible.
Writing secure Flex applications  MXML tags with security restrictions  Disabling viewSourceURL  Remove sensitive information from SWF files  Input.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
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,
Will New HTTP headers save us? John Wilander, OWASP/Omegapoint, IBWAS’10.
The Postman Always Rings Twice: Attacking and Defending postMessage in HTML5 Websites Paper by Sooel Son and Vitaly Shmatikov, The University of Texas.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
NodeJS Security Using PassportJS and HelmetJS:
Data Virtualization Tutorial… CORS and CIS
Host of Troubles : Multiple Host Ambiguities in HTTP Implementations
Topic: Java Security Models
Browser code isolation
WWW安全 國立暨南國際大學 資訊管理學系 陳彥錚.
HTTP Security Headers Explained
Web Programming and Design
HTTP Security Headers You Need To Know
Presentation transcript:

I'll see your cross site scripting and raise you a Content Security Policy Lou Leone :: Rochester OWASP

What Is It Why How Does It Work What Browsers Support It How To Use It Default CSP Restrictions CSP Policy Directives CSP Violation Reports Examples How To Test Unintended Consequences Resources

Mozilla’s Content Security Policy is a proposed standard providing a contract between web pages and browsers to control the locations from which browsers will load content Declarative in nature and provides a fine granularity of content inclusion control Designed to be backwards compatible so as not to break browsers that don’t support it Provides reporting of violations to the appropriate issuing domains

Motivated by the endless parade of cross site scripting and “clickjacking” exploits that have arisen over the last decade Designed to mitigate: Cross Site Scripting exploits (XSS) “Clickjacking” Packet sniffing attacks (specifically by eliminating inadvertent use of unencrypted data transmission protocols)

Prevents XSS and “Clickjacking” by controlling the domains from which Javascript can be loaded, blocking the ability for exploits to force the loading of malicious Javascript (Think whitelist versus blacklist) It also prevents link injection Reduces packet sniffing exposure by forcing content to be exchanged only via HTTPS

At present, only FireFox 4 and up support CSP It’s rather hard to glean this information from googling and what not, but there’s a great test page (link at end of presentation) and the following tip versions were verified as failing as of 02 May 2012: Google Chrome Mac Safari Opera Microsoft IE (won’t even run the JS test…)

Understand the default restrictions browsers honoring CSP will enact for CSP enabled web pages Understand how multiple policies are interpreted by the browser 3 basic parts to implementing a CSP: Policy Delivery Policy Directives Violation Reports

No inline Javascript - all Javascript must be in external files No Javascript URLs - use of “javascript: …” is forbidden Element event handling attributes are disabled - use element.addEventListener() instead eval() is disabled - setTimeout() and setInterval() must be called with functions only - no setInterval(“location=‘yourehacked.org’", 10000) The Function() constructor is disabled - use the function operator or function statement data: URIs are disabled except for images - may be overridden in the X-Content-Security-Policy header XBL binding must use the chrome: or resource: URI specifier policy-uri and report-uri must refer to the issuing domain’s host

CSP follows a policy of “least privilege” which means that when multiple policies are present in the content being loaded by the browser, the browser will enforce the most restrictive intersection of the policies received All policies must allow an action to be taken for it to be executed The following issue is being debated: “What should happen when multiple instances of the same directive but with different values occur within a single policy header or meta element, i.e. should they be combined or intersected as they are successively parsed?”

Browsers are informed of a CSP by one of two methods: X-Content-Security-Policy Response Header Specifying policy in the header is preferred over the meta element means and takes precedence when both are specified HTML Element The header entry or meta element contains the policy directives for the issuing page

Policy directives provide for fine-grained content inclusions rules: – frame-ancestors – report-uri – policy-uri – options – script-nonce (proposed) – sandbox (proposed) – default-src – script-src – object-src – img-src – media-src – style-src – frame-src – font-src – xhr-src

default-src Specifies the default safe source domains for all types except frame-ancestors and where not otherwise declared script-src Specifies the safe domains for script element “src” attributes object-src Specifies the safe domains for object element “data” attributes, embed element “src” attributes, and applet element “code”/”archive” attributes

img-src Specifies the safe domains for img element “src” attributes, CSS property “url()” and “image()” values, and the “href” value of or elements media-src Specifies the safe domains for media and audio element “src” attributes style-src Specifies the safe domains for the “href” value of element or directives

frame-src Specifies the safe domains for iframe element “src” attributes font-src Specifies the safe domains CSS rule “src” attributes xhr-src Specifies the safe domains XMLHttpRequest objects are able to communicate with (this appears to be a relaxation of the same origin policy currently honored by XMLHttpRequest objects)

frame-ancestors Specifies domains from which content will be able to utilize the, or elements report-uri Specifies the URL for posting the JSON violation report data policy-uri Specifies a URL to load a policy file from and can only be used when no other policy directives are specified using the header or meta element policy delivery mechanism

options Provides a means of relaxing the default CSP restrictions script-nonce (proposed) Provides a means to allow inline Javascript to execute sandbox (proposed) Provides a sandbox policy with the same syntax and semantics as the iframe element “sandbox” attribute defined in HTML5

Limiting content to the issuing domain: X-Content-Security-Policy: default-src 'self' Allowing images from anywhere, plugin content from a list of trusted providers, and scripts from a specific domain: X-Content-Security-Policy: default-src 'self'; img-src *; \ object-src media1.example.com media2.example.com *.cdn.example.com; \ script-src trustedscripts.example.com Globally denying all third-party scripts and disallowing third-party media by using separate headers: X-Content-Security-Policy: default-src *; script-src 'self‘ X-Content-Security-Policy: default-src *; script-src 'self'; media-src 'self' Ensure all content is loaded over TLS: X-Content-Security-Policy: default-src

When using the report-uri directive to specify a delivery URL for violation reports, a code-behind to handle the incoming reports must be implemented Violation reports sent to the delivery URL via an HTTP POST of JSON formatted data The JSON contains the following: request : Specifies the HTTP request of the resource whose policy was violated including method/verb, URI and HTTP version request-headers : Specifies the HTTP request headers sent with the request for the protected resource whose policy was violated blocked-uri : Specifies the URI of the resource that was prevented from loading due to the policy violation violated-directive : Specifies which policy directive that was violated original-policy : Specifies the original policies as received by the user-agent and comma separating them if multiple were received Be sure to follow secure programming practices when implementing the code behind the report delivery URL

For the policies specified: Inject content that would violate the policies Test in browsers supporting both CSP and not supporting CSP Verify content is not loaded/executed using tracing tools such as Fiddler/Wireshark and client-side debuggers such as FireBug If enforcing HTTPS, verify content is loaded only over secure protocols using a tool such as Wireshark Verify your reporting code is reporting the correct information from the violations (also perform whatever secure coding tests you would for a normal web application) When multiple browsers support CSP, be sure to test policies across supporting browsers

Consider: A page provides a script-src policy to allow the inclusion of Javascript from a 3 rd party who does not issue a CSP and has not been included in your CSP. The 3 rd party’s Javascript includes other Javascript files from the 3 rd party’s domain. At a later date the 3 rd party changes where their included Javascript is being loaded from to a domain not specified in the original CSP. The 3 rd party’s functionality is now broken.

Mozilla’s overview: _Policy _Policy W3C’s unofficial draft: file/tip/csp-specification.dev.html file/tip/csp-specification.dev.html Demo scripts and test page: policy/demo.cgi policy/demo.cgi