News for hackers. Stuff that matters.
Re:QEMU VM Escape by sansnomme on Sunday August 25, 2019 @09:25PM (#20796831)
If the VM is ran in a hypervisor, will this be able to break out of the hypervisor?
Re:QEMU VM Escape by darren0 on Sunday August 25, 2019 @10:34PM (#20797043)
Yes but slirp isn't used in a production grade setup. It's more of a simple slow default that's guarantees to work, so it's used mostly in development setups.
Re:QEMU VM Escape by bonzini on Monday August 26, 2019 @02:42AM (#20797904)
Note that since the last version of QEMU (4.1, released a few days ago) slirp has been moved out into a separate library hosted at https://gitlab.freedesktop.org/slirp/libslirp.

There is interest in using it in container runtimes as well, and hopefully this will give slirp more love. It's very old code that most QEMU developers wouldn't have touched with a ten-foot pole...

Re:QEMU VM Escape by rtpg on Monday August 26, 2019 @04:54AM (#20798306)
>Testing

> Unfortunately, there are no automated tests available.

> You may run QEMU -net user linked with your development version.

Not trying to shame anyone here, but I do think that this would be a good entry point for anyone trying to help this project out. Hell, this might be a fun little target for property testing or other kinds of generative testing

Re:QEMU VM Escape by sansnomme on Sunday August 25, 2019 @11:22PM (#20797235)
Why would it compromise the hypervisor though?
Re:QEMU VM Escape by geofft on Monday August 26, 2019 @12:45AM (#20797508)
There's no separate "hypervisor" component. QEMU itself is the hypervisor. That is, QEMU is a regular computer program whose functionality is to emulate a machine; that emulated machine is called a virtual machine. QEMU itself runs on a regular computer OS like Linux. (QEMU with hardware acceleration is a perfectly good and quite common production-grade virtualization setup.) All the code described here is part of QEMU itself, not part of the virtualized OS running inside QEMU.

If a VM running inside QEMU is able to compromise QEMU's code, it then runs with the privileges of QEMU on the host. The host, the regular OS running QEMU, is colloquially called "the hypervisor." And in most production virtualization setups, there is nothing of interest on the host other than some QEMU processes itself, i.e., anything valuable on the host is perfectly well accessible to QEMU, and therefore to malicious code that has taken over the QEMU process.

Re:QEMU VM Escape by jsolson on Monday August 26, 2019 @01:22AM (#20797621)
It's quite reasonable to distinguish QEMU from the hypervisor: QEMU typically runs with strictly lower privileges.

The "hardware acceleration" that helps QEMU emulate a computer operates in root VMX and non-root VMX (when actually executing guest instructions) modes. When operating in root VMX mode as a supervisor, it has approximately the highest privileges in the system (ignoring SMM), as it is operating in host ring 0. QEMU runs in host ring 3, making it a typical user mode process. If you manage to compromise QEMU (and only QEMU), you have only escaped into host user mode. In that case you haven't compromised the hypervisor, merely the virtual machine monitor.

If, on the other hand, you manage to compromise KVM (or vhost) you could reasonably claim to have actually compromised the hypervisor.

Type 2 hypervisors make this generally much uglier than type 1, but it's reasonable to say that the hypervisor in a type 2 deployment is limited to the kernel component rather than the user-mode VMM.

Re:QEMU VM Escape by person_of_color on Monday August 26, 2019 @05:49AM (#20798492)
Where do you get this type of academic education of virtualization techniques?
Re:QEMU VM Escape by jsolson on Tuesday August 27, 2019 @12:45AM (#20806396)
Some of it is academic study (BS and MS at Georgia Tech) -- that helped with the theory and a bit of the breadth. That said, most of what I know of modern virtualization was more or less "on the job" from working on Google Compute Engine. Lots of practical experience understanding virtualization boundaries, and really really enormous access to historical domain experts in the space.
Re:QEMU VM Escape by RaitoBezarius on Monday August 26, 2019 @11:14AM (#20800525)
Depends on your country, but I suppose it has to do with theoretical computer science at the master level, you can see a lot of academic content around this (in Paris, France for example): https://wikimpri.dptinfo.ens-cachan.fr/doku.php (yes, HTTPS is broken…)
Re:QEMU VM Escape by rasz on Monday August 26, 2019 @10:29AM (#20800144)
> it has approximately the highest privileges in the system (ignoring SMM)

and MINIX in case of Intel :-)

Re:QEMU VM Escape by bonzini on Monday August 26, 2019 @02:50AM (#20797936)
> anything valuable on the host is perfectly well accessible to QEMU

In a well configured KVM instance QEMU obeys the principle of least privilege as much as possible, that is it can only access the resources it needs to do its job.

In practical terms, this means QEMU is confined (via SELinux, cgroups, Unix permissions, seccomp) to only access resources for the VM it is running; taking over QEMU does not give you access to "anything valuable on the host".

Of course, having remote code execution in QEMU is awful; it can be a base for exploiting a kernel vulnerability to get root access. Luckily this bug would not be exploitable in a production setting.

Re:QEMU VM Escape by zurn on Monday August 26, 2019 @02:53AM (#20797941)
I think the intersection of conigurations where QEMU is using the SLiRP networking and where it's carefully configured to use the (non-default) sandboxing is pretty small. The sandboxing configs are typically associated with use of libvirt where you'll probably be using tun/tap or some other non-slirp kind of networking.
Re:QEMU VM Escape by bonzini on Monday August 26, 2019 @03:24AM (#20798034)
Exactly, this is why this bug is unlikely to be exploitable in production (OpenStack for example only runs QEMU via Libvirt).
Re:QEMU VM Escape by geofft on Monday August 26, 2019 @08:46AM (#20799376)
In a production system, it's highly unlikely that there is anything on the host besides the VM. You're not running qemu on one core and an unvirtualized database on another. Amazon is not running an S3 file server on the same physical machine that's being an EC2 host. The only valuable thing is other VMs.

And I think that there is no common configuration of OpenStack or libvirt that assigns unique access control labels per VM. Every qemu runs with the same privileges, ergo one exploited qemu can laterally attack another. (But maybe there's something nifty I'm missing?)

(Agree that for the use case of desktop virtualization, a good SELinux config can keep it from accessing your browser cookies.)

Re:QEMU VM Escape by mjg59 on Monday August 26, 2019 @09:21AM (#20799630)
SVirt will usually use a per-VM label that should inhibit direct lateral interaction.
Re:QEMU VM Escape by bonzini on Monday August 26, 2019 @12:42PM (#20801298)
FWIW, sVirt is the "code name" for Libvirt's SELinux labeling scheme. It uses SELinux multi-category security to ensure that each QEMU can only access resources destined to one VM.