Bluepilling the Xen Hypervisor



Similar documents
Security Challenges in Virtualized Environments

Attacking Intel Trusted Execution Technology

matasano Hardware Virtualization Rootkits Dino A. Dai Zovi

Attacking Hypervisors via Firmware and Hardware

Introducing Ring -3 Rootkits

Intel s Virtualization Extensions (VT-x) So you want to build a hypervisor?

Virtual machines and operating systems

Attacking Hypervisors via Firmware and Hardware

Full and Para Virtualization

AMD 64 Virtualization

A Hypervisor IPS based on Hardware assisted Virtualization Technology

Virtualization Technology. Zhiming Shen

Subverting the Xen hypervisor

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

Virtual Machines. COMP 3361: Operating Systems I Winter

Kernel Virtual Machine

Implementation of a Purely Hardware-assisted VMM for x86 Architecture

Basics of Virtualisation

Brian Walters VMware Virtual Platform. Linux J. 1999, 63es, Article 6 (July 1999).

An Introduction to Hardware-Assisted Virtual Machine (HVM) Rootkits

Virtualization. Jia Rao Assistant Professor in CS

BHyVe. BSD Hypervisor. Neel Natu Peter Grehan

x86 Virtualization Hardware Support Pla$orm Virtualiza.on

Uses for Virtual Machines. Virtual Machines. There are several uses for virtual machines:

Virtualization. ! Physical Hardware. ! Software. ! Isolation. ! Software Abstraction. ! Encapsulation. ! Virtualization Layer. !

POACHER TURNED GATEKEEPER: LESSONS LEARNED FROM EIGHT YEARS OF BREAKING HYPERVISORS. Rafal Wojtczuk

Cloud^H^H^H^H^H Virtualization Technology. Andrew Jones May 2011

Machine Virtualization: Efficient Hypervisors, Stealthy Malware

SUBVERTING LINUX ON-THE-FLY USING HARDWARE VIRTUALIZATION TECHNOLOGY

OSes. Arvind Seshadri Mark Luk Ning Qu Adrian Perrig SOSP2007. CyLab of CMU. SecVisor: A Tiny Hypervisor to Provide

Performance tuning Xen

Virtualization. Clothing the Wolf in Wool. Wednesday, April 17, 13

Virtualization VMware Inc. All rights reserved

Virtualization Technology

Hybrid Virtualization The Next Generation of XenLinux

KVM KERNEL BASED VIRTUAL MACHINE

kvm: Kernel-based Virtual Machine for Linux

CS5460: Operating Systems. Lecture: Virtualization 2. Anton Burtsev March, 2013

Securing Your Cloud with Xen Project s Advanced Security Features

Cloud Computing CS

Introduction to Virtualization & KVM

Chapter 5 Cloud Resource Virtualization

Secure Virtual Machine Architecture Reference Manual

Introduction to Virtual Machines

Using Linux as Hypervisor with KVM

SUSE Linux Enterprise 10 SP2: Virtualization Technology Support

RPM Brotherhood: KVM VIRTUALIZATION TECHNOLOGY

Qubes OS Architecture

Windows 7 XP Mode for HP Business PCs

Virtualization benefits Introduction to XenSource How Xen is changing virtualization The Xen hypervisor architecture Xen paravirtualization

Poacher turned gamekeeper: Lessons learned from eight years of breaking hypervisors

Virtual Machine Security

Enterprise-Class Virtualization with Open Source Technologies

KVM Security Comparison

Nested Virtualization

Practical Applications of Virtualization. Mike Phillips IAP 2008 SIPB IAP Series

Virtdbg. Using virtualization features for debugging the Windows 7 kernel. Damien Aumaitre. Recon 2011

Hypervisors and Virtual Machines

Chapter 16: Virtual Machines. Operating System Concepts 9 th Edition

KVM on S390x. Revolutionizing the Mainframe

Nested Virtualization

Virtualization Technologies

Hypervisors. Introduction. Introduction. Introduction. Introduction. Introduction. Credits:

Hypervisor-Based, Hardware-Assisted System Monitoring

CSE 501 Monday, September 09, 2013 Kevin Cleary

Hypervisor Memory Forensics

Taming Hosted Hypervisors with (Mostly) Deprivileged Execution

