Attacking Hypervisors Via Firmware and Hardware: Alex Matrosov (@matrosov)
Attacking Hypervisors Via Firmware and Hardware: Alex Matrosov (@matrosov)
Image source
Hypervisor Based Isolation
Virtual Machine Virtual Machine
VMM / Hypervisor
System Firmware
(BIOS, U/EFI firmware, SMI handlers, Coreboot…)
Hardware
Memory CPU Graphics
I/O Network
Hypervisor Based Isolation
Virtual Machine Virtual Machine
VMM / Hypervisor
System Firmware
(BIOS, U/EFI firmware, SMI handlers, Coreboot…)
Hardware
Memory 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, Access to
exceptions, I/O ports
interrupts… Access to CPU Access to (e.g. 0xB2)
MSRs memory
(e.g. DEBUGCTL) (EPT violations)
VMM Host
VM Exit Handler
Image source
What is firmware rootkit?
VMM / Hypervisor
Rootkit
System Firmware
(e.g. DXE driver)
Hardware
Memory CPU Graphics
I/O Network
Firmware rootkit can open a backdoor for
an attacker VM to access all other VMs
1. At some point
System Firmware Rootkit 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
Phys Memory
SMI Handlers in
RAX (code) SMI SMRAM
RBX (pointer) Fake structure inside SMRAM
RCX (function)
RDX OS Memory
RSI
RDI
Compromised VM
SMI Pointer
injects SMM payload
Hypervisor through the input
pointer vulnerability in
SMI Handlers SMI handler
System Firmware
SMM firmware
Hardware payload modifies
Memory CPU Graphics hypervisor code or
VMCS/EPT to install
I/O Network
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
SMI Handlers in
RAX (code) SMI SMRAM
RBX (pointer)
RCX (function)
RDX Hypervisor Memory
(Protected by EPT)
RSI
RDI
Phys Memory
SMI Handlers in
RAX (code) SMI SMRAM
RBX (pointer)
RCX (function)
VMM
RDX Hypervisor Memory Protections
(Protected by EPT) are OFF
RSI VMM Protected Page
RDI
VMM / Hypervisor
I/O Network
Do Hypervisors Dream
of Electric Sheep?
Virtual Machine
Apps / OS
VMM / Hypervisor
BDS
NORMAL BOOT
S3 RESUME
DXE S3 Boot
Script Table
UEFI core
Restores
& drivers hardware config
Script Engine
S3_BOOTSCRIPT_DISPATCH/2
S3_BOOTSCRIPT_PCI_CONFIG_WRITE
S3_BOOTSCRIPT_IO_WRITE
…
Xen exposes S3 boot script table to Dom0
VM modifies S3 boot
Privileged PV guest (Dom0) script table in memory
Xen Hypervisor
MODIFY
U/EFI System Firmware
BDS
NORMAL BOOT
S3 RESUME
DXE S3 Boot
Script Table
UEFI core
Restores
& drivers hardware config
Script Engine
https://youtu.be/Dsu-scEJyJg
Image source
Déjà vu?
Image sciencenews.org
First things first - fix that firmware!
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!