Analysis of Firmware Security in Embedded ARM Environments
Total Page:16
File Type:pdf, Size:1020Kb
Analysis of Firmware Security in Embedded ARM Environments Dane A. Brown Dissertation submitted to the Faculty of the Virginia Polytechnic Institute and State University in partial fulfillment of the requirements for the degree of Doctor of Philosophy in Computer Engineering T. Charles Clancy, Chair Ryan Gerdes Yaling Yang Jonathan Black Patrick Schaumont August 13, 2019 Arlington, Virginia Keywords: Security, Firmware, Embedded Devices, ARM Copyright 2019, Dane A. Brown Analysis of Firmware Security in Embedded ARM Environments Dane A. Brown (ABSTRACT) Modern enterprise-grade systems with virtually unlimited resources have many options when it comes to implementing state of the art intrusion prevention and detection solutions. These solutions are costly in terms of energy, execution time, circuit board area, and capital. Sus- tainable Internet of Things devices and power-constrained embedded systems are thus forced to make suboptimal security trade-offs. One such trade-off is the design of architectures which prevent execution of injected shell code, yet have allowed Return Oriented Program- ming (ROP) to emerge as a more reliable way to execute malicious code following attacks. ROP is a method used to take over the execution of a program by causing the return address of a function to be modified through an exploit vector, then returning to small segments of otherwise innocuous code located in executable memory one after the other to carry out the attacker’s aims. We show that the Tiva TM4C123GH6PM microcontroller, which utilizes an ARM Cortex-M4F processor, can be fully controlled with this technique. Firmware code is pre-loaded into a ROM on Tiva microcontrollers which can be subverted to erase and rewrite the flash memory where the program resides. That same firmware is searched for a Turing- complete gadget set which allows for arbitrary execution. We then design and evaluate a method for verifying the integrity of firmware on embedded systems, in this case Solid State Drives (SSDs). Some manufacturers make firmware updates available, but their proprietary protections leave end users unable to verify the authenticity of the firmware post installa- tion. This means that attackers who are able to get a malicious firmware version installed on a victim SSD are able to operate with full impunity, as the owner will have no tools for detection. We have devised a method for performing side channel analysis of the current drawn by an SSD, which can compare its behavior while running genuine firmware against its behavior when running modified firmware. We train a binary classifier with samples of both versions and are able to consistently discriminate between genuine firmware and modified firmware, even despite changes in external factors such as temperature and supplied power. Analysis of Firmware Security in Embedded ARM Environments Dane A. Brown (GENERAL AUDIENCE ABSTRACT) To most consumers and enterprises, a computer is the desktop or laptop device they use to run applications or write reports. Security for these computers has been a top priority since the advent of the Internet and the security landscape has matured considerably since that time. Yet, these consumer-facing computers are outnumbered several times over by embedded computers and microcontrollers which power ubiquitous systems in industrial control, home automation, and the Internet of Things. Unfortunately, the security landscape for these embedded systems is in relative infancy. Security controls designed for consumer and enterprise computers are often poorly suited for embedded system due to constraints such as power, memory, processing, and real-time performance demands. This research considers the unique constraints of embedded systems and analyzes their security in a practical way. We begin by exploring the mechanism and extent to which a device can be compromised. We show that a technique known as Return Oriented Programming (ROP) can be used to bypass some of the process control protections in place and that there can be enough existing code in the firmware to allow an attacker to execute code at will. This leads naturally to the question of how embedded computers can be secured. One important security assurance is the knowledge that a device is running legitimate firmware. This can be difficult for a device owner to verify due to proprietary protections put in place by manufacturers. However, we contribute a method to detect modifications to firmware on embedded systems, particularly Solid State Drives. This is done through an analysis of the current drawn during drive operations with best-practice data classification techniques. The findings of this research indicate that current embedded devices present a larger surface area for attack, less sophistication required for attack, and a larger quantity of devices vulnerable to attack. Even though these findings should raise concern, we also found that there are practical methods for detecting attack via monitoring and analysis. Dedication I dedicate this work to my wife, Jennifer, my daughter, Elliana, my son, Edison, and my mother, Roberta. Jennifer has sacrificed her time and goals selflessly as I have pursued this Ph.D. My children have been my biggest cheerleaders and have always been there to lift my spirits. My mother has been a constant source of support, whether I needed childcare or just a word of encouragement. I am eternally grateful to my family for their love and support. Finally, I dedicate this work to my God above for giving me the determination and stamina to complete this process in the midst of several demanding life obligations. i Acknowledgments I would like to first acknowledge my committee chair, Dr T. Charles Clancy, for his guidance throughout this daunting process. I also acknowledge the constructive criticism and outside perspectives offered by the rest of my committee: Dr. Ryan Gerdes, Dr. Yaling Yang, Dr. Patrick Schaumont, and Dr. Jonathan Black. I need to acknowledge those who helped me perform the research, starting with Dr. Nathanael Weidler who was my chief collaborator on Return Oriented Programming work. I also need to thank my research group at the U.S. Naval Academy, the Computer Engineering and Cyber Security Research group (CECSR), in particular Dr. T. Owens Walker, Dr. Robert Ives, Dr. Justin Blanco, and Dr. Ryan Rakvic worked very closely with me to plan, collect, and analyze data for the Solid State Drive research. Finally, I would like to thank the students and interns who volunteered their time to assist me in data collection and script writing: Midshipman Rupam Mondal, Ensign Zachary Johnson, Mr. Bernie Cieplak, Mr. Ryan McDowell, and Mr. Tsegazeab Beteselassie. ii Contents List of Figures vii List of Tables xi 1 Introduction 1 1.1 Vulnerability of Embedded Systems ....................... 3 1.2 Ubiquitous Microcontrollers ........................... 4 1.2.1 Rapid Prototyping of Inexpensive Devices ............... 5 1.2.2 Internet of Things ............................ 5 1.3 Review of Security Analysis Techniques ..................... 6 1.3.1 Buffer Overflow Attacks ......................... 6 1.3.2 Return Oriented Programming ..................... 7 1.3.3 Side Channel Analysis .......................... 8 1.3.4 Data Classification ............................ 8 1.4 Thesis Statement and Research Questions ................... 9 1.5 Contributions ................................... 10 1.5.1 Return Oriented Programming Contributions ............. 11 1.5.2 Detection of Modified Firmware Contributions ............. 12 iii 1.6 Organization of the Dissertation ......................... 13 2 Return Oriented Programming on Embedded Firmware 15 2.1 Microcontroller Security ............................. 15 2.1.1 Security versus Sustainability ...................... 16 2.1.2 Related Work ............................... 18 2.1.3 Thumb Instruction Set .......................... 19 2.1.4 Threat Model ............................... 19 2.2 Return-Oriented Programming on ARM Architectures ............ 20 2.3 Erasing and Programming Flash Memory .................... 24 2.3.1 Finding Gadgets ............................. 25 2.3.2 Reprogramming Method ......................... 26 2.3.3 Demonstration of Writing a Simple Program to Flash ......... 29 2.3.4 Second Gadget Set ............................ 31 2.4 Turing-complete Gadget Set ........................... 34 2.4.1 Requirement ............................... 37 2.4.2 Gadgets from the Tiva C ........................ 37 2.5 Experimental Results ............................... 49 3 Security Analysis of Solid State Drive Firmware 58 3.1 Solid State Drive Security ............................ 58 iv 3.2 Related Work ................................... 59 3.3 Jasmine Flash Translation Layers ........................ 62 3.4 Threat Model ................................... 64 3.4.1 Ownership Trust Boundary ....................... 64 3.4.2 Internet Trust Boundary ......................... 67 3.4.3 Physical Trust Boundary ......................... 67 3.4.4 Threat Model Review .......................... 68 3.5 Malicious Code Injection ............................. 68 3.5.1 Denying Garbage Collection ....................... 69 3.5.2 Formatting NAND Flash ......................... 70 3.5.3 Clearing DRAM Buffers ......................... 71 4 Detection of Modified Firmware on Solid State Drives 73 4.1 Detecting Modified Firmware .......................... 73 4.1.1 Data Collection Setup .......................... 73 4.1.2 Data Processing