qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH RFC 2/2] block: Warn on insecure format probing
Date: Thu, 30 Oct 2014 10:08:46 +0100	[thread overview]
Message-ID: <5452001E.9070907@redhat.com> (raw)
In-Reply-To: <1414512220-19058-3-git-send-email-armbru@redhat.com>

On 2014-10-28 at 17:03, Markus Armbruster wrote:
> If the user neglects to specify the image format, QEMU probes the
> image to guess it automatically, for convenience.
>
> Relying on format probing is insecure for raw images (CVE-2008-2004).
> If the guest writes a suitable header to the device, the next probe
> will recognize a format chosen by the guest.  A malicious guest can
> abuse this to gain access to host files, e.g. by crafting a QCOW2
> header with backing file /etc/shadow.
>
> Commit 1e72d3b (April 2008) provided -drive parameter format to let
> users disable probing.  Commit f965509 (March 2009) extended QCOW2 to
> optionally store the backing file format, to let users disable backing
> file probing.  QED has had a flag to suppress probing since the
> beginning (2010), set whenever a raw backing file is assigned.
>
> Despite all this work (and time!), we're still insecure by default.  I
> think we're doing our users a disservice by sticking to the fatally
> flawed probing.  "Broken by default" is just wrong, and "convenience"
> is no excuse.
>
> I believe we can retain 90% of the convenience without compromising
> security by keying on image file name instead of image contents: if
> the file name ends in .img or .iso, assume raw, if it ends in .qcow2,
> assume qcow2, and so forth.
>
> Naturally, this would break command lines where the filename doesn't
> provide the correct clue.  So don't do it just yet, only warn if the
> the change would lead to a different result.  Looks like this:
>
>      qemu: -drive file=my.img: warning: insecure format probing of image 'my.img'
>      To get rid of this warning, specify format=qcow2 explicitly, or change
>      the image name to end with '.qcow2'
>
> This should steer users away from insecure format probing.  After a
> suitable grace period, we can hopefully drop format probing
> alltogether.
>
> Example 0: file=WHATEVER,format=F
>
> Never warns, because the explicit format suppresses probing.
>
> Example 1: file=FOO.img
>
> Warns when probing of FOO.img results in anything but raw.  In
> particular, it warns when the guest just p0wned you.
>
> Example 2: file=FOO.qcow2 with backing file name FOO.img and no
> backing image format.
>
> Warns when probing of FOO.qcow2 results in anything but qcow2, or
> probing of FOO.img results in anything but raw.
>
> This patch is RFC because of open questions:
>
> * Should tools warn, too?  Probing isn't insecure there, but a "this
>    may pick a different format in the future" warning may be
>    appropriate.
>
> * I didn't specify recognized extensions for formats "bochs", "cloop",
>    "parallels", "vpc", because I have no idea which ones to recognize.
>
> Additionally, some tests still need to be updated.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   block.c                   | 46 ++++++++++++++++++++++++++++++++++++++++++++--
>   block/dmg.c               |  1 +
>   block/qcow.c              |  1 +
>   block/qcow2.c             |  1 +
>   block/qed.c               |  1 +
>   block/raw_bsd.c           |  1 +
>   block/vdi.c               |  1 +
>   block/vhdx.c              |  1 +
>   block/vmdk.c              |  1 +
>   include/block/block_int.h |  1 +
>   10 files changed, 53 insertions(+), 2 deletions(-)


So I guess it's my turn to give yet another opinion (or just something 
in between of what has been already said).

First, I'm fine with this patch, or at least the idea as there were yet 
some quirks.

But I oppose turning the warning into an error eventually. I want to be 
able to use -hda $filename and it should work. As Kevin said, a warning 
alone will not help a lot, though. I don't know about that, I think it 
should work. This warning should only appear when you're using qemu 
directly because management tools should already use -drive with format= 
or driver=; and if you're using qemu directly you should be watching stderr.

The only way I'd be fine with turning this into an error would be to 
make an exception for -hda and the like. There were already plans of 
introducing pseudo block drivers for format and protocol probing; if we 
do that we can use those block drivers for -hda. We should still emit 
the warning, but in my opinion it should never be an error with -hda, 
-cdrom etc.. For me, this is not about backwards compatibility but 
because I'm using -hda myself.

