Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: Kristian Amlie <kristian.amlie@mender.io>
Cc: Patches and discussions about the oe-core layer
	<openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH v1] wic: Add --exclude-path option to rootfs source plugin.
Date: Mon, 28 Nov 2016 12:46:24 +0200	[thread overview]
Message-ID: <20161128104624.GA15660@linux.intel.com> (raw)
In-Reply-To: <c74d1583-9f57-65d7-1631-36b29fb17165@mender.io>

On Mon, Nov 28, 2016 at 08:07:05AM +0100, Kristian Amlie wrote:
> On 25/11/16 17:33, Ed Bartosh wrote:
> > On Fri, Nov 25, 2016 at 01:35:53PM +0100, Kristian Amlie wrote:
> >> On 25/11/16 13:28, Maciej Borzęcki wrote:
> >>> On Fri, Nov 25, 2016 at 11:15 AM, Kristian Amlie
> >>>> +                # Disallow '..', because doing so could be quite disastrous
> >>>> +                # (we will delete the directory).
> >>>> +                remaining = path
> >>>> +                while True:
> >>>> +                    (head, tail) = os.path.split(remaining)
> >>>> +                    if tail == '..':
> >>>> +                        msger.error("'..' not allowed: --exclude-path=%s" % orig_path)
> >>>> +                    elif head == "":
> >>>> +                        break
> >>>> +                    remaining = head
> >>>
> >>> Why not do this instead?
> >>>
> >>>     if '..' in path:
> >>>         msger.error("'..' not allowed: --exclude-path=%s" % orig_path)
> >>>
> > would "'/..' in path" or something similar work?
> 
> '/..my-file' is a valid file name, so no, it wouldn't work. I realize
> that this would be uncommon, and it makes the check more complex, so I'm
> ok with making it simpler if you want me to, but we have to trade
> simplicity for correctness in that case.
>
OK, makes sense.

Would something like this work for you?

> mkdir -p /tmp/rootfs/bla/bla/bla/bla
> python -c "import os;print os.path.realpath('/tmp/rootfs/bla/../bla/../bla/../bla/../').startswith('/tmp/rootfs/')"
False
> python -c "import os;print os.path.realpath('/tmp/rootfs/bla/../bla/../bla/bla/../').startswith('/tmp/rootfs/')"
True

--
Regards,
Ed


  reply	other threads:[~2016-11-28 10:46 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25 10:15 [PATCH v1] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2016-11-25 10:33 ` Patrick Ohly
2016-11-25 12:07   ` Kristian Amlie
2016-11-25 16:31     ` Ed Bartosh
2016-11-28  7:15       ` Kristian Amlie
2016-11-28 10:52         ` Ed Bartosh
2016-11-28 11:01           ` Kristian Amlie
2016-11-28 11:18             ` Ed Bartosh
2016-11-30 13:30               ` Kristian Amlie
2016-11-30 13:37                 ` Maciej Borzęcki
2016-11-30 15:29                 ` Ed Bartosh
2016-11-30 19:29                   ` Paul Eggleton
2016-12-02 14:36                   ` Kristian Amlie
2016-12-02 15:05                     ` Ed Bartosh
2016-12-05 10:23                       ` Kristian Amlie
2016-12-14 16:28               ` [PATCH v2] " Kristian Amlie
2016-12-14 16:28                 ` [PATCH v2 1/3] " Kristian Amlie
2016-12-14 16:28                 ` [PATCH v2 2/3] Add e2tools recipe, in order to test contents of images Kristian Amlie
2016-12-14 16:28                 ` [PATCH v2 3/3] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2016-12-16 14:44                   ` Ed Bartosh
2016-12-19  9:09                     ` Kristian Amlie
2016-12-19  9:09                       ` [PATCH v3 1/3] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2016-12-19  9:09                       ` [PATCH v3 2/3] Add e2tools recipe, in order to test contents of images Kristian Amlie
2016-12-19  9:09                       ` [PATCH v3 3/3] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2016-12-19 20:49                         ` Burton, Ross
2016-12-20  9:20                           ` Kristian Amlie
2016-12-29 10:05                           ` Kristian Amlie
2016-12-29 10:05                             ` [PATCH v4 1/2] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2016-12-29 10:05                             ` [PATCH v4 2/2] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2016-12-29 10:23                               ` Kristian Amlie
2016-12-29 14:03                                 ` Kristian Amlie
2016-12-29 14:03                                   ` [PATCH v5 1/2] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2016-12-29 14:03                                   ` [PATCH v5 2/2] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2017-01-16  9:05                                   ` [PATCH v4 " Kristian Amlie
2017-02-06 16:16                                     ` Kristian Amlie
2017-02-06 16:16                                       ` [PATCH 1/2] wic: Add --exclude-path option to rootfs source plugin Kristian Amlie
2017-02-06 16:16                                       ` [PATCH 2/2] selftest/wic: Add tests for --exclude-dir option Kristian Amlie
2017-02-06 16:38                                       ` [PATCH v4 " Ed Bartosh
2016-12-19 11:57                       ` [PATCH v2 3/3] " Ed Bartosh
2016-11-25 12:28 ` [PATCH v1] wic: Add --exclude-path option to rootfs source plugin Maciej Borzęcki
2016-11-25 12:35   ` Kristian Amlie
2016-11-25 16:33     ` Ed Bartosh
2016-11-28  7:07       ` Kristian Amlie
2016-11-28 10:46         ` Ed Bartosh [this message]
2016-11-28 11:00           ` Kristian Amlie
2017-02-06 16:29 ` ✗ patchtest: failure for wic: Add --exclude-path option to rootfs source plugin. (rev10) Patchwork
2017-02-06 16:29 ` ✗ patchtest: failure for wic: Add --exclude-path option to rootfs source plugin. (rev11) Patchwork
2017-02-07  7:23   ` Kristian Amlie

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=20161128104624.GA15660@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=kristian.amlie@mender.io \
    --cc=openembedded-core@lists.openembedded.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