32
Secure Mashups Kris Zyp Introduction

Secure Mashups

  • Upload
    kriszyp

  • View
    2.106

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Secure Mashups

Secure MashupsKris Zyp

Introduction

Page 2: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Interconnectedness

•Web continues to grow in interconnectedness of data

Page 3: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Overview

•More services and data sources

•More consumers want utilize this services

•Tools

-ADsafe

-Caja

-dojox.secure

Page 4: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Techniques of mashups

•Server Side Mashup

Page 5: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Techniques of mashups

•Client Side Mashup

Page 6: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Trust between mashup participants

•Exploit between participants

-Consumer gaining excess privileges

-Services exploiting Consumers

Page 7: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Server Side Mashups

•Public Content - Easy

•Protected Content - Authorization necessary

Page 8: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

OAuth

Page 9: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Client Side Mashups

•Directly utilize broker (the browser)

•Direct communication

•Exploits:

-Cross site scripting

-Cross site request forgery

Page 10: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Providing services for mashups

•Publicly accessible resources are simple, provide as many transports as possible

•Protected resources more complicated

Page 11: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Services protecting resources

•Authentication and authorization MUST be differentiated

•Cross site request forgery is a major exploit

•Cookies should be used for authentication

•Authorization

-May require user interaction

-May be based on origin (Referer header or Access-Control-Origin header)

Page 12: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

JSON Hijacking

•CSRF Vulnerability + top-level Arrays = Exploit

•Modified JSON

-Commenting

-{}&&[...]

•Best to have good CSRF protection

Page 13: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Client Side Transports: JSONP

GET /resource/?callback=myfunc

myfunc({“foo”:”bar”});

Page 14: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Client Side Transports: Fragment Identifier Messaging

Outer Framehttp://mashup.com/

Inner Framehttp://service.com/#message_for_the_outer_frame

Page 15: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Client Side Transport: Subspace

•Sandboxed JSONP

•Very complicated, more requests

•DNS requirements

Page 16: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Client Side Transport: window.name

•Data is loaded in a sandboxed frame, the mashup is protected from malicious code

•Client side handling

-UI interaction possible

•Efficient

Page 17: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Client Side Transport: postMessage

•Iframe based

•Allows client side handling

-User interaction can be utilized for authorization of resources

•Efficient transport

•Conventions/standards be developed for proxying requests

Page 18: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Client Side Transport: Native XHR with W3C CS-AC

•Coming soon

•Efficient

•Secure, no code execution

•More complicated authorization

Page 19: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Third party widgets

•We want third part code to execute, but in a controlled manner

•Protect the environment, provide access to a subset of the DOM

•Restrict JavaScript features

Page 20: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

ADsafe

•Disables features in JavaScript that prevent containment/sandboxing

-Global variables

- [index], this, ==, !=

-Properties:

-apply,call,callee,caller,constructor,eval, prototype,this,unwatch,valueOf,watch, and anything starting or ending with __

-with, eval

Page 21: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

ADsafe

•ADsafe compliant JavaScript can only access objects that are “given” to it.

•ADsafe scripts can be safely sandboxed, and one can control what objects are accessible.

Page 22: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Caja

•Object capability version of JavaScript (same idea as ADsafe)

•Larger set of language features (less major restrictions)

•Uses code translation

Page 23: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Dojo Secure

•Full framework for loading, validating, and providing a safe set of library functions and safe access to the DOM.

-Provides loading registry with different loading mechanims

-Uses ADsafe style language constraints

-Provides |this| within class constructors

Page 24: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Dojo Secure

-Provides access to the DOM (a facade), with the standard API, that is restricted

-Provides a library API (with no namespacing, no need in a global-less environment)

•Full framework: loading, validation, and DOM sandboxing

Page 25: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Using dojox.secure

//Register cross-domain loading mechanismdojox.io.xhrWindowNamePlugin("http://siteA.com");//Create sandboxmySandbox = dojox.secure.sandbox(dojo.byId("sandbox"));//Securely load, validate, and evaluate HTML or JavaScriptmySandbox.loadJS("http://siteA.com/widget.js");mySandbox.loadHTML("http://siteA.com/widget.html");

Page 26: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Accompanied by Demo

dojox.secure

•Create HTML or JavaScript

-element and document provides access to the DOM

-innerHTML and DOM methods available

•Follow sanboxing rules (avoid restricted operators and globals)

•Full library available:

-query, byId, style, forEach, Class, fromJson, etc.

•Use Class to build methods with this operator

Page 27: Secure Mashups

Secure Mashups

Page 28: Secure Mashups

Properly differentiate authorization and

authentication

Page 29: Secure Mashups

Avoid insecure loading mechanisms

and cookie only based authorization

Page 30: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

dojox.secure to create client-side mashups

•Mutually suspicious components can coexist

•Eliminate vulnerabilities between widgets

Page 31: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved

Secure Mashups

Page 32: Secure Mashups

Copyright SitePen, Inc. 2008. All Rights Reserved