Enhancing the Security and Privacy of Full-Stack Javascript Web Applications , January 2020
Total Page:16
File Type:pdf, Size:1020Kb
ENHANCING THE SECURITY AND PRIVACY OF FULL-STACK JAVASCRIPT WEB APPLICATIONS Vom Fachbereich Informatik der Technischen Universität Darmstadt genehmigte dissertation zur Erlangung des akademischen Grades Doktor-Ingenieur (Dr.-Ing.) von cristian-alexandru staicu, m.sc. geboren in Or˘as, tie, Rumänien. Referenten: Prof. Dr. Guido Salvaneschi Prof. Dr. Michael Pradel Prof. Dr. Andrei Sabelfeld Tag der Einreichung: 05.02.2020 Tag der Prüfung: 18.03.2020 Cristian-Alexandru Staicu: Enhancing the Security and Privacy of Full-Stack JavaScript Web Applications , January 2020. This document was published using tuprints, the E-Publishing-Service of TU Darmstadt. http://tuprints.ulb.tu-darmstadt.de [email protected] Please cite this document as: URN: urn:nbn:de:tuda-tuprints-118087 URL: https://tuprints.ulb.tu-darmstadt.de/id/eprint/11808 This work is licensed under a Creative Commons “Attribution-ShareAlike 4.0 Interna- tional” license. ERKLÄRUNG Hiermit erkläre ich, dass ich die vorliegende Arbeit – abgesehen von den in ihr ausdrücklich genannten Hilfen – selbständig verfasst habe. Darmstadt, Deutschland, März 2020 Cristian-Alexandru Staicu ACADEMICCV October 2014 - March 2020 Doctoral Degree in Computer Science Technische Universität Darmstadt, Germany September 2012 - August 2014 Master Degree in Computer Science University of Trento, Italy and University of Twente, Netherlands September 2007 - August 2011 Bachelor Degree in Computers and Information Technology Politehnica University Timis, oara, Romania iii ABSTRACT Web applications are the most important gateway to the Internet. Billions of users are relying on them every day and trusting them with their most sensitive data. Therefore, ensuring the security and privacy of web appli- cations is of paramount importance. Traditionally, the server-side code of websites was written in languages such as PHP or Java for which secu- rity issues are well studied and understood. Recently, however, full-stack JavaScript web applications emerged, which have both their client-side and server-side code written in this language. We hypothesize that there are several unique properties of full-stack JavaScript web applications that pose a serious challenge for the security analysts: the new threat model for JavaScript, the excessive code reuse, the prevalence of code transformations, and the existence of complex full-stack threats. In this dissertation, we support this thesis by performing several in-depth studies of the JavaScript ecosystem and by proposing multiple improvements to the state-of-the art practices. First, we discuss two types of security vulnerabilities that are aggravated by the new threat model: injections and regular-expression denial of service. Second, we show that excessive code reuse in the JavaScript ecosystem increases the chance of relying on malicious or vulnerable code. Third, we provide evidence that code transformations are widespread and that full-stack threats exist. Fi- nally, we propose several improvements for techniques aimed at hardening web applications: cost-effective consideration of implicit flows, the extrac- tion of taint specification for third-party libraries, and pragmatic program analysis for defending against injections. The problem of securing full-stack JavaScript web applications is far from settled, but we hope that the current dissertation serves as motiva- tion for future work to consider this increasingly important class of appli- cations. In particular, we argue for holistic approaches that consider full- stack and cross-library information flows. v ZUSAMMENFASSUNG Webanwendungen sind die wichtigste Schnittstelle zum Internet. Milliar- den Nutzer sind täglich auf sie angewiesen und vertrauen ihnen ihre sen- siblen Daten an. Deshalb ist es besonders wichtig, die Sicherheit und den Datenschutz von Webanwendungen zu gewährleisten. Der serverseitige Code von Websites wurde üblicherweise in Sprachen wie PHP oder Ja- va geschrieben, deren Sicherheitslücken gut erforscht und nachvollziehbar sind. In letzter Zeit sind jedoch Full-Stack-JavaScript-Webanwendungen aufgetreten, deren clientseitiger und serverseitiger Code in dieser Sprache geschrieben ist. Unsere Hypothese ist, dass viele Eigenschaften von Full-Stack- JavaScript-Webanwendungen eine ernsthafte Herausforderung für einen Sicherheitsanalysten darstellen: Das neue Bedrohungsmodell für Ja- vaScript, die übermäßige Wiederverwendung von Code, verbreitete Code-Transformationen und komplexe Full-Stack-Bedrohungen. In dieser Dissertation vertreten wir diese These, indem wir das JavaScript- Ökosystem mehrmals gründlich untersuchen und zahlreiche Verbesse- rungen zum heutigen Stand der Technik aufzeigen. Als Erstes erörtern wir zwei Arten von Sicherheitslücken, die durch das neue Bedrohungs- modell verschärft werden: Injections und Denial-of-Service für reguläre Ausdrücke. Als Zweites wird aufgezeigt, dass eine übermäßige Wieder- verwendung von Code im JavaScript-Ökosystem die Wahrscheinlichkeit erhöht, sich auf bösartigen oder anfälligen Code zu verlassen. Als Drit- tes weisen wir die weite Verbreitung von Code-Transformationen und das Vorkommen von Full-Stack-Bedrohungen nach. Schließlich werden verschiedene verbesserte Techniken zum Härten von Webanwendungen vorgestellt: Berücksichtigung der Effizienz von impliziten Datenflüssen, Extraktion von Taint-Spezifikationen für Bibliotheken von Drittanbietern und pragmatische Programmanalyse zur Abwehr von Injection-Angriffen. Das Sicherheitsproblem von Full-Stack-JavaScript-Webanwendungen ist noch lange nicht gelöst. Jedoch hoffen wir, dass die vorliegende Dissertati- on dazu motiviert, diese zunehmend wichtige Applikationsart für zukünf- tige Arbeiten zu berücksichtigen. Insbesondere befürworten wir ganzheit- liche Ansätze, die Full-Stack und bibliotheksübergreifende Informations- flüsse miteinschließen. vii ACKNOWLEDGEMENTS The work described in this dissertation was done over the course of five crazy, intense years. This wonderful time of my life was filled with a lot of transformative experiences. Even though pursuing a PhD is viewed as a way to climb into or build one’s ivory tower, I found that the opposite was true in my case: I met a lot of wonderful, down-to-earth people on the way who supported and encouraged my efforts. First and foremost, I want to thank my adviser Michael Pradel who was an excellent mentor and role model. He guided every step of my PhD adventure and enabled me to transform from a software engineer with an interest for science into an independent researcher. This rite of passage involved climbing many steep slopes and fighting a lot of my inner beasts. Thank you, Michael, I am forever grateful for your immense trust and support. Please do not forget that if (secret) x = true. Next, I want to thank the current and past members of Software Lab. The friendly atmosphere in the group and the accent on high quality re- search allowed me to continuously grow, while nurturing the right amount of skepticism. In particular, I am very grateful to Andrea Püchner, Marija Selakovic, Marina Billes, Jibesh Patra, Andrew Habib and Daniel Lehmann for their continuous support, for helping with navigating the German bu- reaucracy, and for the fun philosophical discussions. I also want to thank Markus Zimmermann, Philippe Skolka and Patrick Mell for completing their theses under my supervision and Katharina Plett for helping with the translation of the thesis abstract into German. I am also grateful for having had the opportunity to co-author papers with great researchers from around the world: Max Schäfer, Anders Møller, Martin Toldam Torp, Nikos Vasilakis, Daniel Schoepe, Musard Balliu, An- drei Sabelfeld, Benjamin Livshits, Luca Della Toffola, Cam Tenny, Hui Liu, Qiurong Liu, Yue Luo, Esben Andreasen, Liang Gong, Koushik Sen, Mar- iano Ceccato, Paolo Falcarin, Alessandro Cabutto and Yosief Weldezghi Frezghi. Thank you for guiding my research in the right direction in these early years, I learned a lot by working side-by-side with you. As I mentioned earlier, I had the benefit of meeting a lot of wonder- ful people while in Darmstadt, many of whom I already mentioned. My colleagues at Software Lab and their partners were some of my closest friends during these years. I want to thank especially Supriti Sinhama- ix hapatra, Jovan Kruni´cand Lydia Gad for the many great afternoons we spent together. Additionally, I want to thank Nikolay Matyunin for his great sense of humor and for our endless discussions about the Eastern European experience and Wen Wang for her extraordinarily positive atti- tude. Karina Köhres for helping me better understand and fit in the Ger- man culture, and the Darmstädter one in particular. Hanne Weismann and Matthew Geddes for our fantastic board game nights, especially for our trip to Chamstone. I also want to thank Peter Merz and Nathalie Brunner Merz for their affection, Giorgia Azzurra Marson for being an amazing flat- mate, Tommaso Gagliardoni for his entertaining travel stories and Patrick Struck for the fun pub quiz evenings. Finally, I also want to thank Nikolaos Athanasios Anagnostopoulos, Carel van Rooyen and Spyros Boukoros for tackling together the shock of our first doctorate year. Next, I would like to thank my teachers and mentors who, during my studies, instilled respect and curiosity for science in me, and for knowl- edge in general: Marius Minea, Radu Marinescu, Emilia Petris, or, Massi- miliano Sala, Artur Kuczapski, C˘alinDon, Gabriel Petric, Letit, ia Rafiliu, Maria Pascu and Camelia T˘almaciu. During