How To Make A Minecraft Iommus Work On A Linux Kernel (Virtual) With A Virtual Machine (Virtual Machine) And A Powerpoint (Virtual Powerpoint) (Virtual Memory) (Iommu) (Vm) (

Understanding Full Virtualization, Paravirtualization, and Hardware Assist. Introduction...1 Overview of x86 Virtualization...2 CPU Virtualization...

Hardware virtualization technology and its security

VMware Server 2.0 Essentials. Virtualization Deployment and Management

Knut Omang Ifi/Oracle 19 Oct, 2015

Survey on virtual machine security

Virtual Machines. Virtual Machine (VM) Examples of Virtual Systems. Types of Virtual Machine

The Microsoft Windows Hypervisor High Level Architecture

FRONT FLYLEAF PAGE. This page has been intentionally left blank

Virtualization. Pradipta De

Virtualization. Types of Interfaces

Intel Virtualization Technology Overview Yu Ke

Virtualization in Linux KVM + QEMU

Intro to Virtualization

WHITE PAPER Mainstreaming Server Virtualization: The Intel Approach

A technical review on comparison of Xen and KVM hypervisors: An analysis of virtualization technologies

9/26/2011. What is Virtualization? What are the different types of virtualization.

CS 695 Topics in Virtualization and Cloud Computing. More Introduction + Processor Virtualization

Nested Virtualization

2972 Linux Options and Best Practices for Scaleup Virtualization

IOS110. Virtualization 5/27/2014 1

Basics in Energy Information (& Communication) Systems Virtualization / Virtual Machines

Lecture Embedded System Security Dynamic Root of Trust and Trusted Execution

Distributed Systems. Virtualization. Paul Krzyzanowski

Fine-grained covert debugging using hypervisors and analysis via visualization

Windows Server Virtualization & The Windows Hypervisor

Transcription:

Bluepilling the Xen Hypervisor Joanna Rutkowska & Alexander Tereshkin Invisible Things Lab Black Hat USA 2008, August 7th, Las Vegas, NV

Xen 0wning Trilogy Part Three

Previously on Xen 0wning Trilogy...

Part 1: Subverting the Xen Hypervisor by Rafal Wojtczuk (Invisible Things Lab) Hypervisor attacks via DMA TG3 network card manual attack Generic attack using disk controller Xen Loadable Modules framework :) Hypervisor backdooring DR backdoor Foreign backdoor

Part II: Detecting and Preventing the Xen Hypervisor Subversions by Rafal Wojtczuk & Joanna Rutkowska Latest Xen security features How they fail: Q35 exploit How they fail: FLASK exploit The need for hypervisor integrity checks! Introducing HyperGuard!

Now, in this part...

1 Nested virtualization ( Matrix inside Matrix ) 2 BluePillBoot 3 XenBP: Bluepilling the Xen hypervisor on the fly! 4 Bluepilled Xen detection

Nested Virtualization

Hypervisor (Primary) VM1 VM2 (Nested Hypervisor) VM3 VM4 VM21 VM22 VM221 VM222

Idea of how to handle this situation...

Hypervisor VM1 VM2 VM3 VM21 VM22 VM221 VM222 Hypervisor VM1 VM2 VM21 VM22 VM221 VM222 VM3

Now, lets look at the actual details :)

Let s start with AMD-V...

VMCB0 VMCB0 VMCB0 VMRUN VMRUN RDMSR

VMCB0 VMRUN VMCB1 VMRUN?

VMCB0 VMCB0 VMCB1 VMRUN VMRUN VMCB1 VMRUN RDMSR?

VMCB1 VMCB1 VMCB0 VMRUN VMRUN VMCB1 VMCB1 VMRUN RAX RDMSR

Looks convincing but we also need to take care about some technical details, that are not trivial...

VMCB0 VMCB0 VMCB0 VMRUN VMRUN GIF=0 RDMSR GIF=1 GIF=1

GIF=0 Hypervisor VMRUN GIF=1 Nested Hypervisor Nested Guest RDMSR

Hypervisors expect to have GIF=1 when VMEXIT occurs... They might not be prepared to handle interrupts just after VMEXIT from guests!... but when we resume the nested hypervisor CPU sets GIF=1, because we do this via VMRUN, not VMEXIT...

Getting around the GIF Problem We need to emulate that GIF is 0 for the nested hypervisor We stop this emulation when: The nested hypervisor executes STGI The nested hypervisor executes VMRUN How do we emulate it?

GIF0 emulation VMCB 1.V_INTR_MASKING = 1 Host s RFLAGS.IF = 0 Intercept NMI, SMI, INIT, #DB and held (i.e. record and reinject) or discard until we stop the emulation

Additional details Need to also intercept VMLOAD/VMSAVE Need to virtualize VM_HSAVE_PA ASID conflicts

Hypervisor: ASID = 0 Conflicting ASIDs! Nested Hypervisor: ASID = 1 (but thinks that has ASID = 0) Nested Guest: ASID = 1 (assigned by the nested hypervisor)

But we can always reassign the ASID in the VMCB prim that we use to run the nested guest.

Performance Impact One additional #VMEXIT on every #VMEXIT that would occur in a nonnested scenario One additional #VMEXIT when the nested hypervisor executes: STGI, CLGI, VMLOAD, VMSAVE Lots of space for optimization though

Intel VT-x

Nested virtualization on VT-x No GIF bit - no need to emulate GIF0 for the nested hypervisor :) No Tagged TLB - No ASID conflicts :) However: VMX instructions can take memory operands - need to use complex operand parser No tagged TLB - potentially bigger performance impact

Nested VT-x: Status We have that working! The VT-x nesting code cannot be published though :(

Who else does Nested (hardware-based) Virtualization?

IBM z/vm hypervisor on IBM System z mainframe Running z/vm in a virtual machine (that is, z/vm as a guest of z/vm, also known as second-level z/vm) is functionally supported but is intended only for testing purposes for the secondlevel z/vm system and its guests (called third-level guests). -- http://www.vm.ibm.com/pubs/ hcsf8b22.pdf IBM System z10, source: ibm.com

Blue Pill Boot

MBR/ BIOS Xen hypervisor VM1 VM1 VM1 Management Domain

MBR/ BIOS BluePill Xen hypervisor VM1 VM1 VM1 Management Domain Dom0 modifies the MBR

Blue Pill Boot = MBR infector + Blue Pill loader + Blue Pill that supports nested virtualization

BPB s MBR Sector 1 Original MBR Sector 2 Sectors 3...n bootcode.sys (BluePill) Disk

BluePill (stage 2) 0x10000 BluePill (stage 1) Start hardware VM executing from 0x7c00 in Real Mode 0x7c00 0x0 BPB s MBR Memory Enable Long Mode Original MBR 0x7c00 0x0

BluePill Int 15h/e820h queries are intercepted by BluePill int 15h Xen MBR starts Xen which now runs in a hardware virtual machine controlled by the BluePill Original MBR 0x7c00 0x0

Demo: BluePillBootting the Xen (please excuse the recording quality)

Ensure hypervisor integrity via SRTM or DRTM

Xen Blue Pill

MBR/ BIOS Xen hypervisor VM1 VM1 VM1 Management Domain

SRTM/ DRTM BluePill Xen hypervisor MBR/ BIOS VM1 VM1 VM1 Management Domain SRTM/DRTM do not protect the already loaded hypervisor!

SRTM/ DRTM BluePill Xen hypervisor MBR/ BIOS VM1 VM1 VM1 Management Domain SRTM/DRTM do not protect the already loaded hypervisor!

The details

Loading using Rafal s XLM framework...

hypervisor XBP xenpgalloc domains xenrunproc Dom0

BluePill hypervisor XBP domains xenpgalloc xenrunproc Dom0

We allocate a block of memory for XBP inside Xen hypervisor -- this memory is used for both the XBP s code and data and heap

Demo: Bluepilling the Xen on the fly...

On Xen 3.3 we need to use Q35 exploit instead of direct hdd (see the talk #2)

Bluepilled Xen: Detection

Detecting a VMM is now not enough...

... as we know there is already one VMM in the system already (i.e. the Xen)...

We can only try direct timing analysis to see if #VMEXITs will take longer time to execute... (then on non-bluepilled Xen)

Impact on PV domains

BluePill hypervisor #GP, not #VMEXIT! ring 3 PV domains #GP VMRUN Dom0 We don t need to intercept anything besides VMRUN (and optionally VMLOAD, VMSAVE, STGI, CLGI) -- all those instructions cause #GP when executed in PV guests (including Dom0)

On AMD! 0 On Intel we have obligatory intercepts (CPUID, INVD, MOV CR3).

Impact on HVM domains

HVM domains: impact on #vmexit time (RDMSR intercept on AMD) 30.0 22.5 kcycles 15.0 7.5 5 0 Full Nested Virtualization - VMCB rewriting - CLGI/STGI interception - VMLOAD/ VMSAVE interception Native Xen (baseline)

5k cycles (Native Xen) vs. 7k cycles (Bluepilled Xen) 10.0 7.5 5.0 2.5 0 Xen Bluepilled Xen

2000 cycles from the Holy Grail ;)

But that you can observe only in a HVM domain; on PV domains it is: 0 cycles (on AMD)!

HyperGuard vs. BluePill?

Summary (of the whole trilogy)

Talk #1 (Rafal)

Modifying Xen via DMA attacks

Xen Loadable Modules Framework

Hypervisor Rootkits/Backdoors for Xen (don t confuse with virtualization-based rootkits!)

Talk #2 (Joanna & Rafal)

DMA protections (IOMMU/VT-d) on recent Xens

Getting around VT-d Xen protection (BONUS: on the fly SMM modification, despite D_LCK set)

Other Xen protection mechanisms...

... and how they sometimes might be bypassed... Exploiting a heap overflow in Xen hypervisor

HyperGuard - integrity scanner for a hypervisor

Talk #3 (Alex & Joanna)

Hardware Nested Virtualization

Blue Pill Boot

Xen Blue Pill: Bluepilling the Xen on the fly

Discussed the XBP detection

Slides available at: http://invisiblethingslab.com/bh08 Demos and code will be available from the same address after Intel releases the patch.

Thank you!