Adam Barth (Berkeley) Collin Jackson (Stanford) William Li - - PowerPoint PPT Presentation

adam barth berkeley collin jackson stanford william li
SMART_READER_LITE
LIVE PREVIEW

Adam Barth (Berkeley) Collin Jackson (Stanford) William Li - - PowerPoint PPT Presentation

Adam Barth (Berkeley) Collin Jackson (Stanford) William Li (Berkeley) Mashups Two web sites collaborating to create user experience Housing maps Yelp (uses Google Maps) iGoogle Mashups are everywhere Advertising just a


slide-1
SLIDE 1

Adam Barth (Berkeley) Collin Jackson (Stanford) William Li (Berkeley)

slide-2
SLIDE 2

Mashups

 Two web sites collaborating to create user experience

 Housing maps  Yelp (uses Google Maps)  iGoogle

 Mashups are everywhere

 Advertising just a special case of mashups  Greasemonkey / browser extensions

slide-3
SLIDE 3

Browser Support

 Support in old browsers sucks

 <iframe>: no interaction  <script>: no security

 Many proposals for better primitives

 <module>, Subspace, <openSandbox>,

OMash, CompoWeb, …

 Which ones are good and why?

slide-4
SLIDE 4

Mashup Primi2ve Design Space

 Lexical vs. Dynamic  Interfaces vs. Asymmetry  Typed vs. Untyped  Values vs. Objects

slide-5
SLIDE 5

Lexical vs. Dynamic

 Function written by one principal might call a

function written by another principal

 Which is security context to use?

 Lexical: Use owner of last JavaScript function (bar)  Dynamic: Use owner of first JavaScript function (foo)

function foo () { bar(); } function bar () { alert(document.cookie); }

slide-6
SLIDE 6

Dynamic Sucks!

frames[0].getPublicInterface(); function getPublicInterface () { top.setTimeout("... attack code ...", 0); } Fixed:

slide-7
SLIDE 7

Interfaces vs. Asymmetry

 How do the principals interact?

 Each defines an interface function appendMessage (message) { document.createTextNode(message); document.getElementById('messages').appendChild(node); }  One principal subsumes the other frames[0].document.body.innerHTML += 'Hello!';

slide-8
SLIDE 8

Asymmetry Sucks!

doc.querySelectorAll(query); document.querySelectorAll = function() {…}

slide-9
SLIDE 9

Capability Leaks

document.querySelectorAll = function () { var obj = document.querySelectorAll.caller; while (obj.arguments.length == 0 || !obj.arguments[0].target) {

  • bj = obj.caller;

} var victimDocument = obj. arguments[0].target.ownerDocument; victimDocument.body.innerHTML = "<img onerror=’...’>"; }

slide-10
SLIDE 10

Typed vs. Untyped

 How should the interface be defined?

 In terms of types

function deref (a : Array, b : Number) { return a[b]; }

 Without types

function deref (a, b) { return a[b]; }

slide-11
SLIDE 11

Untyped Sucks!

deref(deref(frames[0], "document"), "cookie") function deref (a, b) { return a[b]; }

slide-12
SLIDE 12

More AGacks

slide-13
SLIDE 13

Values vs. Objects

 What types can be exchanged?

 Just primitive values

foo('Hello!');

 Both primitive values and objects

var obj = { msg: function() { return 'Hello!'; } } foo(obj);

slide-14
SLIDE 14

Objects Suck!

 Contain pointers to other objects  __proto__ leads to Object.prototype

frames[0].getPublicInterface function getPublicInterface () { } alert($(document.body));

slide-15
SLIDE 15

Exploit

 valueOf is also effective

frames[0].getPublicInterface.__proto__ .__proto__.toString = function () { this.append("<img src=’’ onerror=’...’>"); } } function getPublicInterface () { } alert($(document.body));

slide-16
SLIDE 16

Ideal Primi2ve

 Lexical authorization  Interact via an interface  Interface restricted by type  Only exchange primitive values  Wait! We already have such a primitive…

slide-17
SLIDE 17

PostMash

 Can simulate other primitives using postMessage  DCOM‐like design

 Integrator uses stub library  RPC to gadget <iframe> using postMessage  Remote objects represented as opaque handles

 Built safe version of Google Maps gadget

Integrator Stub Gadget

slide-18
SLIDE 18

PostMash version of GMap2

slide-19
SLIDE 19

Performance

774 774 774 461 461 234 397 200 400 600 800 1000 1200 1400 1600 1800 2000 Reference Optimized postMessage Unoptimized postMessage Milliseconds JSON2 No batching postMessage Reference

slide-20
SLIDE 20

Conclusions

 Design of mashup primitives fraught with landmines

 Many proposals are broken  Might be possible to hack together, but why?

 Learn to love the postMessage

 Simple primitive  Powerful building block

 Please stop proposing new mashup primitives!

 Or at least build it on top of postMessage