qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Jeff Cody <jcody@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Image probing: how it can be insecure, and what we could do about it
Date: Thu, 06 Nov 2014 16:00:28 +0100	[thread overview]
Message-ID: <545B8D0C.4040600@redhat.com> (raw)
In-Reply-To: <20141106145658.GD23802@localhost.localdomain>

On 2014-11-06 at 15:56, Jeff Cody wrote:
> On Thu, Nov 06, 2014 at 01:53:35PM +0100, Max Reitz wrote:
>> On 2014-11-06 at 13:26, Markus Armbruster wrote:
>>> Max Reitz <mreitz@redhat.com> writes:
>>>
>>>> On 2014-11-04 at 19:45, Markus Armbruster wrote:
>>>>> I'll try to explain all solutions fairly.  Isn't easy when you're as
>>>>> biased towards one of them as I am.  Please bear with me.
>>>>>
>>>>>
>>>>> = The trust boundary between image contents and meta-data =
>>>>>
>>>>> A disk image consists of image contents and meta-data.
>>>>>
>>>>> Example: all of a raw image's contents is image contents.  Leaves just
>>>>> file name and attributes for meta-data.
>>>>>
>>>>> Example: QCOW2 meta-data includes header, header extensions, L1 table,
>>>>> L2 tables, ...  The meta-data defines where in the image the actual
>>>>> contents is stored.
>>>>>
>>>>> A guest can access the image contents, not the meta-data.
>>>>>
>>>>> Image contents you've let an untrusted guest write is untrusted.
>>>>>
>>>>> Therefore, there's a trust boundary between image contents and
>>>>> meta-data.  QEMU has to trust image meta-data, but shouldn't trust image
>>>>> contents.  The exact location of the trust boundary depends on the image
>>>>> format.
>>>>>
>>>>>
>>>>> = How we instruct QEMU what to trust =
>>>>>
>>>>> By configuring QEMU to use an image, the user instructs QEMU to trust
>>>>> the image's meta-data.
>>>>>
>>>>> When the user's configuration specifies the image format explicitly, the
>>>>> trust boundary is clear.
>>>>>
>>>>> Else, the trust boundary is ambigous when more than one format is
>>>>> possible.
>>>>>
>>>>> QEMU resolves this ambiguity by picking the first format with the
>>>>> highest "score".  Raw format is always possible, and always has the
>>>>> lowest score.
>>>>>
>>>>>
>>>>> = How this lets the guest escape isolation =
>>>>>
>>>>> Unfortunately, this lets the guest shift the trust boundary and escape
>>>>> isolation, as follows:
>>>>>
>>>>> * Expose a raw image to the guest (whether you specify the format=raw or
>>>>>     let QEMU guess it doesn't matter).  The complete contents becomes
>>>>>     untrusted.
>>>>>
>>>>> * Reuse the image *without* specifying the raw format.  QEMU guesses the
>>>>>     format based on untrusted image contents.  Now QEMU guesses a format
>>>>>     chosen by the guest, with meta-data chosen by the guest.  By
>>>>>     controlling image meta-data, the malicious guest can access arbitrary
>>>>>     files as QEMU, enlarge its storage, and more.  A non-malicious guest
>>>>>     can accidentally DoS itself, by writing a pattern probing recognizes.
>>>> Thank you for bringing that to my attention. This means that I'm even
>>>> more in favor of using Kevin's patches because in fact they don't
>>>> break anything.
>>> They break things differently.  The difference may or may not matter.
>>>
>>> Example: innocent guest writes a recognized pattern.
>>>
>>>    Now: next restart fails, guest DoSed itself until host operator gets
>>>    around to adding format=raw to the configuration.  Consequence:
>>>    downtime (probably lengthy), but no data corruption.
>>>
>>>    With Kevin's patch: write fails, guest may or may not handle the
>>>    failure gracefully.  Consequences can range from "guest complains to
>>>    its logs (who cares)" via "guest stops whatever it's doing and refuses
>>>    to continue until its hardware gets fixed (downtime as above)" to
>>>    "data corruption".
>> You somehow seem convinced that writing to sector 0 is a completely
>> normal operation. For x86, it isn't, though.
>>
>> There are only a couple of programs which do that, I can only think
>> of partitioning and setting up boot loaders. There's not a myriad of
>> programs which would increase the probability of one both writing a
>> recognizable pattern *and* not handling EPERM correctly.
>>
>> I see the probability of both happening at the same time as
>> extremely low, not least because there are only a handful of
>> programs which access that sector.
>>
> I'm not yet opposed to the "restricted-raw" method, but...
>
> I think the above is a somewhat dangerous viewpoint to take with QEMU.
> It is a bit of a slippery slope to start to assume what data guests
> will write to the disks provided to them.  Even if the probability of
> this happening is very low, with what usage we envision now, it is
> still entirely legitimate usage for a guest to write data starting at
> sector 0.

Then let's officially deprecate format probing, if we haven't done so 
already. That way, there's no excuse.

What I'm saying is that there are obviously no compatibility issues. 
There is no guest software which did write recognizable patterns (so far 
nobody provided a counterexample), and since format probing is 
deprecated (or should be), you have no excuse for running future guests 
in qemu without having explicitly specified the format.

And if you are specifying the format, Kevin's patches will not prevent 
the guest from making its disk a qcow2 image whatsoever.

Max

  reply	other threads:[~2014-11-06 15:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04 18:45 [Qemu-devel] Image probing: how it can be insecure, and what we could do about it Markus Armbruster
2014-11-04 20:33 ` Jeff Cody
2014-11-05  7:04   ` Markus Armbruster
2014-11-05  7:30 ` Markus Armbruster
2014-11-05  8:38 ` Max Reitz
2014-11-05 10:18   ` Eric Blake
2014-11-06 12:43     ` Markus Armbruster
2014-11-06 13:02       ` Eric Blake
2014-11-05 11:15   ` Kevin Wolf
2014-11-06 12:26   ` Markus Armbruster
2014-11-06 12:53     ` Max Reitz
2014-11-06 14:56       ` Jeff Cody
2014-11-06 15:00         ` Max Reitz [this message]
2014-11-07 14:52           ` Markus Armbruster
2014-11-07 15:17             ` Max Reitz
2014-11-10  7:58               ` Markus Armbruster
2014-11-07  9:57       ` Markus Armbruster
2014-11-06 13:02     ` Kevin Wolf
2014-11-07 14:50       ` Markus Armbruster
2014-11-05 10:12 ` Gerd Hoffmann
2014-11-05 10:33 ` Eric Blake
2014-11-06 12:52   ` Markus Armbruster
2014-11-05 11:01 ` Kevin Wolf
2014-11-06 13:57   ` Markus Armbruster
2014-11-06 14:14     ` Eric Blake
2014-11-06 15:52       ` Jeff Cody
2014-11-06 14:35     ` Jeff Cody
2014-11-06 15:01     ` Kevin Wolf
2014-11-07 15:21       ` Markus Armbruster
2014-11-07 17:33         ` Jeff Cody
2014-11-10  8:12           ` Markus Armbruster
2014-11-10  9:14             ` Kevin Wolf
2014-11-10 10:30               ` Markus Armbruster
2014-11-10 14:24                 ` Jeff Cody
2014-11-11  8:28                   ` Markus Armbruster
2014-11-10  8:13         ` Markus Armbruster
2014-11-05 15:24 ` Dr. David Alan Gilbert
2014-11-06 13:04   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=545B8D0C.4040600@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).