qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH RFC 2/2] block: Warn on insecure format probing
Date: Wed, 29 Oct 2014 09:25:08 +0100	[thread overview]
Message-ID: <5450A464.9070908@redhat.com> (raw)
In-Reply-To: <87ppdbiaxx.fsf@blackfin.pond.sub.org>

On 2014-10-29 at 08:36, Markus Armbruster wrote:
> Jeff Cody <jcody@redhat.com> writes:
>
>> On Tue, Oct 28, 2014 at 12:56:37PM -0600, Eric Blake wrote:
>>> On 10/28/2014 12:29 PM, Jeff Cody wrote:
>>>
>>>>>> 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.
>>>>> Yes.  For precedent, libvirt can be considered a tool on images for
>>>>> certain operations, and libvirt has been warning about probing since 2010.
>>>>>
>>>> I think at least the invocation 'qemu-img info' should be exempt from
>>>> the warning; doing a format probe is arguably part of its intended
>>>> usage.
>>>>
>>>>> Also, while I agree that any tool that operates on ONLY one layer of an
>>>>> image, without ever trying to chase backing chains, can't be tricked
>>>>> into opening wrong files, I'm not sure I agree with the claim that
>>>>> "probing isn't insecure" -
>>>>>
>>>> Maybe we should draw the distinction at tools that write data?
>>>> Without a guest running, a tool that simply reads files should be safe
>>>> to probe.
>>> Misprobing a top-level raw file as qcow2 can result in opening and
>>> reading a backing file, even when the top-level file was opened with
>>> read-only intent.  If the guest can stick some sort of /proc filesystem
>>> name as a qcow2 backing file for interpretation for a bogus probe of a
>>> raw file, you can result in hanging the process in trying to read the
>>> backing file.  Even if you aren't leaking data about what was read, this
>>> could still possibly constitute a denial of service attack.
>>>
>> True, but the warning doesn't prevent the probe.  My thinking is that
>> if I am running 'qemu-img info' without specifying a format, I
>> explicitly want the probe (how else to determine the format of a .img
>> file, or other generic file/device?)
>>
>> But I am not hung up on this; a warning won't negate the usefulness of
>> 'qemu-img info', so if others feel it is useful in that usage case, it
>> is OK with me.
> As far as I can tell, "qemu-img info" doesn't probe the backing file.
>
> I'd prefer not to warn there.

Except for when you're using --backing-chain.

I don't really see the point in warning because qemu-img acts with the 
privileges of the invoking user and only passes data to that user, so 
there should not be any security issues here. However, we may want to 
warn anyway just so the user knows that he/she should rename the image file.

So for me it comes down to what is easier, and I think just always 
emitting the warning is easier.

Max

>>> I was about to propose these two rules as something I'd still feel more
>>> comfortable with:
>>>
>>> if it is the top-level file, then warn for read-write access doing a
>>> probe where the probe differed from filename heuristics, be silent for
>>> read-only access doing a probe (whether or not the file claims to have a
>>> backing image)
>>>
>>> if it is chasing the backing chain (necessarily read-only access of the
>>> backing), then warn if the backing format was not specified and the
>>> probe differs from filename heuristics
> Have you considered the "warn of future change" role?
>
>> It'd also be nice if there was something that indicated the tree depth
>> the warning was from - it may be confusing for the user if they run a
>> qemu command on 'image.qcow2', and get a warning because a backing
>> file image in the chain just had a generic '.img' extension.
> This is how it looks now:
>
>      qemu: -drive file=flawed.img,if=none: warning: insecure format probing of image 'flawed.img'
>      To get rid of this warning, specify format=qcow2 explicitly, or change
>      the image name to end with '.qcow2'
>      qemu: -drive file=flawed.img,if=none: warning: insecure format probing of image 'backing.img'
>      To get rid of this warning, specify format=qcow2 explicitly, or change
>      the image name to end with '.qcow2'
>
> Would be less clear with a differently named backing file.  Could you
> sketch what you'd like to see?
>
>>> But that still has the drawback that if the backing file is some /proc
>>> name that will cause the process to hang, you don't want to print the
>>> message until after you read the file to discover that the probe
>>> differed from heuristics, but it is doing the open/read that determines
>>> the hang.  So I don't see an elegant way to break the chicken-and-egg
>>> problem.
> Probing needs to die.  Leave it to file(1).
>
> [...]
>

  reply	other threads:[~2014-10-29  8:25 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 [this message]
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
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=5450A464.9070908@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).