linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: Graham Cobb <g.btrfs@cobb.uk.net>, linux-btrfs@vger.kernel.org
Subject: Re: Security implications of btrfs receive?
Date: Wed, 7 Sep 2016 11:20:19 -0400	[thread overview]
Message-ID: <f954e01c-3ccf-5b44-3fde-e627537f2af2@gmail.com> (raw)
In-Reply-To: <4a00b682-c674-a46f-798e-d98b3e517f02@gmail.com>

On 2016-09-07 07:58, Austin S. Hemmelgarn wrote:
> On 2016-09-06 13:20, Graham Cobb wrote:
>> Thanks to Austin and Duncan for their replies.
>>
>> On 06/09/16 13:15, Austin S. Hemmelgarn wrote:
>>> On 2016-09-05 05:59, Graham Cobb wrote:
>>>> Does the "path" argument of btrfs-receive mean that *all* operations
>>>> are
>>>> confined to that path?  For example, if a UUID or transid is sent which
>>>> refers to an entity outside the path will that other entity be affected
>>>> or used?
>>> As far as I know, no, it won't be affected.
>>>> Is it possible for a file to be created containing shared
>>>> extents from outside the path?
>>> As far as I know, the only way for this to happen is if you're
>>> referencing a parent subvolume for a relative send that is itself
>>> sharing extents outside of the path.  From a practical perspective,
>>> unless you're doing deduplication on the receiving end, the this
>>> shouldn't be possible.
>>
>> Unfortunately that is not the case.  I decided to do some tests to see
>> what happens.  It is possible for a receive into one path to reference
>> and access a subvolume from a different path on the same btrfs disk.  I
>> have created a bash script to demonstrate this at:
>>
>> https://gist.github.com/GrahamCobb/c7964138057e4e092a75319c9fb240a3
>>
>> This does require the attacker to know the (source) subvolume UUID they
>> want to copy.  I am not sure how hard UUIDs are to guess.
> Oh, I forgot about the fact that it checks the whole filesystem for
> referenced source subvolumes.
>>
>> By the way, this is exactly the same whether or not the --chroot option
>> is specified on the "btrfs receive" command.
> Which makes sense, chroot only affects the VFS layer, not the underlying
> FS.
>>
>> The next question this raises for me is whether this means that
>> processes in a chroot or in a container (or in a mandatory access
>> controls environment) can access files outside the chroot/container if
>> they know the UUID of the subvolume?  After all, btrfs-receive uses
>> IOCTLs that any program running as root can use.
> Yes, it does mean that, but if you want proper security you should be
> using a real container system (or better yet, a virtual machine), not
> just a chroot.  Chroot by itself is not a security mechanism, it's a
> safety belt and testing tool.  If you actually want to secure something,
> chroot should only be part of it, together with isolating it to it's own
> filesystem, and using cgroups and namespaces.
I should probably add to this that you shouldn't be accepting 
send/receive data streams from untrusted sources anyway.  While it 
probably won't crash your system, it's not intended for use as something 
like a network service.  If you're sending a subvolume over an untrusted 
network, you should be tunneling it through SSH or something similar, 
and then using that to provide source verification and data integrity 
guarantees, and if you can't trust the system's your running backups 
for, then you have bigger issues to deal with.

  parent reply	other threads:[~2016-09-07 15:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05  9:59 Security implications of btrfs receive? Graham Cobb
2016-09-05 14:33 ` Duncan
2016-09-06 12:15 ` Austin S. Hemmelgarn
2016-09-06 17:20   ` Graham Cobb
2016-09-07 11:58     ` Austin S. Hemmelgarn
2016-09-07 14:44       ` Christoph Anton Mitterer
2016-09-07 14:55         ` Austin S. Hemmelgarn
2016-09-07 15:20       ` Austin S. Hemmelgarn [this message]
2016-09-07 16:10         ` Graham Cobb
2016-09-07 17:33           ` Austin S. Hemmelgarn
2016-09-09 16:18       ` David Sterba
2016-09-09 16:58         ` Austin S. Hemmelgarn
2016-09-07 14:41     ` Christoph Anton Mitterer
2016-09-07 15:06       ` Austin S. Hemmelgarn
2016-09-07 16:27         ` Graham Cobb
2016-09-07 18:07         ` Christoph Anton Mitterer
2016-09-07 19:08           ` Austin S. Hemmelgarn
2016-09-07 19:34             ` Chris Murphy
2016-09-08 11:48               ` Austin S. Hemmelgarn
2016-09-09 18:58                 ` Chris Murphy
2016-09-10 19:27                   ` Chris Murphy
2016-09-12 11:24                   ` Austin S. Hemmelgarn
2016-09-12 20:25                     ` Chris Murphy
2016-09-13 11:46                       ` Austin S. Hemmelgarn
2016-09-09 16:33             ` David Sterba
2016-09-09 17:21               ` Austin S. Hemmelgarn
2016-09-07 20:29           ` Zygo Blaxell

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=f954e01c-3ccf-5b44-3fde-e627537f2af2@gmail.com \
    --to=ahferroin7@gmail.com \
    --cc=g.btrfs@cobb.uk.net \
    --cc=linux-btrfs@vger.kernel.org \
    /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).