430 likes | 677 Views
Verified Security for Browser Extensions. Arjun Guha, Matthew Fredrikson, Ben Livshits, and Nikhil Swamy. Brown University. University of Wisconsin Madison. Microsoft Research. Curated Extension Gallery. 1/3 rd of Firefox users run extensions (~34 million users)
E N D
Verified Security for Browser Extensions Arjun Guha, Matthew Fredrikson, Ben Livshits, and Nikhil Swamy Brown University University of WisconsinMadison Microsoft Research
Curated Extension Gallery 1/3rd of Firefox users run extensions (~34 million users) Popular Chrome extensions have thousands of users
Change mailto: links mailto:joe@cs.brown.edu Change links to evil.com? https://mail.google.com/mail/?view=cm&tf=1&to=joe@cs.brown.edu&cc=&su=&body=&fs=1
Google Dictionary Service evil.com Send my email to evil.com? Sends selected word to Google
Access Control in Chrome "permissions": [ "tabs", "http://www.twitter.com/*", "http://api.bit.ly/", ] 1. Sensitive APIs 2. Extension runs on these URLs Barth et al. Protecting Browsers from Extension Vulnerabilities. NDSS 2010.
Policy analysis:Accessible URLs Access to all data on all websites Access toall data on one website 2—86 websites 1,137 extension policies
Policy analysis:Access to history why? Full History Access 1,137 extension policies
Rewrite mailto: links on all sites Sends selected word to Google from any website "permissions": [ "http://???" ] "permissions": [ "http://*/*" ] desired, least-privilege security policy is inexpressible "permissions": [ "http://*/*" ] "permissions": [ "http://???" ] 11
Full History Access Access to all websites Access to all data on all websites Access to all websites
IBEX: Rethinking Browser Extension Security • Cross-platform extension model • Expressive policies with formal semantics • Secure-by-construction extensions • Empirical evaluation: 17 varied extensions proved secure
Extension in Fine Type-safe high-level language
Extension in Fine Extension policy • Developers • Write extension and policy in Fine • Use tools to ensure extension conforms to policy ML/F# dialect with a type system for program verification Fine Verifier & Compiler Secure Browser API Policy Visualizer • Gallery • Uses tools to ensure extension conforms to policy • Uses visualizer to help understand policy • Users • Trust curated extension gallery • Install approved extensions C3
Extension in Fine Extension policy Fine Verifier & Compiler Example: Only Read text in <head> Secure Browser API C3
Native DOM elements, abstract to Fine type elt valgetInnerText : elt -> string valgetTagName : elt -> string DOM API Implemented in Browser
type elt valgetInnerText : { e:elt | CanRead e } -> string valgetTagName : e:elt -> { s:string | EltTagName e s } Secure DOM API Precondition; DOM permission Postcondition; DOM predicate Only Read text in <head>
type elt • valgetInnerText : • { e:elt | CanRead e } • -> string • valgetTagName : • e:elt • -> { s:string | EltTagName e s } • (e:elt) . EltTagName e "head" CanReade Secure DOM API Policy
type elt • valgetInnerText : • { e:elt | CanRead e } • -> string • valgetTagName : • e:elt • -> { s:string | EltTagName e s } • (e:elt) . EltTagName e "head" CanReade • let read e = • if getTagNamee = "head" then • getInnerTexte • else • "not <head>" Secure DOM API Fine checks pre- and post-conditions statically Policy EltTagName e "head" No manual code audit(only policy audit) No security exceptions (robust) and no runtime overhead (fast) Code
Library of Predicates and Permissions DOM Network requests Event handlers, selected text, etc. various other predicates and permissions
What Does “Secure” Mean? Formal Model Policy Visualization
Formal Modelof core browser + reference monitor • Key element: interaction of extension with JavaScript on page • Theorem:well-typed programs do not signal reference monitor errors • Reference monitor not needed • Relies on type soundness of Fine • Assumption: tag names and attribute names are public metadata • Analysis of security property • Strength: Robust safety in the presence of JavaScript side effects • Weakness: admits collusion between malicious JavaScript on a page and extension Formal Model
Example: FaceBookExtension SECURE ^
Question: What is the security policy? Bookmarks my friends’ Websites
Can Read Names Can Read Websites (and ability to bookmark—elided) Principle of Least Authority
Policy: Can read <a> tags Can read <a> tags can read links to likes, dislikes, groups, posts, friends, …
Policy: can read <td class="data"> tags, if adjacent to <th class="label">Website:</th> (data:elt), (label:elt) . EltSibling data label && EltAttr label "class" "label" && EltAttrdata "class" "data" && EltTextValuelabel "Website:" CanRead data
(e:elt) . CanReadAttr e "class" (label:elt), (labelText:elt) . EltParentlabelText label && EltAttr label "class" "label" CanReadValuelabelText (data:elt),(label:elt), (labelText:elt),(website:elt), (parent:elt) . EltParent data parent && EltParent label parent && EltParent website data && EltParentlabelText label && EltAttr label "class" "label" && EltTextValuelabelText "Website:" CanReadAttr website "href" Policy Visualization Interpret policies as selectors (e.g., XPath, jQuery, or CSS) Can we help extension reviewers read this?
DOM + Network authorization Experimental Results authorization DOM + history + storage + dataflow (next presentation)
Extension in Fine Extension policy • Developers • Write extension and policy in Fine • Use tools to ensure extension conforms to policy Fine Verifier & Compiler Secure Browser API Policy Visualizer • Gallery • Uses tools to ensure extension conforms to policy • Uses visualizer to help understand policy • Users • Trust curated extension gallery • Install approved extensions C3 Available online: http://research.microsoft.com/fstar
Policy: (e:elt).EltAttre "id" "phone" CanRead e <html> ... <div id="phone">+1 (401) 484-8019</div> ... <input type="password" value="redbull64" /> ... </html> let e = getElementById "phone" let phoneNumber = getTextValue e Verified Fine code var phone = document.getElementById("phone"); var pass = document.getElementsByTagName("input")[0]; phone.innerText = pass.value JavaScript on the page Verified Fine code let password = getTextValue e Monotonic policies; no dynamic revocation Authorization policies, not information flow
+ Extension code Policy FINE Type-checker & Compiler + Z3 DCIL Binary JavaScript extension DCIL Verifier C3
Curator still needs to read the policy Remove friend?!
Chrome Extension Model Content script DOM Interactions Verified Web Page Rewrite in Fine Message Passing Sandbox Extension core (JavaScript) HTTP Web Server