From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Jeff Cody <jcody@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] Image probing: how it can be insecure, and what we could do about it
Date: Thu, 6 Nov 2014 14:02:41 +0100 [thread overview]
Message-ID: <20141106130241.GC4409@noname.redhat.com> (raw)
In-Reply-To: <87a944y0od.fsf@blackfin.pond.sub.org>
Am 06.11.2014 um 13:26 hat Markus Armbruster geschrieben:
> >> * 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.
Depends.
Another possible outcome is that the guest doesn't DoS itself, but
writes a valid image header. You've argued before that a guest could be
keeping a qcow2 image on a whole disk for whatever odd reason. In this
case, the qemu restart will present the nested image instead of the
top-level one to the guest, which can probably be labelled 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".
>
> Example: innocent guest first writes a recognized pattern, then
> overwrites it with a non-recognized pattern.
>
> Now: works.
>
> With Kevin's patch: as above.
>
> Again, I'm not claiming the differences are serious in practice, only
> that they exist.
Yes, the failure scenario is different. The point still stands that if
it were relevant in practice, we would likely have heard of it before.
> > You actually want to completely abolish probing? I thought we just
> > wanted to use the filename as a second source of information and warn
> > if the contents and the extension don't seem to match; and in the
> > future, maybe make it an error (but we don't have to discuss that
> > second part now, I think).
>
> Yes, I propose to ditch it completely, after a suitable grace period. I
> tried to make that quite clear in my PATCH RFC 2/2.
>
> Here's why.
>
> Now: 1. probe
> 4. open, error out if meta-data is bad
>
> With my proposed patch:
> 1. probe
> 2. guess from trusted meta-data
> 3. warn unless 1 and 2 match
> 4. open, error out if meta-data is bad
>
> Now make the warning an error:
> 1. probe
> 2. guess from trusted meta-data
> 3. error out unless 1 and 2 match
> 4. open, error out if meta-data is bad
>
> I figure the following is equivalent, but simpler:
>
> 2. guess from trusted meta-data
> 4. open, error out if meta-data is bad
>
> because open should detect all the errors the previous step 3 caught.
> If not, things are broken with explicit format=.
Not entirely true, see below.
> > My conclusion: Don't ditch probing. It increases entropy, why would
> > you ditch probing? Just combine it with the extension and if both
> > don't seem to match, that's an error.
>
> How does probing add value?
>
> Compare
>
> 1. probe
> 2. guess from trusted meta-data
> 3. error out unless 1 and 2 match
> 4. open, error out if meta-data is bad
>
> to just
>
> 2. guess from trusted meta-data
> 4. open, error out if meta-data is bad
>
> Let P be the driver recommended by probe, and G be the driver
> recommended by guess.
P = qcow2, G = raw
> If P == G, same result: we open with the same driver.
No, they are not the same.
> Else, if open with G fails, equivalent result: error out in step 3
> vs. error out in step 4.
No, raw accepts the image.
> Else, we have an odd case: one driver's probe accepts (P's), yet a
> different driver's open succeeds (G's).
>
> If G's probe rejects: is this a bug? Shouldn't open always fail
> when probe rejects?
No, raw's probe doesn't reject, it just has a very low score.
> If G's probe accepts, then probing chose P over G. Maybe it
> shouldn't have. Or maybe the probing functions are imprecise.
> Anyway, keeping probing around makes this an error. Should it be
> one?
Yes, raw being the fallback for everything is imprecise. It's the only
way we have for probing raw.
> Am I missing something?
This is the safety measure that was missing in your proposal, against
corruption caused by a qcow2 image stored in foo.img that is now
unintentionally opened as raw.
Same thing probably for qcow2 stored on LVs etc.
Kevin
next prev parent reply other threads:[~2014-11-06 13:02 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
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 [this message]
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=20141106130241.GC4409@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=jcody@redhat.com \
--cc=mreitz@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).