Xen hypervisor memory corruption due to x86 emulator flaw
xenbits.xen.org
xenbits.xen.org
Additional thoughts by Qubes Security Team
===========================================
We see several problems that concern us about this vulnerability and
patching process:
1) It seems really difficult to understand why would anybody design a
structure like the one shown above, which uses a union to store two,
RADICALLY DIFFERENTLY TRUSTED data: an internal pointer into
hypervisor memory and VM-provided UNTRUSTED DATA? Such design decision
made by one of the core hypervisor developer is certainly worrying.
We're not sure if it would be more worrying if this was done purposely
vs by carelessness...
2) We are not entirely convinced if the way Xen Security Team decided
to address this vulnerability is really optimal, security wise. It
seems like a more defensive approach would be to get rid of this
dangerous construct of reusing the same memory for both an internal
pointer and VM-provided data. Apparently Xen developers believe that
they can fully understand the code, with all its execution paths, for
decoding x86 operands. This optimistic attitude seems surprising,
given the very bug we're discussing today.
3) This lack of defensive programing and perhaps over confidence (in
ability to fully understand all the code paths) has been demonstrated
by the Xen Security Team also previously. In the recently released XSA
109 [2], the official patch also seemed to address the problem much
earlier in the execution path rather than at the actual offending
instructions, i.e. those that performed the NULL-dereference. While
asked specifically about adding at least an additional check on these
instructions, the Xen developers were unwilling to implement it
implying potential performance impact.
4) This is all certainly a bit disconcerting and we hope we could
start a bit more public debate on these issues, especially among
independent security researchers. We still believe Xen is currently
the most secure hypervisor available, mostly because of its unique
architecture features, that are lacking in any other product we are
aware of.
[1]: https://raw.githubusercontent.com/QubesOS/qubes-secpack/mast...Does anyone know why KVM would be considered less secure than Xen?
Xen allows for creating an entire stub domU solely for running the driver, then giving a running guest access via ring buffer in a shared memory segment.
(So, yep, you're correct in your thinking)
PVH fixes it so you don't need emulation in Linux, but it's a brand new feature and probably not production quality. Read this (it's not too technical) http://wiki.xen.org/wiki/Virtualization_Spectrum
As of this writing, Xen 4.4 and Linux 3.14 have experimental support for PVH DomUs and Xen 4.5 has support for PVH Dom0s. PVH allows practically native-hardware-speed guests without any emulation.
Local APIC emulation is fully accelerated on modern processors, which is a big win for any use case that is heavy on interrupts.
Things happen. We should be glad that these sort of security problems are being found and addressed; it would be naive to believe Xen or any other large codebase has zero security problems.
VM's should be regularly patched anyway, which usually requires a reboot now and then. If it were a physical server, the same would be true; just because things are in the "cloud" now doesn't mean they will have infinite uptime.
I understand that sometimes these services reboot and patch with little notice, but this should be built into any Terms Of Service constructed with your client(s); ie. "We will patch and reboot your service for critical vulnerabilities as quickly as possible, which in some circumstances may leave only short notice."
You can't migrate to a new kernel on Linode without a reboot anyway, so if you're proud of a 12+ month uptime, you're running a vulernable kernel.
> A security vuln, almost by definition, requires a shared resource. No sharing, no caring
You would only not care if your servers have zero access to the internet and are air-gaped from the rest of your network (even then it's been proven some vulnerabilities can be exploited to gain access).
http://docs.vmd.citrix.com/XenServer/5.0.0/1.0/en_gb/install...
I discussed it in detail previously on HN [0], but we give you the ability to live-migrate your workloads, even onto heterogeneous kernels. If that's something you really need, you can get it from Terminal today.
"Non-standard PCI device functionality may render pass-through insecure " http://xenbits.xen.org/xsa/advisory-124.html
the others also released today
We've got a distribution of Xen 4.4/ARMv7/ubuntu for anyone curious to try it out on a cheapo Cubieboard2 or Cubietruck over at https://github.com/mirage/xen-arm-builder (with prebuilt SDcard images at http://blobs.openmirage.org)
Nobody is proposing re-writing a hypervisor in Java or Python, but C/C++ isn't the only game in town anymore for unmanaged code, and the alternatives are designed from the ground up with security in mind.
> and the alternatives are designed from the ground up with security in mind
The RMS Titanic was billed as one of the safest ships on the sea -- yet due to poorly implemented protocols and practices, negligent leadership, and disregard for best practices, it resulted in one of the most catastrophic maritime disasters.
Using the most "secure" programming language in the world, one can still design very insecure code. Conversely, using the most "insecure" programming language in the world, one can still design very secure code. This would boil down to the skill of the engineers, competence of leadership and adherence to best practices.
C/C++ starts you in a position where it is extremely easy to write insecure code. Even a competent coder can produce insecure code in either language without a great deal of effort or stupidity on their part.
Other languages aren't "unsinkable" to come back to the Titanic, but they make it harder to sink, and the requirements on the developer aren't as high. Just like with the Titanic you have to hit the iceberg in a certain specific way to sink, rather than sinking from any old collision.
Certain C/C++ compilers have definitely made the situation better when in "strict mode" as well as a lot of tooling to identify potential problem points. However ultimately the language is plagued by "undefined behaviour" and a large code-base where developers are using various insecure tricks to save pennies (e.g. this exact exploit, where they are creating insecure code to save a single structure's worth of memory, which on an 8 GB stick of RAM is less than 1/2 of 1c worth (assuming $60/8 GB stick)).
It's worth mentioning K&R, which used to be where people learn C, has a huge number of instances of very risky practices.