Cross-Core Microarchitectural Side Channel Attacks and Countermeasures
Total Page:16
File Type:pdf, Size:1020Kb
Cross-core Microarchitectural Side Channel Attacks and Countermeasures by Gorka Irazoqui A Dissertation Submitted to the Faculty of the WORCESTER POLYTECHNIC INSTITUTE In partial fulfillment of the requirements for the Degree of Doctor of Philosophy in Electrical and Computer Engineering by April 2017 APPROVED: Professor Thomas Eisenbarth Professor Berk Sunar Dissertation Advisor Dissertation Committee ECE Department ECE Department Professor Craig Shue Professor Engın Kirda Dissertation Committee Dissertation Committee CS Department Northeastern University Abstract In the last decade, multi-threaded systems and resource sharing have brought a number of technologies that facilitate our daily tasks in a way we never imagined. Among others, cloud computing has emerged to offer us powerful computational resources without having to physically acquire and install them, while smartphones have almost acquired the same importance desktop computers had a decade ago. This has only been possible thanks to the ever evolving performance optimization improvements made to modern microarchitectures that efficiently manage concur- rent usage of hardware resources. One of the aforementioned optimizations is the usage of shared Last Level Caches (LLCs) to balance different CPU core loads and to maintain coherency between shared memory blocks utilized by different cores. The latter for instance has enabled concurrent execution of several processes in low RAM devices such as smartphones. Although efficient hardware resource sharing has become the de-facto model for several modern technologies, it also poses a major concern with respect to security. Some of the concurrently executed co-resident processes might in fact be malicious and try to take advantage of hardware proximity. New technologies usually claim to be secure by implementing sandboxing techniques and executing processes in isolated software environments, called Virtual Machines (VMs). However, the design of these isolated environments aims at preventing pure software-based attacks and usually does not consider hardware leakages. In fact, the malicious utilization of hardware resources as covert channels might have severe consequences to the privacy of the customers. Our work demonstrates that malicious customers of such technologies can utilize the LLC as the covert channel to obtain sensitive information from a co-resident victim. We show that the LLC is an attractive resource to be targeted by attackers, as it offers high resolution and, unlike previous microarchitectural attacks, does not require core-colocation. Particularly concerning are the cases in which cryptography is compromised, as it is the main component of every security solution. In this sense, the presented work does not only introduce three attack variants that can be applicable in different scenarios, but also demonstrates the ability to recover cryptographic keys (e.g. AES and RSA) and TLS session messages across VMs, bypassing sandboxing techniques. Finally, two countermeasures to prevent microarchitectural attacks in general and LLC attacks in particular from retrieving fine-grain information are presented. Unlike previously proposed countermeasures, ours do not add permanent overheads in the system but can be utilized as preemptive defenses. The first identifies leakages in cryptographic software that can potentially lead to key extraction, and thus, can be utilized by cryptographic code designers to ensure the sanity of their libraries before deployment. The second detects microarchitectural attacks embedded into innocent-looking binaries, preventing them from being posted in official application repositories that usually have the full trust of the customer. 2 Acknowledgements The attacks described in Chapter 4 are based on collaborative work with Mehmet Sinan Inci_ and resulted in peer-reviewed publications [IIES14b, IIES15]. The content presented in Chapter 5 has been published as [IES16]. Parts of the results introduced in Chapter 6 are based joint work with Mehmet Sinan Inci_ and Berk Gulmezoglu and resulted in publication [IGI_ +16a]. The rest of the content of Chapter 6 has been published in [IES15a, IES15b] The vulnerability analysis described in Chapter 7 was performed jointly with Intel employes Xiaofei Guo, Hareesh Khattri, Arun Kanuparthi and Kai Cong, and it is under submission for a peer-review venue. The remaining contributions in the chapter have also been submitted to a peer-review conference. This work was supported by the National Science Foundation (NSF), under grants CNS-1318919, CNS-1314770 and CNS-1618837. This thesis is the result of several years of effort that would not have been successful without the collaboration, both in a professional and personal way, of certain people to whom I would like to express my gratitude. My two advisors Thomas Eisenbarth and Berk Sunar have given me confidence and freedom to achieve the results presented in this thesis. Without their knowledge, advise and personal treatment this journey would have been much more complicated. They were able to take the best out of my skills, and sometimes even believed in me more than I did. I will always feel that part of the achievements that I will accomplish during my career will belong to them. As part of this thesis I had the chance of working closely to Yuval Yarom and Xiaofei Guo. Besides the pleasure that it was working with them, with both of them I established a relationship that goes beyond our professional collaborations. I wish them the best of the lucks in both their professional careers and their personal lives. I would like to thank the members of the Vernam lab, for being such a great support in the most difficult moments. Every single person in the lab was helpful at some specific point during the last 4 years. I am looking forward to maintain the good relationships we built in the upcoming years. I also would like to express my gratitude to the One United and E soccer team members, who gave me the distraction that every person needs to accomplish profes- sional success. Besides the three tournaments that we won together, they provided me an invaluable personal support which produced friendship relationships that I will never forget. They can feel proud of being one of the most positive things I take from this experience. My parents and my sister have always been the first ones believing in me, and have a great influence in any success I achieve in my personal career. Although they already know what they mean to me, I would still like to thank them for everything they do to take always the best of me. I cannot imagine a better source of strength for the upcoming challenges. i Finally, I would like to thank Elena Gonzalez for being the best person I could ever find to stay by my side. Despite all the obstacles she never gave up on us. I will always be in debt with her for all the support she gave me to complete this thesis. She has shown me personal values that I hardly find in other people, and that I am willing to enjoy everyday from now on. ii Contents 1 Introduction 1 2 Background 6 2.1 Side Channel Attacks . .6 2.2 Computer Microarchitecture . .7 2.2.1 Hardware Caches . .8 2.3 The Cache as a Covert Channel . 11 2.3.1 The Evict and Time attack . 11 2.3.2 The Prime and Probe Attack . 13 2.4 Funcionality of Commonly Used Cryptographic Algorithms . 13 2.4.1 AES . 13 2.4.2 RSA . 16 2.4.3 Elliptic Curve Cryptography . 19 3 Related Work 21 3.1 Classical Side Channel Attacks . 21 3.1.1 Timing Attacks . 21 3.1.2 Power Attacks . 22 3.2 Microarchitectural Attacks . 23 3.2.1 Hyper-threading . 24 iii 3.2.2 Branch Prediction Unit Attacks . 24 3.2.3 Out-of-order Execution Attacks . 25 3.2.4 Performance Monitoring Units . 26 3.2.5 Special Instructions . 26 3.2.6 Hardware Caches . 27 3.2.7 Cache Internals . 28 3.2.8 Cache Pre-Fetching . 29 3.2.9 Other Attacks on Caches . 29 3.2.10 Memory Bus Locking Attacks . 30 3.2.11 DRAM and Rowhammer Attacks . 30 3.2.12 TEE Attacks . 31 3.2.13 Cross-core/-CPU Attacks . 32 4 The Flush and Reload attack 34 4.1 Flush and Reload Requirements . 35 4.2 Memory Deduplication . 36 4.3 Flush and Reload Functionality . 37 4.4 Flush and Reload Attacking AES . 39 4.4.1 Description of the Attack . 40 4.4.2 Recovering the Full Key . 42 4.4.3 Attack Scenario 1: Spy Process . 44 4.4.4 Attack Scenario 2: Cross-VM Attack . 45 4.4.5 Experiment Setup and Results . 45 4.4.6 Comparison to Other Attacks . 47 4.5 Flush and Reload Attacking Transport Layer Security: Re-viving the Lucky 13 Attack . 49 4.5.1 The TLS Record Protocol . 49 iv 4.5.2 HMAC . 50 4.5.3 CBC Encryption & Padding . 51 4.5.4 An Attack On CBC Encryption . 51 4.5.5 Analysis of Lucky 13 Patches . 52 4.5.6 Patches Immune to Flush and Reload .............. 53 4.5.7 Patches Vulnerable to Flush and Reload ............ 53 4.5.8 Reviving Lucky 13 on the Cloud . 55 4.5.9 Experiment Setup and Results . 59 4.6 Flush and Reload Outcomes . 62 5 The First Cross-CPU Attack: Invalidate and Transfer 64 5.1 Cache Coherence Protocols . 65 5.1.1 AMD HyperTransport Technology . 67 5.1.2 Intel QuickPath Interconnect Technology . 68 5.2 Invalidate and Transfer Attack Procedure . 69 5.3 Exploiting the New Covert Channel . 71 5.3.1 Attacking Table Based AES . 72 5.3.2 Attacking Square and Multiply El Gamal Decryption . 72 5.4 Experiment Setup and Results . 73 5.4.1 Experiment Setup . 74 5.4.2 AES Results . 74 5.4.3 El Gamal Results . 76 5.5 Invalidate and Transfer Outcomes .