Code-Reuse Attacks and Defenses, © April 2015 Phd Referees: Prof
Total Page:16
File Type:pdf, Size:1020Kb
CODE-REUSEATTACKSANDDEFENSES Vom Fachbereich Informatik (FB 20) an der Technischen Universität Darmstadt zur Erlangung des akademischen Grades eines Doktor-Ingenieurs genehmigte Dissertation von: MSc. Lucas Vincenzo Davi Geboren am 27. April 1984 in Duisburg, Deutschland Referenten: Prof. Dr.-Ing. Ahmad-Reza Sadeghi (Erstreferent) Prof. Hovav Shacham (Zweitreferent) Tag der Einreichung: 22. April 2015 Tag der Disputation: 3. Juni 2015 CASED/System Security Lab Intel Collaborative Research Center for Secure Computing Fachbereich für Informatik Technische Universität Darmstadt Hochschulkennziffer: D17 Lucas Vincenzo Davi: Code-Reuse Attacks and Defenses, © April 2015 phd referees: Prof. Dr.-Ing. Ahmad-Reza Sadeghi (1st PhD Referee) Prof. Hovav Shacham (2nd PhD Referee) further phd commission members: Prof. Dr. Dr. h.c. Johannes A. Buchmann Prof. Dr. Stefan Katzenbeisser Prof. Dr.-Ing. Matthias Hollick Darmstadt, Germany April 2015 ABSTRACT Exploitation of memory corruption vulnerabilities in widely used software has been a threat for almost three decades and no end seems to be in sight. In particular, code- reuse techniques such as return-oriented programming offer a robust attack technique that is extensively used to exploit memory corruption vulnerabilities in modern software programs (e. g. web browsers or document viewers). Whereas conventional control-flow attacks (runtime exploits) require the injection of malicious code, code-reuse attacks leverage code that is already present in the address space of an application to undermine the security model of data execution prevention (DEP). In addition, code-reuse attacks in conjunction with memory disclosure attack techniques circumvent the widely applied memory protection model of address space layout randomization (ASLR). To counter this ingenious attack strategy, several proposals for enforcement of control-flow integrity (CFI) and fine-grained code randomization have emerged. In this dissertation, we explore the limitations of existing defenses against code-reuse attacks. In particular, we demonstrate that various coarse-grained CFI solutions can be effectively undermined, even under weak adversarial assumptions. Moreover, we ex- plore a new return-oriented programming attack technique that is solely based on indi- rect jump and call instructions to evade detection from defenses that perform integrity checks for return addresses. To tackle the limitations of existing defenses, this dissertation introduces the design and implementation of several new countermeasures. First, we present a generic and fine-grained CFI framework for mobile devices targeting ARM-based platforms. This framework preserves static code signatures by instrumenting mobile applications on- the-fly in memory. Second, we tackle the performance and security limitations of exist- ing CFI defenses by introducing hardware-assisted CFI for embedded devices. To this end, we present a CFI-based hardware implementation for Intel Siskiyou Peak using dedicated CFI machine instructions. Lastly, we explore fine-grained code randomization techniques. III ZUSAMMENFASSUNG Laufzeitangriffe nutzen Speicher- und Programmierfehler aus, um beliebiges Schadver- halten auf einem Computersystem zu verursachen. Obwohl diese Angriffe seit über zwei Jahrzehnten bekannt sind, stellen sie immer noch eine große Bedrohung für moderne Software-Programme dar. Dabei benutzen heutige Angriffe eine ausgeklügelte Tech- nik, die sich Return-Oriented Programming (ROP) nennt. Im Gegensatz zu klassischen Laufzeitangriffen, die auf das Einschleusen von Schadcode in den Speicher eines Pro- grammes angewiesen waren, können ROP Angriffe allein über das Zusammensetzen von vorhandenen gutartigen Code Schadverhalten erzeugen. Weil hierbei kein neuer Schadcode explizit eingeschleust wird, umgehen ROP Angriffe weit verbreitete Ab- wehrmechanismen wie beispielsweise Ausführungsschutz für den Arbeitsspeicher. Ins- besondere können ROP Angriffe in Kombination mit sogenannten Speicherlecks –in der englischen Fachliteratur häufig als Memory Disclosure bezeichnet– dazu verwendet werden, um Adress Randomisierung zu umgehen. Um effektiv gegen diese neuartigen Laufzeitangriffe vorzugehen, wurden in den letzten Jahre eine Vielzahl an Abwehrmeth- oden vorgeschlagen, die meistens entweder auf Kontrollfluss-Integrität oder auf fort- geschrittenen Speicheradressen Randomisierungstechniken basieren. In dieser Dissertation erforschen wir die Grenzen und Einschränkungen von existieren- den Schutzmechanismen gegen ROP Angriffe und demonstrieren praktische Angriffe gegen kürzlich präsentierte Kontrollfluss-Integritätslösungen sowie Speicheradressen Randomisierungstechniken, die nicht selten mit nur minimalen Anforderungen ange- griffen werden können. Insbesondere präsentieren wir einen neuartigen ROP Angriff, der ausschließlich indirekte Sprungbefehle missbraucht, um Detektion von Schutzmech- anismen zu umgehen, die Integritätsprüfungen für Funktionsrücksprünge ausführen. Um den Sicherheitsproblemen von vorhandenen Schutzmechanismen effektiv entge- genzutreten, stellen wir in dieser Dissertation die Konzepte und die Implementierungen von mehreren neuartigen Abwehrmethoden vor. Zuerst präsentieren wir eine allgemeine und fortgeschrittene Kontrollflussintegritäts-Lösung für mobile Geräte. Unsere Lösung ist kompatibel zu digitalen Code Signaturen, weil sie nur bereits verifizierten Code dynamisch im Adressspeicher um Integritätsprüfungen erweitert. Zudem erforschen wir einen neuen Hardware-basierten Ansatz zur Kontrollflussintegrität, der im Beson- deren die Leistungseinbußen von existierenden Ansätzen löst. Unser Prototyp basiert auf der Intel-basierten Platform Siskiyou Peak, die besonders für eingebettete Systeme geeignet ist. Zuletzt erforschen wir fortgeschrittene Speicheradressen Randomisierung- stechniken. IV ACKNOWLEDGMENTS Foremost, I’d like to thank my advisor Prof. Ahmad-Reza Sadeghi for his support, feed- back, and guidance. I am very grateful for the intensive and fruitful discussions we had with Ahmad during the five years of my PhD research. His passion and dedication for research has highly influenced my career in academia. I am grateful for the numerous opportunities he has given me, particularly for connecting me with outstanding security researchers worldwide. Besides my advisor Ahmad, I want to thank several professors for their support and advices. Prof. Fabian Monrose from the University of North Carolina at Chapel Hill has supported me with great feedback and writing tips. I learned a lot from his accurateness and critical reviews. From the beginning of my PhD, I was privileged to collaborate with Prof. Thorsten Holz from Ruhr-Universität Bochum. Our collaboration with Thorsten’s team resulted in several publications. I’d also like to thank Prof. N. Asokan (Aalto Uni- versity) for working with me on a lecture book on mobile security, and Prof. Yier Jin (University of Central Florida) for collaborating on hardware-assisted control-flow in- tegrity. I am very honored to have Prof. Hovav Shacham from University of California, San Diego as second referee of my PhD dissertation. I was also pleased to collaborate with him on advanced return-oriented programming attacks. This dissertation is a result of collaborations with various co-authors and colleagues. In particular, I’d like to thank all my colleagues at the System Security Lab at Ruhr- Universität Bochum and Technische Universität Darmstadt, Germany. The joint research work with my colleagues Alexandra Dmitrienko, Marcel Winandy, Christopher Liebchen, Steffen Schulz, Thomas Fischer, Matthias Hanreich, Stefan Nürnberger, Sven Bugiel, Bhargava Shastry, Debayan Paul, Mihai Bucicoiu, and Stephan Heuser resulted in several publications. I have been very lucky to work with several excellent researchers. I’d like to partic- ularly thank Ralf Hund from Ruhr-Universität Bochum. For several months we visited each other, and developed a control-flow integrity framework for mobile devices. Spe- cial thanks also go to Kevin Z. Snow from University of North Carolina at Chapel Hill. We presented together just-in-time return-oriented programming attacks at BlackHat USA 2013 and received the best student paper award at IEEE Security & Privacy 2013. There are many other external co-authors I was privileged to work with, particularly Per Larsen, Stephen Crane, Andrei Homescu, Dean Sullivan, Orlando Arias, Mauro Conti, Marco Negro, Stephen Checkoway, Manuel Egele, Blaine Stancill, Nathan Otterness, Fe- lix Schuster, Kari Kostiainen, Elena Reshetova, and Razvan Deaconescu. I had the privilege to supervise and work with several outstanding students. In the bachelor thesis of Daniel Lehmann, we conducted a security analysis of recently pro- posed control-flow integrity schemes. The master thesis of Tim Werthmann introduces fine-grained application sandboxing on iOS. For Christopher Liebchen’s master thesis, we explored fine-grained code randomization and execution-path randomization. V During my PhD, I had the unique opportunity to do a summer internship at the Se- curity Research Lab at Intel Labs in Hillsboro, Oregon. I’d like to thank my manager Anand Rajan and my mentor Manoj Sastry. Both have greatly supported me during my internship. Because of our newly founded Intel Security Institute in Darmstadt (Intel CRI-SC), I had the opportunity to work with Matthias Schunter, Patrick Koeberl, and Steffen Schulz. In particular, I’d like to thank Patrick for his great feedback on the archi- tectural and implementation aspects of hardware-assisted