Isolating Commodity Hosted Hypervisors with Hyperlock
Total Page:16
File Type:pdf, Size:1020Kb
Isolating Commodity Hosted Hypervisors with HyperLock Zhi Wang Chiachih Wu Michael Grace Xuxian Jiang Department of Computer Science North Carolina State University {zhi wang, cwu10, mcgrace}@ncsu.edu [email protected] Abstract 1. Introduction Hosted hypervisors (e.g., KVM) are being widely deployed. Recent years have witnessed the accelerated adoption of One key reason is that they can effectively take advantage of hosted or Type-II hypervisors (e.g., KVM [19]). Compared the mature features and broad user bases of commodity oper- to bare-metal or Type-I hypervisors (e.g., Xen [5]) that run ating systems. However, they are not immune to exploitable directly on the hardware, hosted hypervisors typically run software bugs. Particularly, due to the close integration with within a conventional operating system (OS) and rely on the host and the unique presence underneath guest virtual this “host” OS to manage most system resources. By doing machines, a hosted hypervisor – if compromised – can also so, hosted hypervisors can immediately benefit from various jeopardize the host system and completely take over all key features of the host OS that are mature and stable, guests in the same physical machine. including abundant and timely hardware support, advanced In this paper, we present HyperLock, a systematic ap- memory management, efficient process scheduling, and so proach to strictly isolate privileged, but potentially vul- forth. Moreover, a hosted hypervisor extends the host OS nerable, hosted hypervisors from compromising the host non-intrusively as a loadable kernel module, which is ar- OSs. Specifically, we provide a secure hypervisor isolation guably much easier to install and maintain than a bare-metal runtime with its own separated address space and a restricted hypervisor. Due to these unique benefits, hosted hypervisors instruction set for safe execution. In addition, we propose are increasingly being adopted in today’s virtualization another technique, i.e., hypervisor shadowing, to efficiently systems [28]. create a separate shadow hypervisor and pair it with each From another perspective, despite recent advances in guest so that a compromised hypervisor can affect only hardware virtualization (such as Intel VT [18]), virtualizing the paired guest, not others. We have built a proof-of- a computer system is still a complex task. For example, concept HyperLock prototype to confine the popular KVM a commodity hosted hypervisor, such as KVM, typically hypervisor on Linux. Our results show that HyperLock has a involves a convoluted shadow paging mechanism to virtu- much smaller (12%) trusted computing base (TCB) than the alize the guest memory (including emulating five different original KVM. Moreover, our system completely removes modes of operation in x86: paging disabled, paging with 2, QEMU, the companion user program of KVM (with > 3, or 4 levels of page tables, and hardware assisted memory 531K SLOC), from the TCB. The security experiments and virtualization, including EPT/NPT [18]). For performance performance measurements also demonstrated the practical- reasons, many hypervisors also support an “out-of-sync” ity and effectiveness of our approach. (OOS) shadow paging scheme that synchronizes the shadow page table with the guest only when absolutely necessary. In Categories and Subject Descriptors D.4.6 [Operating Sys- addition, hosted hypervisors still suffer from a large attack tems]: Security and Protection—Security kernels surface, because they take many untrusted guest virtual General Terms Design, Security machine (VM) states as input. For example, shadow paging needs to read guest page tables for synchronization, while Keywords Virtualization, Hypervisor, KVM, Isolation instruction emulation – another complicated component of a hypervisor – involves fetching guest instructions for interpretation and execution. Due to inherent high complexity and broad attack surface, Permission to make digital or hard copies of all or part of this work for personal or contemporary hosted hypervisors are not immune to serious classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation security vulnerabilities. A recent study of the National on the first page. To copy otherwise, to republish, to post on servers or to redistribute Vulnerability Database (NVD) [25] indicates that there were to lists, requires prior specific permission and/or a fee. 24 security vulnerabilities found in KVM and 49 in VMware EuroSys’12, April 10–13, 2012, Bern, Switzerland. Copyright c 2012 ACM 978-1-4503-1223-3/12/04. $10.00 Workstation over the last three years. These vulnerabilities can be potentially exploited to execute arbitrary code with measurement. To summarize, this paper makes the following the highest privilege, putting the whole host system at contributions: risk. In fact, successful attacks against both KVM [12] and • To address the imperative need to confine commodity VMware Workstation [21] have been publicly demonstrated hosted hypervisors, we propose a secure hypervisor iso- to escape from a guest VM and directly attack the host OS. lation runtime with a dedicated address space and a Worse, a compromised hypervisor can also easily take over reduced instruction set to strictly confine their execution. all the other guests, leading to disruption of hosted services To the best of our knowledge, the proposed hypervisor or stealing of sensitive information. This can have a devas- isolation runtime is among the first to isolate hosted tating effect in the scenario where a single physical machine hypervisors and protect the host OSs from being jeop- may host multiple VMs from different organizations (e.g., ardized by them. in a cloud setting). In light of the above threats, there is a pressing need to secure these hosted hypervisors and protect • To effectively prevent a compromised hosted hypervisor the host system – as well as the other guest VMs – from a from taking over all guests in the same physical ma- compromised hypervisor. chine, we propose another key technique, i.e., hypervisor To address the need, researchers have explored a number shadowing, to create a guest-specific shadow hypervisor of approaches. For example, seL4 [20] takes a formal without additional resource overhead. By doing so, we approach to verify that a small micro-kernel (∼8.7K source ensure that a compromised hypervisor will only affect the lines of code or SLOC) is secure including the absence of corresponding guest, not others. certain software vulnerabilities (e.g., buffer overruns and • We have developed a HyperLock prototype and used it NULL pointer references). However, it is not scalable or still to protect the popular KVM hypervisor. Our prototype incomplete in accommodating commodity hypervisors (e.g., introduces a very small TCB (∼4K SLOC) to the current KVM) that have a much larger code base and support various OS kernel while completely removing the original KVM complex x86 CPU/chipset features [30]. HyperSafe [39] code (∼33.6K SLOC) as well as the companion QEMU enables self-protection for bare-metal hypervisors to enforce program (∼531K SLOC) from the TCB of the host their control flow integrity. Unfortunately, as admitted in OS. The security analysis and evaluation with standard [39], the proposed approach cannot be applied for hosted benchmark programs shows that our prototype is not hypervisors due to different design choices in the commodity only effective, but also lightweight (< 5% performance host OS (e.g. frequent page table updates) from bare-metal slowdown). hypervisors. Other approaches [32, 42] take a layer-below method to isolate untrusted device drivers, which is also The rest of the paper is structured as follows: we first not applicable because hosted hypervisors already run at the present the design of HyperLock with a focus on the lowest level on the system. KVM hypervisor in Section 2. After that, we discuss the In this paper, we present HyperLock, a system that is implementation and evaluation of HyperLock in Sections 3, able to establish a tight security boundary to isolate hosted and 4, respectively. Issues and possible improvements are hypervisors. Specifically, we encapsulate the execution of discussed in Section 5. Finally, we describe related work in a hosted hypervisor with a secure hypervisor isolation Section 6 and conclude the paper in Section 7. runtime, which has its own separate address space and a 2. Design reduced instruction set for safe execution. By doing so, the host system is not accessible to the hypervisor. Instead, it Before presenting our system design, we first briefly review must go through a well-defined interface, which is mediated the basic architecture of existing hosted hypervisors and and sufficiently narrowed-down by HyperLock to block the associated threat model. For simplicity, we use KVM any unexpected side-effects. Moreover, we further propose as the representative example throughout the paper. As a a hypervisor shadowing technique, which can efficiently popular, open-source hypervisor, KVM is incredibly simple create a separate shadow hypervisor for (and pair it with) to deploy and run. It can be dynamically loaded as a kernel each guest so that a compromised hypervisor can affect only module on Linux and once loaded, it instantly extends the the paired guest, not others. By exploiting recent memory host OS with virtualization support (based on hardware de-duplication techniques, these shadow hypervisors can be virtualization extensions such as Intel VT [18]). KVM created without incurring additional resource overhead. uses a companion user program, i.e., a QEMU variant, to We have implemented a proof-of-concept HyperLock cooperatively emulate hardware devices for a guest (e.g., prototype for the popular KVM hypervisor (version kvm- hard disks). In Figure 1(a), we show the main execution flow 2.6.36.1 and qemu-0.14.0). Our experience shows that Hy- of a KVM-powered guest, which involves close interaction perLock can be implemented with a small code base (∼4K between KVM and QEMU.