On the other hand, I'm very fine with Kevin's proposal. Bootloaders 
normally don't change that often and there's not that much variety 
(aside from hand-written hobby stuff) so we should be able to regularly 
make sure that nothing breaks. I'd like to increase the entropy, though, 
so we should take another look into the block drivers' probing functions 
and make them more specific, if possible. I don't feel like testing four 
bytes is enough (although in practice it should be).

Also, I like Kevin's proposal/Anthony's approach a lot more because of 
its principle. If a guest can overwrite the beginning of the image so it 
looks like an image format, that's the real bug. Afterwards, anyone will 
recognize that image as non-raw and they'd be correct.

Max

  parent reply	other threads:[~2014-10-30  9:09 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 16:03 [Qemu-devel] [PATCH RFC 0/2] block: Warn on insecure format probing Markus Armbruster
2014-10-28 16:03 ` [Qemu-devel] [PATCH RFC 1/2] block: Factor bdrv_probe_all() out of find_image_format() Markus Armbruster
2014-10-28 16:34   ` Eric Blake
2014-10-28 16:41   ` Jeff Cody
2014-10-29 15:22   ` Stefan Hajnoczi
2014-10-28 16:03 ` [Qemu-devel] [PATCH RFC 2/2] block: Warn on insecure format probing Markus Armbruster
2014-10-28 17:02   ` Eric Blake
2014-10-28 18:29     ` Jeff Cody
2014-10-28 18:56       ` Eric Blake
2014-10-28 19:42         ` Jeff Cody
2014-10-29  7:36           ` Markus Armbruster
2014-10-29  8:25             ` Max Reitz
2014-10-29  7:22         ` Markus Armbruster
2014-10-30 13:58           ` Jeff Cody
2014-11-03  8:07             ` Markus Armbruster
2014-10-29  7:03     ` Markus Armbruster
2014-10-28 18:33   ` Jeff Cody
2014-10-29  6:37     ` Markus Armbruster
2014-10-30 13:52       ` Jeff Cody
2014-11-03  8:11         ` Markus Armbruster
2014-10-29  1:16   ` Fam Zheng
2014-10-29  6:32     ` Markus Armbruster
2014-10-29 10:12   ` Kevin Wolf
2014-10-29 13:54     ` Markus Armbruster
2014-10-29 15:34       ` Stefan Hajnoczi
2014-10-30  9:07         ` Markus Armbruster
2014-10-30  9:24           ` Stefan Hajnoczi
2014-10-30 12:19             ` Markus Armbruster
2014-10-30  9:30       ` Kevin Wolf
2014-10-30 12:49         ` Markus Armbruster
2014-10-31 11:19           ` Stefan Hajnoczi
2014-10-31 22:45           ` Eric Blake
2014-11-03  8:15             ` Markus Armbruster
2014-11-03 11:13             ` Kevin Wolf
2014-11-04  9:36               ` Markus Armbruster
2014-11-04 10:32                 ` Kevin Wolf
2014-11-05  7:58                   ` Markus Armbruster
2014-11-03 11:00           ` Kevin Wolf
2014-11-04  9:39             ` Markus Armbruster
2014-11-04 16:09               ` Jeff Cody
2014-11-05  8:05                 ` Markus Armbruster
2014-11-05  8:09                   ` Max Reitz
2014-10-30  9:08   ` Max Reitz [this message]
2014-10-30  9:27     ` Stefan Hajnoczi
2014-10-30  9:36       ` Kevin Wolf
2014-10-31 11:24         ` Stefan Hajnoczi
2014-10-31 11:56           ` Kevin Wolf
2014-11-03  8:54             ` Markus Armbruster
2014-11-03  9:11               ` Max Reitz
2014-11-04  9:34                 ` Markus Armbruster
2014-11-03 10:25               ` Kevin Wolf
2014-11-03 15:05                 ` Stefan Hajnoczi
2014-11-03 15:13                   ` Max Reitz
2014-11-04  9:42                   ` Markus Armbruster
2014-11-04 10:11                   ` Kevin Wolf
2014-11-04 15:25                     ` Stefan Hajnoczi
2014-11-04 15:37                       ` Kevin Wolf
2014-11-05  8:39                         ` Markus Armbruster
2014-11-05 10:18                           ` Eric Blake
2014-10-30 13:02     ` Markus Armbruster
2014-11-03  8:44       ` Max Reitz
2014-10-30 20:45   ` Richard W.M. Jones
2014-11-03  8:18     ` 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=5452001E.9070907@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).