Deconstructing Xen Lei Shi, Yuming Wu, Yubin Xia , Nathan Dautenhahn, - - PowerPoint PPT Presentation

deconstructing xen
SMART_READER_LITE
LIVE PREVIEW

Deconstructing Xen Lei Shi, Yuming Wu, Yubin Xia , Nathan Dautenhahn, - - PowerPoint PPT Presentation

NDSS1 7 Deconstructing Xen Lei Shi, Yuming Wu, Yubin Xia , Nathan Dautenhahn, Haibo Chen, Binyu Zang, Haibing Guan, Jinming Li Shanghai Jiao Tong University , University of Pennsylvania, Huawei Inc. / 27 Hypervisors have Bugs Xen is used


slide-1
SLIDE 1

/ 27

Deconstructing Xen

Lei Shi, Yuming Wu, Yubin Xia, Nathan Dautenhahn, Haibo Chen, Binyu Zang, Haibing Guan, Jinming Li Shanghai Jiao Tong University, University of Pennsylvania, Huawei Inc. NDSS’1 7

slide-2
SLIDE 2

/ 27

Hypervisors have Bugs

2

50 100 150 200 250 2011 2012 2013 2014 2015 2016 2017

  • Xen is used by Amazon EC2
  • Xen’s CVE is growing

210 XSA (Xen Security Advisories) Xen’s LoC is growing from 45K (v2.0) to 270K (v4.0)

  • KVM also has 100+ CVEs

Data from https://xenbits.xen.org/xsa/

slide-3
SLIDE 3

/ 27

Analyze 201 of Xen’s Vulnerabilities (XSA)

3

  • 10 are ignored

7 numbers are not used XSA-161 was withdrawn XSA-99 is irrelevant XSA-166 is too vague

  • 144 are in the hypervisor

E.g., Host DoS, privilege escalation, etc. Use hypervisor to attack VM

47

10

144 (75% of 191)

  • 47 are not in hypervisor

Some are in Domain-0 Some are in Qemu

191

Focus on this part

slide-4
SLIDE 4

/ 27

3 Dimensions to Categorize (144 Hypervisor bugs)

4 Hypervisor Hypervisor Hypervisor

Attack targets Memory management: 25.7% CPU virtualization: 21.5% Code emulation: 13.2% ... Key steps of attack Memory corruption: 45.1% Misuse of hardware: 22.2% Live lock: 8.3% ... Results of attack Host DoS: 61.8% Privilege escalation: 15.3% Info leak: 13.9% ...

Which component to attack? How to attack? Attack for what?

slide-5
SLIDE 5

/ 27

  • 1. Xen Components with Bugs

5 0.00% 5.00% 10.00% 15.00% 20.00% 25.00% 30.00%

Others Scheduler XSM Event channel Domain building Domain control Global Grant table Exception handling I/O Code emulation CPU virtualization Memory management

  • Components with bugs

25.69%: Memory management 21.53%: CPU virtualization 13.19%: Code emulation

  • Observations:

Some components are more attractive to attackers Memory management is critical and hard to get right

25.69 % 21.53 % 13.19 %

slide-6
SLIDE 6

/ 27

  • 2. The Types of Key Step of Attack

6 0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50%

Dead lock Run out of resource General fault False BUG_ON Infinite loop Live lock Misuse of hardware Memory curruption

  • Memory corruption: 45.14%

Illegal memory read

E.g., out-of-boundary

Illegal memory write

E.g., write to an invalid pointer

45.1 % 22.2 %

slide-7
SLIDE 7

/ 27

  • 3. The Consequences of Attack

7 0% 20% 40% 60% 80%

Privilege escalation (to guest) Guest DoS (other) Guest DoS (itself) Information leak Privilege escalation (to host) Host DoS

  • Host DoS: more than 60%

All DoS: more than 70%

  • Guest to guest attack

Some guest app leverages hypervisor to DoS its own guest VM

61.8% 15.3% 13.9%

slide-8
SLIDE 8

/ 27

Summary: Observations

  • Hypervisors have bugs

– Some previous studies focused on bugs of dom-0 or host OS – Some systems (e.g., nested virtualization) can solve the problem but may cause performance overhead due to nested levels

  • Some components have more vulnerabilities (found)

– Take consideration on mem management, code emulation, etc.

  • DoS cannot be ignored

– Need to tolerant DoS for availability

8

slide-9
SLIDE 9

/ 27

NEXEN: NESTED XEN

Deconstruction for Isolation

It’s a palindrome!

9

slide-10
SLIDE 10

/ 27

From Observations to Nexen

  • Hypervisors have bugs

– Deconstruct the hypervisor to isolated components – “Nesting” within single hardware privilege for performance

  • Some components have more vulnerabilities

(found)

– Isolate vulnerabilities in the boundary of VM

  • DoS cannot be ignored

– Isolate failure in the boundary of VM

10

slide-11
SLIDE 11

/ 27

Deconstructing Xen

Xen Slice Xen Slice Xen Slice Shared Service Security Monitor Dom-0 Para-VM Full-VM Hypervisor Virtual Machine Partition Xen into several internal domains, all the domains run in the same hardware privilege

11

slide-12
SLIDE 12

/ 27

Xen Slice

Xen Slice Xen Slice Xen Slice Shared Service Security Monitor Dom-0 Para-VM Full-VM Hypervisor Virtual Machine Each Xen slice serves only one VM, containing the VM’s metadata and handling its VMExits Same code, Different instances

12

slide-13
SLIDE 13

/ 27

Shared Service

Xen Slice Xen Slice Xen Slice Shared Service Security Monitor Dom-0 Para-VM Full-VM Hypervisor Virtual Machine Only one shared service. It does not interact directly with VM, just serves Xen slices. Serve all the Xen slices

13

slide-14
SLIDE 14

/ 27

Xen Destruction

  • Questions

– Which parts to put in Xen slices? – Which parts to put in shared service?

  • Principles

– Least privilege – Minimize runtime communication – Separate mechanism from policy

14

slide-15
SLIDE 15

/ 27 15

Original Xen Component s Vulnerabilities

slide-16
SLIDE 16

/ 27 16

Xen Slice Shared Service Component s Vulnerabilities

slide-17
SLIDE 17

/ 27

Security Monitor: Controls the MMU

Xen Slice Xen Slice Xen Slice Shared Service Security Monitor Dom-0 Para-VM Full-VM Hypervisor Virtual Machine The security monitor controls guest page tables and EPTs. It offers interfaces & does security checks. Isolation

17

slide-18
SLIDE 18

/ 27

Protecting the Security Monitor

  • MMU virtualization

– Get higher software privilege in the same hardware privilege – Similar with the nested-kernel architecture [ASPLOS’16]

  • Only the monitor can modify page tables

– Page tables are mapped as read-only to other components – No page table operation instructions out of the monitor – Enforce security policies on each operation of page table – Bootstrap security: through Intel TXT or TPM

18

slide-19
SLIDE 19

/ 27

Same Memory, Different Views

19

Guest VM Xen Slice Shared Service Security Monitor

RW RW RW RW RW RW RW RW RW RW RW RO RO RO

slide-20
SLIDE 20

/ 27

Call Gate: Intercept Switches between Slices

Xen Slice Xen Slice Xen Slice Shared Service Security Monitor Dom-0 Para-VM Full-VM Hypervisor Virtual Machine Intercept switches between Xen slices & shared service, as well as VM & its Xen slice

call gate

20

slide-21
SLIDE 21

/ 27

Summary: What Nexen can/cannot Defend?

Malicious Component Steal or tamper with VM’s data Host DoS Guest DoS VM (user) N.A. Considered Considered VM (kernel) Not considered Considered N.A. Other VM Considered Considered Considered Xen Slice Considered Considered Not considered Shared Service Considered Not considered Not considered

21

Nexen cannot defend against attacks through legal interfaces (aka., Iago attack)

slide-22
SLIDE 22

/ 27

EVALUATION

Security & Performance

22

slide-23
SLIDE 23

/ 27

Security Evaluation on 144 XSAs

107/144 (74%): Defended 27/144 (19%): target the shared service and can cause host failure 10/144 (7%): attack through interface, depends on semantic

23

slide-24
SLIDE 24

/ 27

Case Study: XSA-108

  • Type: Out-of-boundary mem access in

code emulation causes info leak

  • Description

– Xen’s code emulation for APIC erroneously emulates read and write permissions for 1024 MSRs where there are actually 256 MSRs. A read operation can go beyond the page set up and potentially get sensitive data from the hypervisor or other VMs

  • case MSR_IA32_APICBASE_MSR ... MSR_IA32_APICBASE_MSR +

0x3ff: + case MSR_IA32_APICBASE_MSR ... MSR_IA32_APICBASE_MSR + 0xff:

24

Xen Slice Xen Slic e

Security Monitor

VM VM

slide-25
SLIDE 25

/ 27

SPEC CPU2006 (less than 1%)

slide-26
SLIDE 26

/ 27

IOzone (2.4% on average)

slide-27
SLIDE 27

/ 27

Conclusion

  • Methodology of deconstruction

– Analyze 201 Xen’s vulnerabilities – Derive boundary of isolation from the result – Deconstructing system to internal domains and security monitor

  • Nexen implementation

– Deconstruct Xen to multiple Xen slices and one shared service – Using nested kernel design to protect the security monitor

  • More info: http://ipads.se.sjtu.edu.cn/xsa

Thanks!

27

47

10

144 (75% of 191) 107 (74% of 144)

slide-28
SLIDE 28

/ 27

BACKUP SLIDES

28

