Introduction Network path Bootloader Device model Conclusion

Securing Your Cloud with Xen Project’s Advanced Security Features

Russell Pavlicek, Xen Project Evangelist

CloudOpen North America 2013 Introduction Network path Bootloader Device model Xen Conclusion Who is the Old, Fat Geek Up Front?

I Xen Project Evangelist

I Employed by Citrix, focused entirely on the Xen Project

I History with Open Source begins in 1997

I Former columnist with Infoworld, Processor magazines

I Former panelist on The Show webcast, repeat guest on The Linux Link Tech Show

I Over 150 pieces published, plus one book on Open Source development and several blogs

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 2 / 32 Introduction Network path Bootloader Device model Xen Conclusion Introduction: Xen Project and Security

I Xen Project is an enterprise-grade Type I

I Built for the Cloud before it was called the Cloud I A number of advanced security features

I Driver Domains, Stub Domains, FLASK, and more

I Most of them are not (or cannot) be turned on by default

I Although they are simple to use, sometimes they can appear to be complicated

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 3 / 32 Introduction Network path Bootloader Device model Xen Conclusion Presentation Goals

I Introduce you to key Xen Project Security Tools

I Discuss some key Xen security features

I Get you started in the right direction toward securing your Xen installation

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 4 / 32 Introduction Network path Bootloader Device model Xen Conclusion Presentation Outline

I A few thoughts on the problem of securing the Cloud

I Overview of the Xen architecture

I Brief introduction to principles of security analysis I Consider some attack surfaces and Xen features we can use to mitigate them:

I Driver Domains I PVgrub I Stub Domains I (PV) mode vs Hardware (HVM) mode I FLASK example policy

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 5 / 32 Introduction Network path Bootloader Device model Xen Conclusion The Cloud Security Conundrum

I Security: The 800 pound gorilla of the Cloud world

I Nothing generates more fear in specific, and FUD in general I Probably the single greatest barrier to Cloud adoption

I Immediately behind it is the inability to get out of a 20th century IT mindset (i.e., ”Change is Bad”)

I The good news: we don’t need to fear it – we just need to solve it

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 6 / 32 Introduction Network path Bootloader Device model Xen Conclusion Cloud Security: New Visibility to Old Problem

I Security has always been an issue

I Putting a truly secure system in the open does not reduce its security, just increases the frequency of attack

I Unfortunately, system security behind the firewall has not always been comprehensive

I Having solutions in Clouds forces us to solve the security issues we should have already solved

I Security through obscurity is no longer sufficient

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 7 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security by Design, not by Wishful Thinking

I Security by Wishful Thinking is Officially Dead

I Merely hoping that your firewall holds off the marauding hordes is NOT good enough I Addressing security in one area while ignoring others is NOT good enough I Saying, ”We’ve never had a problem before” is NOT good enough I Comprehensive security starts with design

I It needs to planned and carefully thought through I It needs to be implemented at multiple levels I It needs components which are themselves securable

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 8 / 32 Introduction Network path Bootloader Device model Xen Conclusion Xen Project: Security by Design

I Xen Project was designed for Clouds before the term ”Cloud” was coined in the industry

I Designers foresaw the day of an ”infrastructure for wide-area distributed computing” which we now call ”the Cloud” I http://www.cl.cam.ac.uk/research /srg/netos/xeno/publications.html

I Xen is designed to thwart attacks from many attack vectors, using different defensive techniques

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 9 / 32 Introduction Network path Bootloader Device model Xen Conclusion Xen Architecture: A Basic Picture

dom 0 device model ()

toolstack

Paravirtualized Fully (PV) Virtualized Domain (HVM) Hardware netback netfront Domain Drivers blkback blkfront

Xen Hypervisor

I/O Devices CPU Memory Hardware

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 10 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security Overview

I Threat Models:

I Attacker can access network I Attacker controls one Guest VM I Security considerations to evaluate:

I How much code is accessible? I What is the interface like? (e.g., pointers vs scalars) I Defense-in-depth I Then combine security tactics to secure the installation

I There is no single ”magic bullet” I Individual tactics reduce danger; combined tactics go even farther

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 11 / 32 Introduction Network path Bootloader Device model Xen Conclusion Example System, for our Discussion

I Hardware setup

I Two networks: one Control network, one Guest network I IOMMU with interrupt remapping (AMD or VT-d v2) to allow for full (HVM) I Default configuration

I Network drivers in the Control Domain (aka ”Domain 0” or just ”Dom0”) I Paravirtualized (PV) guests using PyGrub (grub-like boot utility within context of Guest Domain) I Hardware Virtualized (HVM) guests using Qemu (as the device model) running in the Control Domain

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 12 / 32 Introduction Network path Bootloader Device model Xen Conclusion Attack surface: Network path

dom 0 toolstack Domain

netfront

iptables bridge Rogue Domain NIC netback netfront Driver

Xen Hypervisor

Control NIC Guest NIC Hardware

I Where might an exploit focus? I Bugs in hardware driver I Bugs in bridging / filtering I Bugs in netback (via the ring protocol)

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 13 / 32 Introduction Network path Bootloader Device model Xen Conclusion Attack surface: Network path

dom 0 toolstack Domain

netfront

iptables bridge Rogue Domain NIC netback netfront Driver

Xen Hypervisor

Control NIC Guest NIC Hardware

I What could a successful exploit yield?

I Control of Domain 0 kernel I Pretty much control of the whole system

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 14 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security feature: Driver Domains

dom 0 Domain toolstack netfront Driver Domain iptables bridge Rogue Domain

NIC NIC netback netfront Driver Driver

Xen Hypervisor

Control NIC Guest NIC Hardware

I What is a Driver Domain?

I Unprivileged VM which drives hardware, provides access to guests

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 15 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security feature: Driver Domains

dom 0 Domain toolstack netfront Driver Domain iptables bridge Rogue Domain

NIC NIC netback netfront Driver Driver

Xen Hypervisor

Control NIC Guest NIC Hardware

I Now a successful exploit could yield: I Control of the Driver Domain (PV hypercall interface) I Control of that guest’s network traffic I Control of NIC I An opportunity to attack netfront of other guests

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 16 / 32 Introduction Network path Bootloader Device model Xen Conclusion HowTo: Driver Domains

I Create a VM with appropriate drivers

I Use any distribution suitable as a Control Domain I Install the Xen-related hotplug scripts

I Just installing the Xen tools in the VM is usually good enough

I Give the VM access to the physical NIC with PCI pass-through I Configure the network topology in the Driver domain

I Just like you would for the Control Domain I Configure the guest Virtual Network Interface (vif) to use the new domain ID

I Add backend=domnet to vif declaration

vif = [ ’type=pv, bridge=xenbr0, backend=domnet’ ]

I http://wiki.xenproject.org/wiki/Driver Domain

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 17 / 32 Introduction Network path Bootloader Device model Xen Conclusion Attack surface: PyGrub

dom 0 toolstack domain builder

Paravirtualized pygrub (PV) Domain guest disk

Xen Hypervisor

I What is PyGrub? I grub implementation for PV guests I Python program running in Control Domain I Reads guest filesystem, parses grub.conf, shows menu I Passes resulting kernel image to domain builder

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 18 / 32 Introduction Network path Bootloader Device model Xen Conclusion Attack surface: PyGrub

dom 0 toolstack domain builder

Paravirtualized pygrub (PV) Domain guest disk

Xen Hypervisor

I Where might an exploit focus? I Bugs in file system parser I Bugs in menu parser I Bugs in domain builder

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 19 / 32 Introduction Network path Bootloader Device model Xen Conclusion Attack surface: PyGrub

dom 0 toolstack domain builder

Paravirtualized pygrub (PV) Domain kernel guest disk

Xen Hypervisor

I What could a successful exploit yield?

I Control of Domain 0 user space I Pretty much control of the whole system

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 20 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security practice: Fixed kernels

dom 0 toolstack kernel domain image builder

Paravirtualized (PV) Domain guest disk

Xen Hypervisor

I What is a fixed kernel?

I Passing a known-good kernel from Control Domain

I Removes attacker avenue to domain builder

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 21 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security practice: Fixed kernels

dom 0 toolstack kernel domain image builder

Paravirtualized (PV) Domain guest disk

Xen Hypervisor

I Disadvantages

I Host admin must keep up with kernel updates I Guest admin can’t pass kernel parameters, custom kernels,

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 22 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security feature: PVgrub

dom 0 toolstack domain builder pvgrub

MiniOS guest disk

Xen Hypervisor

I What is PVgrub? I MiniOS + PV port of grub running in a guest context I PV equivalent of HVM “BIOS + grub” I Now a successful exploit could yield: I Control of the attacked guest domain alone

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 23 / 32 Introduction Network path Bootloader Device model Xen Conclusion HowTo: PVgrub

I Make sure that you have the PVgrub image

I pvgrub-$ARCH.gz I Normally lives in /usr/lib/xen/boot I Included in Fedora Xen packages I -based: need to build yourself

I Use appropriate PVgrub as bootloader in guest configuration

kernel="/usr/lib/xen/boot/pvgrub-x86_32.gz"

I http://wiki.xenproject.org/wiki/Pvgrub

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 24 / 32 Introduction Network path Bootloader Device model Xen Conclusion Attack surface: Device model (Qemu)

I Where might an exploit focus?

I Bugs in NIC emulator parsing packets I Bugs in emulation of virtual devices I What could a successful exploit yield?

I Control Domain privileged userspace I Pretty much control of the whole system

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 25 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security feature: Qemu stub domains

I What is a stub domain?

I Stub domain: a small “service” domain running just one application I Qemu stub domain: run each Qemu in its own domain I What could a successful exploit yield?

I Control only of the stub domain VM (which, if FLASK is employed, is a relatively small universe) I You need to devise another attack entirely to do anything more significant

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 26 / 32 Introduction Network path Bootloader Device model Xen Conclusion HowTo: Qemu stub domains

I Make sure that you have the PVgrub image:

I ioemu-$ARCH.gz I Normally lives in /usr/lib/xen/boot I Included in Fedora Xen packages I On Debian (and offshoots), you will need to build it yourself

I Specify stub domains in your guest config

device_model_stubdomain_override = 1

I http://wiki.xenproject.org/wiki/Device Model Stub Domains

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 27 / 32 Introduction Network path Bootloader Device model Xen Conclusion Attack Surface: Xen Hypervisor itself

I Where might an exploit focus?

I On Paravirtualized (PV) Guests:

I PV Hypercalls

I On full Hardware Virtualized (HVM) Guests:

I HVM hypercalls (Subset of PV hypercalls) I Instruction emulation (MMIO, shadow pagetables) I Emulated platform devices: APIC, HPET, PIT I Nested virtualization

I Security practice: Use PV VMs whenever possible

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 28 / 32 Introduction Network path Bootloader Device model Xen Conclusion Security feature: FLASK example policy

I What is FLASK?

I Xen Security Module (XSM): Xen equivalent of LSM I FLASK: Framework for XSM developed by NSA I Xen equivalent of SELinux I Uses same concepts and tools as SELinux I Allows a policy to restrict hypercalls I What can FLASK do?

I Basic: Restricts hypercalls to those needed by a particular guest I Advanced: Allows more fine-grained granting of privileges I FLASK example policy

I This contains example roles for the Control Domain (dom0), User/Guest Domain(domU), stub domains, driver domains, etc.

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 29 / 32 Introduction Network path Bootloader Device model Xen Conclusion HowTo: Use the example FLASK policy

I Build Xen with XSM enabled

I Build the example policy I Add the appropriate label to guest config files

I seclabel=[foo] I stubdom label=[foo] I Make sure you TEST the example policy in your environment BEFORE putting it into production!

I NOTE: As an example policy, it is not as rigorously tested as other parts of Xen during release, and it may not be suitable as-is if you are doing unusual things

I http://wiki.xenproject.org/wiki /Xen Security Modules : XSM-FLASK

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 30 / 32 Introduction Network path Bootloader Device model Xen Conclusion ARM: Right solution for security

I Stays in ARM Hypervisor Mode

I The ARM architecture has separate Hypervisor and Kernel modes I Because Xen’s architecture maps so well to the ARM architecture, Xen never has to use Kernel mode I Other have to flip back and forth between modes I If a hypervisor has to enter Kernel mode, it loses the security of running in a privileged mode, isolated from the rest of the system I This is a non-issue with the Xen Hypervisor on ARM I Does not need to use device emulation

I No emulation means a smaller attack surface for bad guys

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 31 / 32 Introduction Network path Bootloader Device model Xen Conclusion For More Information...

Details at http://wiki.xenproject.org/wiki/Securing Xen

Thanks to George Dunlap for supplying much of the information presented here, and Stefano Stabellini for ARM information

Check out our blog: http://blog.xenproject.org/

Contact me at [email protected]

——————————–

Thank You!

CloudOpen North America 2013 Securing Your Cloud with Xen Project’s Advanced Security Features 32 / 32