Principled and Practical Web Application Security
Total Page:16
File Type:pdf, Size:1020Kb
PRINCIPLED AND PRACTICAL WEB APPLICATION SECURITY A DISSERTATION SUBMITTED TO THE DEPARTMENT OF COMPUTER SCIENCE AND THE COMMITTEE ON GRADUATE STUDIES OF STANFORD UNIVERSITY IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF DOCTOR OF PHILOSOPHY Deian Stefan December 2015 c Copyright by Deian Stefan 2016 All Rights Reserved ii I certify that I have read this dissertation and that, in my opinion, it is fully adequate in scope and quality as a dissertation for the degree of Doctor of Philosophy. (David Mazieres)` Principal Adviser I certify that I have read this dissertation and that, in my opinion, it is fully adequate in scope and quality as a dissertation for the degree of Doctor of Philosophy. (John C. Mitchell) I certify that I have read this dissertation and that, in my opinion, it is fully adequate in scope and quality as a dissertation for the degree of Doctor of Philosophy. (Alejandro Russo) I certify that I have read this dissertation and that, in my opinion, it is fully adequate in scope and quality as a dissertation for the degree of Doctor of Philosophy. (Dan Boneh) Approved for the Stanford University Committee on Graduate Studies iii Abstract Large-scale private user data theft has become a common occurrence on the web. A huge factor in these privacy breaches is that developers specify and enforce data security policies by strewing checks throughout their application code. Overlooking even a single check can lead to vulnerabil- ities. Unfortunately, even if developers manage to get all the checks right, most web applications rely on third-party code; a vulnerable or malicious third-party library, yet again, puts the user’s data at risk. This dissertation presents a novel approach to protecting sensitive data even when application code is buggy or malicious. The key ideas of this work are to separate the security and privacy concerns of an application from its functionality, and to use language-level information flow control (IFC) to enforce policies throughout the application codebase. The main challenge of this approach is at once to design practical systems that can be easily adopted by average developers, and simul- taneously to leverage formal semantics that rule out large classes of design error. To address this challenge, this dissertation presents two systems—Hails and COWL—which respectively address the security issues web applications face on the server and in the browser. Hails is a server-side web framework that separates the security and privacy concerns of an ap- plication from it functionality by following a new paradigm called model–policy–view–controller (MPVC). In the MPVC model, developers specify security policies in a single place, using a declar- ative policy specification language. Hails then enforces these policies across all application compo- nents using language-level IFC. This alleviates the need for application logic code to be intertwined with security checks and ensures that policies are enforced in a mandatory fashion, even across third-party code. Hails has been used by developers with a wide-range of expertise, from a novice high school student to expert web developers to build secure web sites with very small trusted com- puting bases. Some of these web applications were deployed production. While Hails ensures that server-side code cannot leak or corrupt sensitive user data, COWL extends this security guarantee to the browser, where JavaScript, typically provided by multiple iv disparate parties, computes on the user’s sensitive data. COWL is a JavaScript confinement system that extends the browser security model with IFC, while retaining backwards compatibility with the existing Web. Much like Hails, COWL allows developers to associate policy with sensitive data, such as passwords. Within the confines of the browser, COWL then enforces these policies with IFC, prohibiting code from arbitrarily leaking data. This system has been implemented in both Firefox and Chromium, and is currently being standardized at the W3C as a new web specification. Building practical systems, such as Hails and COWL, using information flow control required new developments in language-level security foundations. This dissertation describes some of the main results which were key to Hails and COWL, including: DC Labels, a simple yet expressive label model based on propositional logic; LIO, a dynamic, language-level IFC system implemented in Haskell; and, IFC-Inside, a generalization of LIO system to arbitrary languages. These founda- tions explore a new design point in language-level IFC, which addresses many of the shortcomings of previews results, while providing strong security guarantees; this was previously thought to be impractical for purely dynamic IFC enforcement. Taken together, this dissertation presents practical systems that build on newly developed foun- dations in language-based security to provide end-to-end security to web applications. In addition to providing a solution to securing today’s web applications, however, the strong security provided by these systems also opens up the possibility of deploying applications that, because of security concerns, were not previously practical. v Acknowledgments I would first like to thank my advisors David Mazieres,` John C. Mitchell, and Alejandro Russo. They provided me with a model environment for conducting research and always encouraged me to work on things I enjoyed most. David’s close mentorship, deep insights, and intuition have greatly shaped my views on research and systems building. John and Alejandro’s guidance, encouragement, and perspectives have also highly influenced my research approach, especially in leveraging semantics and programming languages techniques. In addition to my advisors, I thank Brad Karp, Dan Boneh, and Arjen Lenstra for being my mentors and sounding boards at various important times of my career. I am truly thankful and honored to have worked with these great people. Next, I would like to thank my close collaborators; this dissertation is based on research I per- formed with many great colleagues. Beyond those already mentioned, I would like to thank Edward Z. Yang, Amit Levy, Stefan Heule, Devon Rifkin, Petr Marchenko, Pablo Buiras, David Terei, Joe Zimmerman, Rahul Sharma, and Daniel B. Giffin. I would also like to thank my Stanford and Chalmers colleagues with whom I’ve had many great discussions—beyond those mentioned, Diego Ongaro, Adam Beley, Sergio Benitez, Arnar Birgisson, Andrea Bittau, Henry Corrigan-Gibbs, Ali Mashtizadeh, and Dante Zanarini. I thank my committee—Dan Boneh, John Gill, David Mazieres,` John C. Mitchell, and Alejandro Russo—for their time, commitment, and feedback on this work. During my Ph.D. I spent a summer at Mozilla Research working with Dave Herman and Bobby Holley. I thank them both for their help and insights in building adoptable systems for the web. I would also like to thank Brendan Eich for helping me bootstrap at Mozilla. Finally, I thank my Mozilla colleagues—Bebenita, Blake Kaplan, Christoph Kerschbaumer, Ian Melven, Garret Robin- son, Brian Smith, Tanvi Vyas, and Boris Zbarsky—for the many fruitful discussions. For roughly a year now I’ve been a member of the W3C Web Application Security group. Work- ing on standards has been immensely rewarding, especially with such a supporting and encouraging group. Beyond their support and encouragement, I would like to thank Brad Hill, Wendy Seltzer, vi and Daniel Veditz for making whole experience very welcoming. I would like to thank my co-founders, colleagues, and advisors at GitStar—in particular, Chris- tian Almenar, Devon Rifkin, David Mazieres,` and Dan Boneh. Working with them to build a com- pany that is putting security research into practice has been immensely rewarding, educational, and full of joy. Finally, I would like to thank my family and friends for being supportive, understanding, and loving. They’ve always stood by me and made my life easier. I would not be the same person without their support. The research in this dissertation was funded by DARPA (CRASH, under contract #N66001-10- 2-4088, and PROCEED, under contract #N00014-11-1-0276-P00002), by the NSF, by the AFOSR, by multiple gifts from Google, by a gift from Mozilla, and by the Swedish research agencies VR and STINT. I was supported by the DoD through the NDSEG Fellowship Program. vii Contents Abstract iv Acknowledgments vi Contents viii List of tables xiii List of figures xiv 1 Introduction1 1.1 Contributions.....................................3 1.2 Organization...................................... 10 I End-to-End Web Application Security with Information Flow Control 12 2 Server-side Security with Hails 13 2.1 Introduction...................................... 13 2.2 Design......................................... 16 2.2.1 Principals and privileges........................... 17 2.2.2 Labels and MAC-based confinement..................... 18 2.2.3 Model-Policy (MP).............................. 20 2.2.4 View-Controller (VC)............................ 24 2.2.5 Life-cycle of an application......................... 26 2.2.6 Trust assumptions.............................. 29 2.3 Implementation.................................... 29 viii 2.3.1 Server-side language-level confinement................... 29 2.3.2 OS-level confinement............................. 30 2.3.3 Browser-side language-level confinement.................. 31 2.4 Applications...................................... 31 2.4.1 GitStar platform............................... 32 2.4.2 LearnByHacking