Virtual Machine escapes Abdul Ali, School of Computing, Engineering and Information Sciences Northumbria University, Newcastle upon Tyne, United Kingdom
[email protected]
Abstract. The threat of breaking out the virtual machines to interact directly with the hypervisor is known as virtual machine escape, as the hypervisor controls all operations of the guest operating systems, consequently if an attacker gains access to the hypervisor, nonetheless gains control on all virtual machines running on that hypervisor. This paper describes the architecture of virtual machine system and the possibilities of VM escape, as well as demonstrates an example of malware behaviours inside OS guest running on a virtual machine. Keywords: Virtualisation, Virtual Machine, Hypervisor, VMM, Malware, Rootkit, VMBR.
1 Introduction Virtualization is an efficient solution for many businesses and enterprises, which they have issues such as space, cost, and cooling system. virtualization requires lower space , reduce the overall cost of any IT project, provides energy savings, and eliminates the need of cooling system, for which is required in some particular computing systems such as severs, additionally virtualization has techniques that used for disaster recovery, that would increase the utilization for businesses. Virtualization provides security benefits for businesses using cloud computing, it centralised storage environment, isolation of applications, and provides security defence layer. However virtualization has complex security issues and handling them is quite complicated, that because virtualization has abstract layer between the hardware and operating systems running on it, this layer is known as hypervisor. Hypervisor also known as virtual Machine Monitor (VMM) is designed to run multiple operating systems in single physical system. These operating systems are logically isolated from each other. Hypervisor allows these operating systems to use same resources such as CPU, RAM, and etc., and it increases their utilization. Hypervisor runs beside the host
operating system (or in some cases replaces it) on the most privileged level (ring 0) that allows the hypervisor to control all hardware and functions of the native physical machine, therefore it emulates these resources and then provides OS guests access to these resources, and controls their executions. Assume that an attacker Compromised the security of the hypervisor, and successfully have a control with it, and then it would be tsunami for the rest of the systems run on that hypervisor, which includes all guests operating systems, and all resources, therefore it is been a tempted target for attackers and defenders. Virtualization architecture, the techniques used for emulation and security issues related to it are discussed in the next sections.
1.1
Virtualization architecture Overview
Virtualization is software emulation of complete system platform that runs operating system likewise physical machine .so to empathise how the virtual machine software actually works we need to be aware of the modern operating systems, and how they work. Computer system is a combination of the operating system and the underlying hardware, this combination deliver a complete operation, which it can concurrently support a number of processes potentially belonging to different handlers. These processes share a software platform and hardware resources. The operating system allocates physical memory and I/O resources to processes and connects them with their resources [1]. The computer architecture of a processor has two main parts: -
-
Part 1: Software architecture, this part is including all properties of the design that are visible to programmer. Also it is referred to Instruction Set Architecture or (ISA) [2]. Part 2: Hardware architecture, this part includes the set of all hardware architectures for specified software architecture; also it is referred to processor family for example Intel x 86 families [2].
Virtual machine is a complete system environment, this environment supports an operating system and its processes, so it supplies an operating system with access to underlying resources, these resources include hardware resources such as I/O, display and graphical user interface, network interface card (NIC), etc. [1]. There are two hypervisor types: 1- Hypervisors run directly above the host hardware level and underneath the guest’s
operating system, thus it can manage the guest operating systems and control their access to the hardware, this type called bare metal see figure 1.a [3].
2- The second type of Hypervisors, the hypervisor runs on the host operating system,
and setup a connection for guest’s operating systems above it to provide management and accessibility for them, this type called hosted hypervisor see figure 1.b [3].
a) Bare metal hypervisor (Type 1)
( b) hosted hypervisor(Type 2)
Figure 1: Hypervisor Types [4]. Software VMM like VMware workstation and Virtual PC, use binary translation to fully virtualise x86.X86 Virtual machine provides security and resource management, fault containment, and server consolidation [5]. To empathise the security issues of the hypervisors, we need to understand the privilege levels for X86 CPU see figure 2 & 3, the most privileged level is ring 0, so that means any software at this level has a full control of the host hardware. Ring 0 also known as Kernel mode, ring 1 is less privilege than ring 0, ring 3 known as User Mode and all application functions execute on ring 3 [3].
Figure 2: x86 Processor privilege levels (rings) [3]. Virtual Machine Monitor (VMM) runs in the most privileged level, referred to as ring 0 or kernel mode, on the other hand the guests operating systems run on less privilege level than VMM, which ring 1.
Figure 3: Hypervisor Architecture (Type 1) [6]. As in the figure 3, Ring 0 is the most privileged layer, ring 1 is a bit less privileged. Ring 3 is where the user applications reside with no privileges to manage the hardware resources at all. Therefore VMM controls the guest operating system access to hardware resources [6]. VMware doesn’t have to translate from one Instruction Set Architecture (ISA) to another but it is based on an x86 to x86 translator. In fact in some cases it just makes an exact copy of the original instructor. VMware translate the binary code that the kernel of guest OS wants to execute on the fly and stores the adapted x86 code in a Translator Cache (TC). User applications will not be touched by VMware’s Binary Translator (BT) as it knows /assumes that user code is safe. User mode applications are executed directly as if they were running natively [1]. In term of emulation, virtualisation is classified into three types: 1- Full virtualisation, it is an approach provide the guest OS to directly run instruction
via an altered hypervisor, therefore it doesn’t requires any extra handler and enhance the performance and the security of the system, example for this approach VMware VM [7]. 2Para-Virtualisation, this approach requires altering the guest operating system side by side with the hypervisor to gets access to the virtualised hardware. Clearly ParaVirtualisation requires modification of the guest operating system example for this approach Xen VM [7]. 3- Another approach is requires altered hardware to directly supports emulation instructions without need to translation, example of that Intel and AMD provides virtualisation technology. Virtualisation technologies developed by Intel and AMD, allow the hypervisor executes in ring 0 the privilege mode, and access the resources in that particular machine, example for this approach Linux-VServer [7].
The recent virtualisation provides techniques to support virtual memory with physical address translation and page table to deliver memory isolation, in CPU: virtual addresses are translated to physical addresses with translation look-aside buffers (TLBs). The page table register points to top-level page table entry, which must be accurately set. In x86 architectures, CR3 register stores the address of the top-level page table [8]. Virtualisation provides additional layer for translation purpose, a guest virtual machine holds virtual address, this address must be translated into physical address, and this physical address would be equivalent to the guest virtual address, instantly it will be translated into real physical memory. The guest operating system maps virtual address to physical address in per-process page tables and the hypervisor provides mapping to guest-physical address called nested page tables. The hypervisor provides translation table called shadow page tables; it is purpose is to map virtual addresses to physical addresses [8]. Hypervisor must protect nested page tables, so that the guest virtual machines must not read or change the nested page tables and hypervisor must change the pointer on the nested page table, Memory allocation managed by the hypervisor that by monitoring memory handlings, allocate, and de-allocate pages for a virtual machine. Hypervisor accesses its own memory space by using similar address translation method [8]. The guest operating system running on virtual machine needs to translate its addresses into physical addresses; however the guest operating system runs on ring 1, with less privilege than what is required to access the real addresses (page tables) in the native memory. In fact the hypervisor emulates memory management unit (MMU) therefore the guest OS access the page tables through hypervisor, the hypervisor uses shadow pages tables, so the guest OS cannot sees the real page tables, and only sees the shadow pages tables, which translate the guest OS addresses into the native addresses [7]. Guest OS needs to communicate with hypervisor to access the virtual hardware components; in most virtualisation software systems the hypervisor emulates the rest of the existence hardware in the real machine [7]. Hypervisor is a piece of code, this piece of code needs to be minimal as much as possible to prevent security vulnerabilities in the hypervisor (privilege layer), hypervisor security explained in next section.
2 Virtualization Security
Hypervisor provides isolation between guest OS, also manages their access to a virtualised hardware. This isolation is huge concern for the VM security, because it is a robust technique to prevent the guest OS from attacks which could possibly infect the entire guests OS. This could be advantage for the security defenders; on the other hand it also could benefit the attackers and by cause security tsunami disaster exploitation for the whole system.
If a sophisticated attacker dominates the hypervisor, at this point the attacker has full control over all the resources within the hypervisor that include the guests OS run on it. this means that the attacker successfully exploited ring 0 on the host without further escalation, however possibilities of this attack is very complex because the hypervisor has less code and runs on most privilege level of security see figure 3 [9]. This type of attack is very critical to company has a cloud architecture. A recent attack at a UK company called Vaserv.com is an obvious proof of such security threat to hypervisor. The attacker used zero-day vulnerability in the Hypervisor to launch the attack over a virtualization application made by the company. 100,000 websites hosted by veserv.com had been destroyed. The zero-day vulnerability gave the hackers the capability to run privileged UNIX commands on the targeted system, these commands include (rm –rf), which causes a recursive delete of all files. The attack has caused a massive damage to the company, 50% of Vaserv’s clients have lost their data [10]. Note that, rm is a UNIX command; by default it deletes a file without confirmation. rm –f ,it means removes all files even if write-protected in a directory without prompting the user[11]. Alternative approach for an attacker is to compromise the virtualization system is to exploit the virtual machine runs above the hypervisor that can be possible if an attacker runs code on a virtual machine that allows an operating system running inside the hypervisor to break out and interact directly with it. This type of attack could allow the attacker access to the host operating system as well as all virtual machines running on that host. This is called virtual machine escape. There are several types of Virtual machine escape that might be possible. The security researches Tom Liston and Ed Skoudis demonstrated several tools that might be developed to create VM escape attacks [12]. These tools are: -
-
-
VMchat: this simple chat software used the VMware hypervisor communication channel as backdoor to send messages back and forth between guest’s operating systems or between guest’s operating system and the host. This simple software did not require any special code to be installed. A DLL injection attack can exploit VMware on the host operating system, so that it allows application running on the host access to the memory of the guest VMware machine, when this happened , the memory buffer will be used as exchange channel between the host machine and client as a shared buffer. This tool is not completely escape the virtual machine; however exploit the boundary between host machine and VMware [12]. VMcat: this tool extension for the VMchat idea to send simple output of (stdin) and (stdout) between the communication channel created with VMchat, which can be used to tunnel a command shell between hosts and guest [12]. VM Drag-n-Sploit: by altering VMware component on the guest (VMwareService.exe), the researchers were successful to monitor and change all data
passing over the communication channel. This allowed running code in the guest OS that could permit a file being drag-n-dropped to be replaced with arbitrary file [12]. VMftp: a user on any guest operating system with any level of privilege is able to read and write data to the host operating system throughout shared folder is enabled and one folder is shared with a guest VM [12]. In 2008, the security researches Tom Liston and Ed Skoudis demonstrated the above testing tools revealed a fault in certain versions of VMware Player, ACE, and Workstation that grants an attacker to remotely or locally exploit the VMware Shared Folders feature (shared folders allows easily exchange data between an OS running on the virtual machine and host OS), as well as read or write to any area of the underlying host [10] [11] [12]. Malicious software could be used for VM escape exploitation; malware cannot break the isolation offered by the virtualization that means malware cannot infect from one guest OS to another, or to the host OS. These isolation cause attackers to find other techniques to detect the existence of virtualization software, Virtualization-aware malware is an example of these techniques, it has the ability to adapt its behaviour consequently, either by attacking the hypervisor VMM layer, or directly attacking the guest OS running on the hypervisor. This discussed in next section [13]. There are three types of malware attacks that can be used to exploit virtual machine: 1- The easiest attack, which can be performed by using malicious software used to
detects the virtual machine emulator. Malicious code such as this very sensitive to the existence of VM. The purpose of detecting the VM platform is to make the analysis of malware harder and even undetectable for the malware researchers. 2- Complicated attack, such as denial of service, which can cause the VM emulator to crash. 3- The most complex attack is virtual machine escape attack [14]. 2.1 Malware and virtualisation
The malware designers have been striving to exploit the virtualization systems, however the isolation on privilege layer created by hypervisor made it harder to them to break out the virtualise system, hypervisor isolates its guest operating systems, and every single guest OS has the responsibility to protect its own security territory. Malware researches have been using Virtualization system to detect, hunt, and debug malware activities (honeypot). Which is inconvenience for malware designers (attackers), and also it is harder to identify the existence of the hypervisor that challenged the malware designers (attackers) to find new techniques to compromise the hypervisor [3]. Malware is becoming increasingly sneaky, enhanced with adding new techniques such the ability to detect and remove protection software such as anti-malware and antivirus, hide their
presence, and kernel-level malware. Virtualisation-aware malware uses technique to detect the system environment, so if discovered that a system is virtualised, then it will adapt itself to take advantage of virtualization environment, this type of malware called virtual machine based rootkit (VMBR) [3], it is difficult to detect or remove, hide its footprint and activity from malware detectors, VMBR has the ability to breach guest OS, and then find its way to the break out and attack the hypervisor, or by directly attacking the hypervisor and taking control of the whole system [3]. Blue Pill is an example of VMBR created by Researcher Joana Ruthowska, she claimed that it is 100% undetectable piece of malware, and she assumed that if the Virtual machine take over host OS (example of that install Xen on a running copy of Windows XP) then it would hide a malware from that VM by remaining within the VMM .However it is very hard for VMM to take over a host OS, but it is impossible just needs a massive work[3] [15] Blue Pill was basically a rootkit that targeted the windows Vista platform by hijacking AMD processor SVM virtualisation capabilities. it uses rootkit to creates a hypervisor that encapsulate the Vista OS ,so Vista operating system would no longer be trusted, it runs on the top of the hypervisor privilege layer taking full control over the whole system. Vitriol malware work exactly as Blue Pill except it is hijacking Intel CPU [15]. Similar techniques are used by SubVirt malware, but with less threat. SubVirt hides its state so it is difficult for anti-malware to detect [3]. However SubVirt installs a fake operating system, it becomes the host operating system, that OS has specific VM emulator, SubVirt support both Windows (carries Virtual PC) and Linux platform(carries VMware), when new host OS runs, then the VM emulator locates the host OS to a VM and keep running as normal(normal as user sees it but in fact it is compromised )[14].when the host loads and runs the new operating system then the VM emulator replaces the original host operating system into virtual machine and continues its operation as normal as it is seen by hypervisor , however the system has been compromised [14][16]. There are three differences between Blue Pill malware and SubVirt rootkit: -
SubVirt is a permanent (i.e. it doesn’t effect if VM restarted ), because SubVirt takes control of the VM before the original OS boots. SubVirt was implemented on Intel x86. Subvirt is on only one VMM, which is Virtual PC or VMware [16].
Figure 4: VMBR operation [16].
2.2 SubVirt Malware Implementation
The purpose of all rootkits is hiding an intruder’s existence that will allow the intruders to take full control of the virtual system without being detected by security system. The first task of a VMBR is to hide its entity, to accomplish this task the VMBR needs to loads before the operating system and applications ,that will only be done by manipulate the boot sequence of the system see figure 5.a & b. Therefore the VMBR boots the operating system using the hypervisor (VMM).then the operating system carries as usual, however VMBR has hidden underneath the operating system. An attacker target a VM system need to gain access the privilege level (ring 0), then install the VMBR’s state on disk, if the target is Windows XP ,the state of VMBR stored in the first active partition of the disk, and if the system is Linux , it stores its state using swap partition[16].
a) Before SubVirt attack
b) After SubVirt Figure 5: installing VMBR [17]
Virtual Machine Based Rootkit (VMBR) operation can be explained in four stages: -
VMBR starts running in privilege layer (ring 0), getting into the hypervisor, and launch its malicious activities onto it. It reserves memory space, which would be used for the malicious operation. The infected host OS is migrated to a VM created by the hypervisor. The hypervisor can intercept any system call or access critical parts of memory [3].
VMBRs hide themselves to avoid detection, and to allow intruders to run malicious services with less fear of security software. Malicious services can be classified into three categories: -
-
Malicious service doesn’t interest to communicate with the target (Zero interaction), such as distributed denial-of-services, spam relays, zombies, and phishing. VMBR allow these services to be executed in the targeted OS [16]. Malicious services that interested to observe information or events from the target (passive monitoring), such as network packets, and keystrokes. VMBRs allows logging of I/O hardware level data that by changing the VMM device emulation code, these changes are hiding from the target OS [16].
-
Malicious services that deliberately targeting the system and modify its execution (active execution modification), for example a malicious services can execute privilege commands to modify, delete, or change of a target application [16].
VMBR has to maintain its control to the target system to avoid being removed, and to protect its state, it achieves that by maintaining its control to the target system. VMBR only loses control of the target system in the time between system powers up and VMBR starts. Basically VMBR lose control when the target system is power off, so it try to reduce the number of times that full system power off happens. Naturally power cycles are reboots and shutdowns, so VMBR avoid reboots by restarting the virtual hardware instead of restarting the physical hardware [16]. Moreover VMBRs use tricky technique to remains running on the system, it achieves that by emulates the system shutdowns (or power cycles).Target system appears to be shutdown, however VMBR is still live and running on the system [16]. ACPI sleep states are used to turning down hard disks, turning the display into a powersaving mode, and turning off fans, at this point the computer appears to be powered off, however RAM is still functioning. This technique is exploited by VMBR to dominate the target system while it is powered off [16]. 2.3 VMBRs Detection and Virtualisation Security Detection systems used to detect VMBRs have to run in two stages below and above the VMBR i.e. run at the layer below and above the VMBR. Therefore Detectors run below the VMBR can monitor the VMBR state, that because when you run detectors below the VMBR that will allow them to read directly from physical memory without going through VMM layer which VMBR control it. So that will allow the detectors to observe any differences made by VMBRs such as modifying boot sequence [16]. There is several ways to install detectors below the VMBR, first one is to implement secure hardware such as Intel’s LaGrande, AMD platform for trustworthy computing, as well as Copilot all propose hardware, these hardware used to install and run security layer under a VMBR. The second way to gain control below the VMBR is using safe bootable medium such as CD-ROM, network boot server, or USB driver, consequently detector can run before the VMBR loads and it can view the VMBR’s state, example GhostBuster detector. The third way is to use a secure hypervisor (VMM). Secure hypervisor can detect and stop a VMBR from modifying the boot sequence [16]. Installing security detectors above may not be efficient because it is probably will not detect a VMBR, that because target system will not observe suspicious activities or changes in its state, even the target system observed , the VMBR would affect the detector and enforce it to report incorrect results [16].
Conclusion The battle between the defenders and attackers is going deeper to the lower layer of the security system. This paper demonstrated the basic architecture of the virtual machine system, and how an attacker can escape the isolation and gain control over the hypervisor. The paper discussed the hypervisors vulnerabilities and how can use them to break out hypervisor interact with it. The paper also attempted to show the recent security researches used to proof the possibilities of VM escape, and techniques used in these researches .Controlling the hypervisor by an attacker is not impossible but it is very sophisticated, the second part of the paper demonstrated the malware development and how attackers have used new methods such VMBR rootkit to compromise the VMM. It also discussed the detection and protection of VMBRs and the improvement of traditional security detectors to defend against VMBR attacks.
References 1. Jim E. Smith, Ravi Nair (2005). Virtual Machines: Versatile Platforms for Systems and Processes. San 2.
3. 4. 5. 6. 7. 8. 9. 10. 11. 12.
Francisco: Morgan Kaufmann. Available from: . [Accessed 15 April 2013]. Jason E. Fritts (2010). Hardware vs. Software Architecture, and the Intel x86 family, lecture notes distributed in the topic CSCI 224 - Computer Architecture. Saint Louis University- Mathematics and Computer Science, Department of Mathematics and Computer Science on 22 January. Dave Shackleford (2013). Fundamentals of Virtualization Security. In: Judy Flynn, (ed). Virtualization Security: Protecting Virtualized Environments, Canada: John Wiley, pp2-13. Arati Baligaa, Liviu Iftodea and Xiaoxin Chen (2008). Automated containment of rootkits attacks. ELSEVIER [online]. 35(2013), p.325-333. Available from: . [Accessed 25 April 2013]. K eith Adams and Ole Agesen (2012, July). A Comparison of Softwar e and Hard war e T echniques f or x86 V irtualization. (0). 0, USA. Available from: . Accessed: 20th April 2013. Johan De Gelas (2008). Hardware Virtualization: the Nuts and Bolts. 17 March 2008. A Matter of Privileges [online]. [Accessed 11 April 2013]. Available from: . Naveed Alam (2008, July). Survey On Hypervisors. (0). 0, Indiana University Bloomington. Available from: . Accessed: 15 April 2013. Seongwook Jin and Jaehyuk Huh (2011, June). Secure MMU: Architectural Support for Memory Isolation among Virtual Machines. (7th). 0, (Korea Adanced Institute of Science and Technology. Available from: . Accessed: 16 April 2013. Farzad Sabahi, Member, IEEE (2012, February). Secure Virtualization for Cloud Environment Using Hypervisor-based Technology. (2). 1, Singapore. Available from: . Accessed: 21 April 2013. Tim Mather, Subra Kumaraswamy,and Shahed Latif (2009). Cloud Security and Privacy: An Enterprise Perspective on Risks and Compliance. United states of America: O'Reilly Media, Inc. Available from: . [Accessed 10 April 2013]. Computer Hope [online]. (2013). Available from: . [Accessed 15 April 2013]. Monty McDougal (2007). VMWare Escape Publicized at SANSfire 2007. 28 July 2007. FOOL MOON BLOG [online]. [Accessed 15 April 2013]. Available from: .
13. Fotis Tsifountidis (2010, September). Virtualization Security: Virtual Machine Monitoring and 14. 15.
16. 17.
Introspection. (0). 0, ROYAL HOLLOWAY, UNIVERSITY OF LONDON. Available from: . Accessed: 12 April 2013. Peter Ferrie (2010, June). Attacks on V i rtual Machine Emulators. (0). 0, USA. Available from: . Accessed: 20 April 2013. Massimo Ferrar, Kenneth van Surksum,and Paola Cornacchiola (2006). Debunking Blue Pill myth. Virtualization.info [online]. 0, p.1. Available from: . [Accessed 22 April 2013]. Samuel T. King Peter M. Chen, Yi-Min Wang, Chad Verbowski , Helen J. Wang and Jacob R. Lorch (2006, May). SubVirt: Implementing malware with virtual machines. (0). 0, Michigan. Available from: . Accessed: 10 April 2013. Samuel T. King Peter M. Chen, Yi-Min Wang, Chad Verbowski , Helen J. Wang and Jacob R. Lorch (2006, May). Presentation by Sam King. (0). 0, Michigan. Available from: < http://web.eecs.umich.edu/~pmchen/papers/>. Accessed: 10 April 2013.
Appendix: Checklist of Items: