[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Critique of the Xen Security Process


  • To: xen-devel@xxxxxxxxxxxxx
  • From: Doug Goldstein <cardoe@xxxxxxxxxx>
  • Date: Mon, 9 Nov 2015 15:48:42 -0600
  • Delivery-date: Mon, 09 Nov 2015 21:49:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

On 11/6/15 11:22 AM, Joanna Rutkowska wrote:
> Hello,
> 
> Recently Xen has released the XSA-148 advisory [1] addressing a fatal bug in 
> the
> hypervisor. The bug has been lurking there for the last 7 years! We, the Qubes
> OS Project, have commented on this in our Security Bulletin #22 [2]. And far
> from enthusiastic commentary that was (FWIW, it was me who wrote this QSB, as
> evidenced in the commits log, in case some from the Xen community would like 
> to
> direct their rage towards a particular human being ;) Ian Jackson then wrote a
> response on the Xen blog [3]. I was then asked to share some more thoughts 
> about
> how I thought Xen could actually improve its security process [4]. So, I share
> some these below:
> 
> 1. First of all, I wish Xen was somehow more defensively coded. To provide 
> some
> examples:
> 
> a. In XSA-109 [5] there was a problem with the hypervisor dereferencing a NULL
> pointer. The problem was fixed by the Xen Security Team by applying a patch
> which (hopefully) made sure the execution path that lead to this NULL pointer
> dereferencing code was never taken. Back then I suggested (on the Xen
> pre-disclosure list) to make this patch more explicit though:
> 
>> On Wed, Jan 21, 2015 at 02:31:51PM +0100, Joanna Rutkowska wrote:
>> (...)
>>>
>>> Wouldn't it be prudent to also check if:
>>>
>>> (v->arch.paging.mode>{write_guest_entry,cmpxchg_guest_entry} != NULL)
>>>
>>> ... in the two affected functions, just before derefing these function
>>> pointers?
>>>
>>> Going even a step further: how about replacing all
>>> function-pointer-based calls with macros that first validates the
>>> pointer before derefing it? At least when the system doesn't have SMEP?
>>>
> 
> ...to which I got a reply from one of the Xen Security Team engineers that the
> above might perhaps be justified in debug builds only, followed by a standard:
> "feel free to contribute a patch".
> 
> b. The XSA-123 [6] was another critical security bug in Xen, this time 
> resulting
> from one of the hypervisor developer's fetish to use an absolutely confusing
> construct in order to save a few modest bytes in a structure which might have
> been allocated by the system maybe a few tens of times at best. Even more
> worrying was the way how Xen Security Team decided to fix the bug: again by
> modifying some condition in the code further up the execution path, with the
> hopes that this time they would ensure this puzzling construct would always be
> used properly. We wrote more about this in our QSB #18 [7].
> 
> c. Finally, the way how Xen fixed the recent XSA-148 looks also very reactive,
> IMHO. With a bug of this calibre, I would expect Xen to carefully review and
> augment all its PV memory virtualization code with additional checks 
> (ASSERTs),
> ensuring certain invariants are always satisfied. Such as e.g. that none of 
> the
> pages containing PDEs or PTEs are becoming writeable by the VM.
> 
> I can't help but have a feeling that some of the Xen developers seem to be
> overconfident in their belief they can fully understand all the possible
> execution paths in their code. Well, the XSAs quoted above are an indisputable
> prove that this is not quite always the case. Realizing that, each developer 
> by
> themselves, might be a great step towards a more secure hypervisor...
> 
> 2. Another security-related aspect of the Xen project is how it totally 
> ignores
> problems related to the build process security. Those who don't believe me
> should grep the sources for wget, which is now disguised as "FETCHER" shell
> variable... (so grep for "FETCHER" string)
> 
> I feel embarrassed that I need to explain, at the end of 2015, why the build
> process of any serious software project should not blindly download unsigned
> components (sources) from the Internet, especially if it is about to execute
> Makefiles from these components a moment later... Come on, guys!

I'll echo this sentiment as well. Most distro packagers will dislike
this and need to work around some of this behavior in their respective
distros. Project Raisin is aiming to help with this but it doesn't seem
to have a lot of community effort behind it and it too attempts to
install dependencies on my machine and wants to be run with sudo.


> 
> (Of course we have been forced to get around this gapping security whole in
> Qubes OS [8] ourselves, sadly with a method that is not well suited for
> upstreaming).
> 
> 3. Another thing is, of course: stop adding features to the core hypervisor. 
> We
> really need Xen to finally mature, stabilize, and for its development process 
> to
> be slowing down over time (just the bug fixes). We need a long-term-supported
> hypervisor, which doesn't change with subsonic speed. This would allow this 
> core
> code to be widely audited by many experts. If some users want features, these
> should perhaps be maintained as additional modules (no, I don't mean 
> dynamically
> loaded modules, just compile-time included), preferably in separate repos.
> 

As far as the compile time support goes I'm aiming for this as well.
I've been working on Kconfig support and hope to get that pushed soon
and the idea being that less mature features can be kept off until
they're ready to be default on. The downstream distro/product makers can
then fiddle with these flags to get the hypervisor that fits their needs.

> Perhaps also to move all the non-hypervisor code, such as all the toolstacks,
> stubdom, etc, into separate repos also. For hygiene, if for nothing else.

From a real high level things should be broken into at least 4 repos:
1) hypervisor
2) libxl
3) userland tools (xl and support scripts)
4) stubdom

> 
> Admittedly, some of the features are a result of hardware evolution, such as
> e.g. UEFI support. But many are not. Again, maintaining these as optional code
> (in separate repos) would be a great step into getting the hypervisor 
> maturing,
> finally.
> 
> I have already written about it years ago [9], as a matter of fact.
> 
> 4. Finally, I've been really surprised by the line of reasoning Ian expressed 
> in
> the above-mentioned blog post. TL;DR: "we're still doing pretty great, 
> compared
> to other projects, because: 1) we have smaller number of publicly disclosed
> bugs, and 2) we actually publicly disclose these bugs which we are aware of".
> 
> The attitude presented in the blog post is so wrong, that I'm not even sure
> where to start commenting on this...
> 
> With a single bug like the XSA-148 which, let me repeat that one more time: 
> had
> been present in the hypervisor for the last 7 years, so with a bug like this 
> it
> really doesn't matter how many (i.e. what number) of critical bugs does the
> competition have. Because only one bug of this calibre is enough for the
> attacker to never really bother to find another one. The mere fact that
> competing hypervisors might got 12 bugs during the same period, really doesn't
> make Xen look any better, sorry.
> 
> Also, there is really nothing to be proud that you disclose the bugs. It would
> be a problem if you didn't.
> 
> Hope the above comments might help improve the Xen security. Perhaps some 
> would
> perceive them as arrogant or rude. Too bad. Remember the actual attackers will
> not be arrogant or rude -- they will just come and exploit bugs, silently.
> Admittedly this might not hurt some of the developers ego, not in the short 
> time
> at least.
> 
> Can we, the Qubes OS project, or myself personally, help with implementing the
> above suggestions? Sadly, no. While some of us do contribute occasional 
> patches
> to Xen (specifically Marek Marczykowski-GÃrecki), we really work for a 
> different
> project and have different tasks and responsibilities.

This is where I'll disagree with you. I too work for a different project
and have different tasks and responsibilities but as a consumer of Xen
we do have the responsibility to try to upstream things where
applicable. Could create patches locally to disable features that I
don't want/need on? Of course and it probably would take me less time
but in the long run upstreaming a generic framework will have an immense
pay off for not just me and my organization but everyone else. You
cannot rail at a project for not doing the work which serves your end
goals without doing some of that work yourself.


> 
> Regards,
> joanna.
> 
> [1] http://xenbits.xen.org/xsa/advisory-148.html
> [2] https://github.com/QubesOS/qubes-secpack/blob/master/QSBs/qsb-022-2015.txt
> [3] https://blog.xenproject.org/2015/10/30/security-vs-features/
> [4] https://twitter.com/xen_org/status/660151720463482880
> [5] http://xenbits.xen.org/xsa/advisory-109.html
> [6] http://xenbits.xen.org/xsa/advisory-123.html
> [7] https://github.com/QubesOS/qubes-secpack/blob/master/QSBs/qsb-018-2015.txt
> [8] 
> https://github.com/QubesOS/qubes-vmm-xen/commit/dcd6c0a4f2c6226a9b706e62469d420579c86975
> [9] http://lists.xen.org/archives/html/xen-devel/2013-09/msg01815.html
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel
> 

-- 
Doug Goldstein

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.