from e to ecmascript and back again
play

From E to EcmaScript and back again Mark S. Miller and the - PowerPoint PPT Presentation

From E to EcmaScript and back again Mark S. Miller and the Cajadores Overview Object-Capabilities Security as extreme modularity Securing JavaScript Why and How? E Caja ES5 SES Dr. SES Patterns of Safe Cooperation In


  1. From E to EcmaScript and back again Mark S. Miller and the Cajadores

  2. Overview Object-Capabilities Security as extreme modularity Securing JavaScript – Why and How? E  Caja  ES5  SES  Dr. SES Patterns of Safe Cooperation In Secure EcmaScript (SES) Distributed Cryptographic Capabilities In Distributed Resilient Secure EcmaScript (Dr. SES)

  3. Security as Extreme Modularity Modularity: Avoid needless dependencies Security: Avoid needless vulnerabilities Vulnerability is a form of dependency Mod: Principle of info hiding - need to know. Sec: Principle of least authority - need to do.

  4. How do I designate thee? by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions How might object Bob come to know of object Carol?

  5. How do I designate thee? Alice says : bob.foo(carol) by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions

  6. How do I designate thee? Alice says : bob.foo(carol) by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions

  7. How do I designate thee? Alice says : bob.foo(carol) by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions

  8. How do I designate thee? Alice says : bob.foo(carol) by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions

  9. How do I designate thee? Alice says : bob.foo(carol) by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions

  10. How do I designate thee? Bob says : var carol = { ... }; by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions

  11. How do I designate thee? Alice says : var bob = { ... carol ... }; by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions

  12. How do I designate thee? At t 0 : by Introduction ref to Carol ref to Bob decides to share by Parenthood by Endowment by Initial Conditions

  13. OCaps: Small step from pure objects Memory safety and encapsulation + Effects only by using held references + No powerful references by default

  14. OCaps: Small step from pure objects Memory safety and encapsulation + Effects only by using held references + No powerful references by default Reference graph ≡ Access graph Only connectivity begets connectivity Natural Least Authority OO expressiveness for security patterns

  15. The Mashup problem: Code as Media <html> <head> <title>Basic Mashup</title> <script> function animate ( id ) { var element = document.getElementById(id); var textNode = element.childNodes[0]; var text = textNode.data; var reverse = false; element.onclick = function() { reverse = !reverse; }; setInterval(function() { textNode.data = text = reverse ? text.substring(1) + text[0] : text[text.length-1] + text.substring(0, text.length-1); }, 100); } </script> </head> <body onload="animate('target')"> <pre id="target">Hello Programmable World! </pre> </body> </html>

  16. Improving JavaScript in Stages EcmaScript 3: One of the hardest oo languages to secure. Caja: Complex server-side translator. Runtime overhead. EcmaScript 5: One of the easiest oo languages to secure. <script src=“initSES.js”></script> Simple client-side init and verifier. No runtime overhead. Approx 3K download compressed.

  17. Objects as Closures makeCounter function makeCounter () { var count = 0; incr incr return { incr incr incr incr incr: function() { return ++count; }, count decr: function() { return –count; } count count }; decr decr decr decr } decr decr

  18. Objects as Closures makeCounter function makeCounter () { var count = 0; incr incr return { incr incr incr incr incr: function() { return ++count; }, count decr: function() { return –count; } count count }; decr decr decr decr } decr decr A record of closures hiding state is a fine representation of an object of methods hiding instance vars

  19. Objects as Closures in ES5/strict “use strict”; makeCounter function makeCounter () { var count = 0; incr incr return def( { incr incr incr incr incr: function() { return ++count; }, count decr: function() { return –count; } count count }); decr decr decr decr } decr decr A tamper-proof record of lexical closures encapsulating state is a defensive object

  20. Turning ES5 into SES <script src=“initSES.js”></script> Monkey patch away bad non-std behaviors Remove non-whitelisted primordials Install leaky WeakMap emulation Make virtual global root Freeze whitelisted global variables • Replace eval & Function with safe alternatives • Freeze accessible primordials

  21. Running ES5 & SES on old browsers

  22. Future objects on old browsers

  23. Revocable Function Forwarder function makeFnCaretaker ( target ) { makeCaretaker return def({ wrapper: function(…args) { revoke revoke revoke revoke wrapper wrapper wrapper wrapper revoke revoke revoke revoke wrapper wrapper wrapper wrapper revoke revoke revoke revoke wrapper wrapper wrapper wrapper return target(…args); }, target target target target target target revoke: function() { target = null; } }); }

  24. Unconditional Access Alice says: Alice Bob foo bob.foo(carol); Grants Bob full access to Carol forever Carol

  25. Revocability ≡ Temporal attenuation Alice says: Alice Bob foo var ct = makeCaretaker(carol); bob.foo(ct.wrapper); revoke revoke wrapper wrapper target Carol

  26. Revocability ≡ Temporal attenuation Alice says: Alice Bob var ct = makeCaretaker(carol); bob.foo(ct.wrapper); //… revoke revoke wrapper wrapper target Carol

  27. Revocability ≡ Temporal attenuation Alice says: Alice Bob var ct = makeCaretaker(carol); bob.foo(ct.wrapper); //… revoke revoke wrapper wrapper ct.revoke(); target Carol

  28. Revocability ≡ Temporal attenuation Alice says: Alice Bob var ct = makeCaretaker(carol); bob.foo(ct.wrapper); //… revoke revoke wrapper wrapper ct.revoke(); target Carol

  29. Attenuators ≡ Access Abstractions Alice says: Alice Bob foo var ct = makeCaretaker(carol); bob.foo(ct.wrapper); Express security policy by the behavior of the objects you provide Carol

  30. Abstractions extend vocabulary Primitives Abstraction Forms Extended Vocabulary procedural abstraction +, ., [] foo(bar, baz), … data abstraction int, struct, array Point, Window, … control abstraction if, while, switch addListener, … points-to access abstraction caretaker, membrane, …

  31. Membranes: Transitive Interposition Alice Bob function makeFnMembrane ( target ) { var enabled = true; function wrap ( wrapped ) { if (wrapped !== Object(wrapped)) { return wrapped; Dave } return function(… args ) { if (!enabled) { throw new Error(“revoked”); } return wrap(wrapped(…args.map(wrap)); } } return def({ wrapper: wrap(target), Carol revoke: function() { enabled = false; } }); }

  32. Attenuators Compose function makeROFile ( file ) { return def({ read: file.read, getLength: file.getLength }); } var rorFile = makeROFile(revocableFile);

  33. No powerful references by default Alice says: Alice Bob var bobSrc = //site B bob var carolSrc = //site C var bob = eval (bobSrc); Carol var carol = eval (carolSrc); carol

  34. No powerful references by default Alice says: Alice Bob var bobSrc = //site B bob var carolSrc = //site C var bob = eval (bobSrc); Carol var carol = eval (carolSrc); carol Bob and Carol are confined . Only Alice controls how they can interact or get more connected.

  35. No powerful references by default Alice says: Alice bob Bob carol Carol

  36. Only connectivity begets connectivity Alice says: bob Bob var counter = makeCounter(); counter incr incr bob(counter.incr); carol(counter.decr); carol count count Carol count bob = carol = null; decr decr

  37. Only connectivity begets connectivity Alice says: bob Bob var counter = makeCounter(); counter incr incr bob(counter.incr); carol(counter.decr); carol count count Carol count bob = carol = null; decr decr Bob can only count up and see result. Carol only down. Alice can only do both.

  38. Membrane eval → compartment var compartment = makeMembrane(eval); var vbob = compartment.wrapper(bobSrc); Bob Alice

  39. Membrane eval → compartment var compartment = makeMembrane(eval); var vbob = compartment.wrapper(bobSrc); //… Bob Alice

  40. Membrane eval → compartment var compartment = makeMembrane(eval); var vbob = compartment.wrapper(bobSrc); //… compartment.revoke(); Bob Alice GC

  41. Composing Authority +? Usually intersection

  42. Rights Amplification ≥ + + Authority conditional on other possessions. Enables more expressive power.

  43. Rights Amplification function makeBrand () { Alice Bob foo var amp = WeakMap(); return def({ seal: function( payload ) { var box = def({}); amp.set(box, payload); makeBrand return box; }, seal unseal seal unseal unseal: function( box ) { amp amp box return amp.get(box); box box } payload payload payload }); }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend