Attacking Hypervisors via Firmware and Hardware



Similar documents
Attacking Hypervisors via Firmware and Hardware

Nested Virtualization

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

A Tour Beyond BIOS Supporting an SMM Resource Monitor using the EFI Developer Kit II

Bluepilling the Xen Hypervisor

Virtual Machine Security

Introducing Ring -3 Rootkits

Intel Virtualization Technology Overview Yu Ke

A Hypervisor IPS based on Hardware assisted Virtualization Technology

Securing Your Cloud with Xen Project s Advanced Security Features

Knut Omang Ifi/Oracle 19 Oct, 2015

matasano Hardware Virtualization Rootkits Dino A. Dai Zovi

Virtualization Technology. Zhiming Shen

Security Challenges in Virtualized Environments

Virtual machines and operating systems

Compromise-as-a-Service

UEFI Firmware Security Best Practices

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

Chapter 5 Cloud Resource Virtualization

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

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

Attacking Intel Trusted Execution Technology

Windows Server Virtualization & The Windows Hypervisor

The Microsoft Windows Hypervisor High Level Architecture

Code Injection From the Hypervisor: Removing the need for in-guest agents. Matt Conover & Tzi-cker Chiueh Core Research Group, Symantec Research Labs

Virtualization. Types of Interfaces

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

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

Distributed Systems. Virtualization. Paul Krzyzanowski

Betting BIOS Bugs Won t Bite Y er Butt? Xeno Kovah Corey Kallenberg

Virtualization in Linux KVM + QEMU

Full and Para Virtualization

Virtualization. Dr. Yingwu Zhu

Virtual Machines. COMP 3361: Operating Systems I Winter

Advanced Computer Networks. Network I/O Virtualization

A Tale of One Software Bypass of Windows 8 Secure Boot. Yuriy Bulygin Andrew Furtak Oleksandr Bazhaniuk

McAfee Deep Safe. Security beyond the OS. Kai-Ping Seidenschnur Senior Security Engineer. October 16, 2012

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

COS 318: Operating Systems. Virtual Machine Monitors

Virtualization. Pradipta De

Securing your Virtual Datacenter. Part 1: Preventing, Mitigating Privilege Escalation

Virtualization. Jukka K. Nurminen

Subverting the Xen hypervisor

CS 356 Lecture 25 and 26 Operating System Security. Spring 2013

Virtualization. Jia Rao Assistant Professor in CS

Kernel Virtual Machine

UNCLASSIFIED Version 1.0 May 2012

OS Virtualization Frank Hofmann

Secure In-VM Monitoring Using Hardware Virtualization

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

KVM: Kernel-based Virtualization Driver

FRONT FLYLEAF PAGE. This page has been intentionally left blank

MODULE 3 VIRTUALIZED DATA CENTER COMPUTE

Basics of Virtualisation

Intel Trusted Platforms Overview

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

Introduction to the NI Real-Time Hypervisor

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

Hybrid Virtualization The Next Generation of XenLinux

On the Feasibility of Software Attacks on Commodity Virtual Machine Monitors via Direct Device Assignment

Virtualization Technology

Abstract. 1. Introduction. 2. Threat Model

EE282 Lecture 11 Virtualization & Datacenter Introduction

Virtualization System Security

Virtualization. P. A. Wilsey. The text highlighted in green in these slides contain external hyperlinks. 1 / 16

x86 Virtualization Hardware Support Pla$orm Virtualiza.on

Hypervisors and Virtual Machines

IOS110. Virtualization 5/27/2014 1

kvm: Kernel-based Virtual Machine for Linux

Intro to Virtualization

Virtualization Technologies

Hardware virtualization technology and its security

Distributed System Monitoring and Failure Diagnosis using Cooperative Virtual Backdoors

A Survey on Virtual Machine Security

How To Stop A Malicious Process From Running On A Hypervisor

Virtualization for Security