slide-29
SLIDE 29

/ 27

Same Memory, Different Views

Xen Slice Code Secure Monitor Shared Service Code Xen Slice Data Xen Slice Data Shared Service Data

Memory Space

Xen Slice 1 Xen Slice n Shared Service

29

slide-30
SLIDE 30

/ 27

Memory management 26% CPU virtualiza9on 22% Code emula9on 13% I/O 9% Excep9on handling 6% Grant table 5% Global 4% Domain control 4% Domain building 4% Event channel 2% XSM 1% Scheduler 1% Others 3%

30

slide-31
SLIDE 31

/ 27

The Control Flow

  • Gate keeper in the monitor
  • Switch between memory spaces
  • Intercept transferring between:
  • Guest VM & Hypervisor
  • Xen slice & shared service
  • Complete mediation
  • Cannot be bypassed

31

slide-32
SLIDE 32

/ 27

Case Study: XSA-191

  • Type

‒ Misuse of H/W feature in code emulation causes privilege escalation to guest kernel

  • Description

‒ Intel hardware uses NULL segment selectors to prevent

  • access. Xen code emulator fails to check this condition and

may erroneously permit invalid access. An unprivileged guest user program may be able to elevate its privilege to that of the guest operating system

32

slide-33
SLIDE 33

/ 27

Case Study: XSA-191

  • How to trigger?
  • 1. try to set kernel data segment selector to NULL
  • 2. trigger an instruction that requires emulation, the side effect
  • f which changes an entry of kernel page table
  • 3. the instruction emulated, changing the page table entry,

giving the user program access to some kernel data

33

slide-34
SLIDE 34

/ 27

Case Study: XSA-191

  • Why cannot defend?

‒ Not harming other VMs: the process completely finish in code emulator of one VM ‒ Iago attack: logic error of code emulator

34

slide-35
SLIDE 35

/ 27

Performance Evaluation: Negligible Overhead

SPEC CPU2006 (less than 1%) IOzone (2.4% on average)

35

slide-36
SLIDE 36

/ 27

Case Study: XSA-83

  • Type

– Memory corruption in shared service causes privilege escalation

  • Description

– Out-of-memory condition yielding memory corruption during IRQ

  • setup. When setting up the IRQ for a passed through physical

device, a flaw in the error handling could result in a memory allocation being used after it is freed, and then freed a second time

36

slide-37
SLIDE 37

/ 27

Case Study: XSA-83

  • Patch

@@ -1590,8 +1590,7 @@ int pirq_guest_bind(struct vcpu *v, stru printk(XENLOG_G_INFO “Cannot bind IRQ%d to dom%d. Out of memory.\n”, pirq->pirq, v->domain->domain_id);

  • rc = -ENOMEM;
  • goto out;

+ return -ENOMEM; }

37

slide-38
SLIDE 38

/ 27

Case Study: XSA-83

  • Why cannot Nexen defend?

– Since the shared service is critical in Nexen, exploiting a bug in this part will allow the attacker to do almost anything destructive towards the whole system – VM’s data are still protected

Xen Slice Security Monitor Dom-0 Shared Service

38

slide-39
SLIDE 39

/ 27

Comparing with Related Work

Hypervisor illegally accesses guest’s data Guest causes host DoS Guest apps attack its

  • wn VM by

hypervisor Disaggregated Xen No No No Xoar No No No Turtles KVM No Yes No DeHype No Yes No HyperLock No Yes No CloudVisor Yes No Yes Nexen Yes Yes Yes

39

slide-40
SLIDE 40

/ 27

Comparing with Related Work

40

slide-41
SLIDE 41

/ 27

Internal Domain API

  • Domains interaction

– Create a Xen slice – Allocate protected memory to a Xen slice – Specify policy for a piece of memory

41

slide-42
SLIDE 42

/ 27

Case Study: XSA-111

  • Type

– False BUG_ON in CPU virtualization causes host DoS

  • Description

– A piece of hypercall parameter translation code assumes that only the lower 32 bits of a 64-bit register variable are used, violation of which will trigger a BUG_ON that kills the hypervisor

42

slide-43
SLIDE 43

/ 27

Case Study: XSA-111

  • How to trigger?

– This condition can be deliberately violated by an HVM guest by temporarily changing to 64-bit mode and passing an invalid 64-bit parameter

int hypercall_xlat_continuation(unsigned int *id, unsigned int nr, unsigned int mask, ...) { ... regs = guest_cpu_user_regs(); ... BUG_ON(*reg != (unsigned int)*reg); }

43

slide-44
SLIDE 44

/ 27

Case Study: XSA-111

  • How to defend?

– In Nexen, the vulnerable code runs in the context of a Xen slice – The modified BUG_ON logic will

  • nly kill current Xen slice VM

when it is triggered

Xen Slice Xen Slice Security Monitor Dom-0 Para-VM

44