Post-Access Cyber Defense

Frontiers in Cyber Security: Beyond the OS

Machine Virtualization: Efficient Hypervisors, Stealthy Malware

ELI: Bare-Metal Performance for I/O Virtualization

Cloud Architecture and Virtualisation. Lecture 4 Virtualisation

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

Guardian: Hypervisor as Security Foothold for Personal Computers

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

VMware and CPU Virtualization Technology. Jack Lo Sr. Director, R&D

Virtualization with Windows

Virtualization System Vulnerability Discovery Framework. Speaker: Qinghao Tang Title:360 Marvel Team Leader

Before we can talk about virtualization security, we need to delineate the differences between the

KVM Security Comparison

5 Steps to Advanced Threat Protection

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

Nested Virtualization

Absolute Backdoor Revisited. Vitaliy Kamlyuk, Kaspersky Lab Sergey Belov, Kaspersky Lab Anibal Sacco, Cubica Labs

Security+ Guide to Network Security Fundamentals, Third Edition. Chapter 2 Systems Threats and Risks

Lecture Overview. INF3510 Information Security Spring Lecture 4 Computer Security. Meaningless transport defences when endpoints are insecure

Under the Hood: How Actaeon Unveils Your Hypervisor

Transcription:

Attacking Hypervisors via Firmware and Hardware Alex Matrosov (@matrosov), Mikhail Gorobets, Oleksandr Bazhaniuk (@ABazhaniuk), Andrew Furtak, Yuriy Bulygin (@c7zero) Advanced Threat Research

Agenda Hypervisor based isolation Firmware rootkit vs hypervisor Attacking hypervisors through system firmware Tools and mitigations Conclusions

Image source Hypervisor Based Isolation

Hypervisor Based Isolation Virtual Machine Virtual Machine App App App App Operating System Operating System Privilege VMM / Hypervisor System Firmware (BIOS, U/EFI firmware, SMI handlers, Coreboot ) Memory Hardware CPU Graphics I/O Network

Hypervisor Based Isolation Virtual Machine Virtual Machine App App App Attack Operating System Operating System Privilege VMM / Hypervisor System Firmware (BIOS, U/EFI firmware, SMI handlers, Coreboot ) Memory Hardware CPU Graphics I/O Network

Hypervisor Protections Software Isolation CPU / SoC: traps to hypervisor (VM Exits), MSR & I/O permissions bitmaps, rings (PV) Memory / MMIO: hardware page tables (e.g. EPT, NPT), software shadow page tables Devices Isolation CPU / SoC: interrupt remapping Memory / MMIO: IOMMU, No-DMA ranges

CPU Virtualization (simplified) VM Guest OS Instructions, exceptions, interrupts Access to CPU MSRs (e.g. DEBUGCTL) Access to I/O ports Access to (e.g. 0xB2) memory (EPT violations) Hypervisor Traps (VM Exits) VMM Host VM Exit Handler VM Control Structure (VMCS) MSR Bitmaps Extended Page Tables I/O Bitmaps

Protecting Memory with HW Assisted Paging VM Guest OS VMM Host Process Virtual Memory CR3 Guest Physical Memory GPA0 VMCS EPTP Host Physical Memory HPA0 VA0 Guest Page Tables GPA1 EPT HPA1 VA1 GPA2 GPA0 HPA3 HPA2 VA2 GPA3 GPA2 HPA5 HPA3 VA3 VA4 GPA4 GPA5 GPA6 GPA4 HPA4 (1:1 mapping) GPA6 block HPA4 HPA5 HPA6

Hypervisor Protections System Firmware Isolation

Firmware Rootkit vs Hypervisor Image source

What is firmware rootkit? Virtual Machine Virtual Machine App App App App Operating System Operating System Privilege VMM / Hypervisor System Firmware Rootkit (e.g. DXE driver) Memory Hardware CPU Graphics I/O Network

Firmware rootkit can open a backdoor for an attacker VM to access all other VMs Virtual Machine App App Operating System Attacker VM App App Operating System 3. Now using this backdoor, attacker VM can access all of memory of victim VMs VMM / Hypervisor System Firmware Backdoor Rootkit 2. During each boot rootkit installs a backdoor for an attacker controlled VM 1. At some point system firmware got infected with a rootkit staying persistent

Backdoor for attacker s VM 1. Firmware rootkit searches & modifies VM s VMCS(B), VMM page tables 2. Rootkit added page table entries to attacker VM which expose entire physical memory Now attacker VM has full access to physical memory of VMM and other VMs

So how would one install a rootkit in the firmware?

Using hardware SPI flash programmer

USB & exploiting weak firmware protections...

Software access and exploiting some vulnerability in firmware From privileged guest (e.g. Dom0). Requires privesc from normal guest (e.g. DomU) or remote From the host OS before/in parallel to VMM From normal guest if firmware is exposed to the guest by VMM For example, if firmware is not adequately write protected in system flash memory

DEMO Rootkit in System Firmware Exposes Secrets from Virtual Machines https://youtu.be/sjniipn0104 Image source

We flashed rootkited part of firmware image from within a root partition to install the rootkit The system doesn t properly protect firmware in SPI flash memory so we could bypass write-protection Finally more systems protect firmware on the flash memory common.bios_wp CHIPSEC module to test write-protection Malware can exploit vulnerabilities in firmware to install a rootkit on such systems Attacking and Defending BIOS in 2015

VMM forensics With the help of a rootkit in firmware any VM guest can extract all information about hypervisor and other VMs and just from memory VMCS structures, MSR and I/O bitmaps for each VM guest EPT for each VM guest Regular page tables for hypervisor and each VM guest IOMMU pages tables for each IOMMU device Full hypervisor memory map, VM exit handler Real hardware configuration (registers for real PCIe devices, MMIO contents )

VMM Hardware Page Tables

Attacking Hypervisors through System Firmware (with OS kernel access) Image source

Pointer Vulnerabilities in SMI Handlers Phys Memory RAX (code) RBX (pointer) RCX (function) RDX RSI RDI SMI SMI Handlers in SMRAM Fake structure inside SMRAM OS Memory Exploit tricks SMI handler to write to an address inside SMRAM Attacking and Defending BIOS in 2015

SMI Pointer Exploiting firmware SMI handler to attack VMM Virtual Machine (child partition) App App Operating System Root partition App Attack Operating System VMM allows VM to invoke SMI handlers (grants access to SW SMI I/O port 0xB2) Memory Hypervisor SMI Handlers System Firmware I/O Hardware CPU Network Graphics Compromised VM injects SMM payload through the input pointer vulnerability in SMI handler SMM firmware payload modifies hypervisor code or VMCS/EPT to install a backdoor

DEMO Attacking Hypervisor via Poisonous Pointers in Firmware SMI handlers https://youtu.be/zujel9cgse8

Root cause? Port B2h is open to VM in I/O bitmap

So this is firmware issue, right? What if firmware validates pointers?

Still exploitable Phys Memory RAX (code) RBX (pointer) RCX (function) RDX RSI RDI SMI SMI Handlers in SMRAM Hypervisor Memory (Protected by EPT) Firmware SMI handler validates input pointers to ensure they are outside of SMRAM preventing overwrite of SMI code/data

Point SMI handler to overwrite VMM page! Phys Memory RAX (code) RBX (pointer) SMI SMI Handlers in SMRAM RCX (function) RDX RSI RDI Hypervisor Memory (Protected by EPT) VMM Protected Page VMM Protections are OFF VT state and EPT protections are OFF in SMM (without STM) SMI handler writes to a protected page via supplied pointer

Attacking VMM by proxying through SMI handler Virtual Machine (child partition) App App Operating System Root partition App Attack Operating System VM with direct access to SMIs invokes SMI handler and supplies a pointer to some VMM page VMM / Hypervisor Memory SMI Handlers System Firmware Hardware CPU Graphics SMI handler writes to the supplied pointer overwriting contents of protected VMM page I/O Network

Do Hypervisors Dream of Electric Sheep? Vulnerability used in this section is VU#976132 a.k.a. S3 Resume Boot Script Vulnerability independently discovered by ATR of Intel Security, Rafal Wojtczuk of Bromium and LegbaCore It s also used in Thunderstrike 2 by LegbaCore & Trammell Hudson

NORMAL BOOT S3 RESUME Waking the system from S3 sleep state Virtual Machine Apps / OS BDS VMM / Hypervisor U/EFI System Firmware DXE UEFI core & drivers S3 Boot Script Table Restores hardware config Script Engine Platform Init Platform Init

What is S3 boot script table? A table of opcodes in physical memory which restores platform configuration S3_BOOTSCRIPT_MEM_WRITE opcode writes some value to specified memory location on behalf of firmware S3_BOOTSCRIPT_DISPATCH/2 S3_BOOTSCRIPT_PCI_CONFIG_WRITE S3_BOOTSCRIPT_IO_WRITE

NORMAL BOOT S3 RESUME MODIFY Xen exposes S3 boot script table to Dom0 Privileged PV guest (Dom0) Exploit VM modifies S3 boot script table in memory Upon resume, firmware executes rogue S3 script Xen Hypervisor U/EFI System Firmware BDS DXE UEFI core & drivers S3 Boot Script Table Restores hardware config Script Engine Platform PEI 0xDBAA4000 Platform PEI

DEMO Attacking Xen in its sleep https://youtu.be/dsu-scejyjg Image source

Déjà vu? Xen 0wning Trilogy (Part 3) by Invisible Things Lab

So these firmware vulnerabilities are exploitable from privileged guest (e.g. root partition, Dom0..) What about use cases where guests must be strongly isolated from the root partition?

Image sciencenews.org Tools and Mitigations

First things first - fix that firmware! Firmware can be tested for vulnerabilities! common.uefi.s3bootscript (tests S3 boot script protections) tools.smm.smm_ptr (tests for SMI pointer issues) Protect the firmware in system flash memory common.bios_wp common.spi_lock... (tests firmware protections in system flash memory)

Testing hypervisors Simple hardware emulation fuzzing modules for open source CHIPSEC tools.vmm.*_fuzz I/O, MSR, PCIe device, MMIO overlap, more soon Tools to explore VMM hardware config chipsec_util iommu (IOMMU) chipsec_util vm (CPU VM extensions)

Dealing with system firmware attacks.. A number of interfaces through which firmware can be attacked or relay attack onto VMM UEFI variables, SMI handlers, S3 boot script, SPI flash MMIO, FW update.. FW doesn t know memory VMM needs to protect VMM need to be careful with which of these it exposes to VMs including to administrative (privileged) guests Some need not be exposed (e.g. S3 boot script), some may be emulated and monitored

Conclusions Compromised firmware is bad news for VMM. Test your system s firmware for security issues Windows 10 enables path for firmware deployment via Windows Update Secure privileged/administrative guests; attacks from such guests are important Vulnerabilities in device and CPU emulation are very common. Fuzz all HW interfaces Firmware interfaces/features may affect hypervisor security if exposed to VMs. Both need to be designed to be aware of each other

References 1. CHIPSEC: https://github.com/chipsec/chipsec 2. Intel s ATR Security of System Firmware 3. Attacking and Defending BIOS in 2015 by Intel ATR 4. Hardware Involved Software Attacks by Jeff Forristal 5. Xen 0wning Trilogy by Invisible Things Lab 6. http://www.legbacore.com/research.html 7. Low level PC attack papers by Xeno Kovah

Thank you!