git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Brockman <gdb@MIT.EDU>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Anders Kaseorg" <andersk@mit.edu>,
	"Johannes Sixt" <j.sixt@viscovery.net>,
	"Ævar Arnfjörð" <avarab@gmail.com>,
	gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCHv3] Updated patch series for providing mechanism to list  available repositories
Date: Wed, 28 Jul 2010 17:21:29 -0700	[thread overview]
Message-ID: <AANLkTikaBoMOEGvLU8FL4Cvw4zBecXytvAnAYTS9GBa3@mail.gmail.com> (raw)
In-Reply-To: <20100728235249.GA29156@dert.cs.uchicago.edu>

Anders brings up a good point.

And note that as I alluded to before, there is another attack

$ echo 'DEFINE pager evilscript' > /tmp/.manpath
$ HOME=/tmp su git -m -c "git-receive-pack '--help'" (3)

which only requires being able to control HOME.

(Incidentally, I just noticed a segfault with

$ unset HOME
$ su git -m -c "git-receive-pack '~'"

that's probably worth fixing... if people don't think this is too
pedantic of a case to fix, I'll submit a patch for it in a later
series [I think the segfault comes from path.c:expand_user_path].)

Anyway, i'll revise my first patch to use HOME rather than getpw*.

Greg



On Wed, Jul 28, 2010 at 4:52 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Anders Kaseorg wrote:
>> On Wed, 2010-07-28 at 01:42 -0500, Jonathan Nieder wrote:
>
>>> (if you use getpwent instead of getenv to fetch $HOME).
>>
>> That seems like it could lead to problems with multiple users with the
>> same UID, and possibly also on Windows.  If it’s important to be
>> paranoid here, what about all the other places Git already uses
>> getenv("HOME"), including where it reads ~/.gitconfig?
>
> Thanks for a sanity check.  I do not see the multiple-user problem
> (git-shell is meant to be the login shell, no?) but I think you are
> right about using getwpwent instead of $HOME being a pointless
> precaution.  My confusion came from a misreading of how 'su' works.
>
> Here was my worry: that a user could do something like this:
>
>  $ mkdir /tmp/git-shell-commands
>  $ ln -s /bin/sh /tmp/git-shell-commands/sh
>  $ HOME=/tmp su git -m -c sh;           # (1)
>
> and get a shell with the privileges of the user with git-shell
> as login shell, which is exactly what a restricted shell like
> this should be preventing.
>
> Now if that is possible, what is to stop me from this?
>
>  $ PAGER=evilscript su git -m -c git-receive-pack --help; # (2)
>
> which became possible (modulo the su bit) as an unintended
> consequence when receive-pack became builtin.
>
> If I understand the manual correctly, then at least on some
> systems, luckily su protects correctly against such problems.
>
>        -m
>                Preserve the current environment.
>
>                If the target user has a restricted shell,
>                this option has no effect (unless su is
>                called by root).
>
> Is that behavior portable?  It certainly seems like the
> only sane way to behave.  It’s a moot question for the
> inclusion of this patch series: if we need to worry about
> (1), then it is still not a regression because (2) was possible
> already.
>
> The same discussion would seem to apply to ssh with
> PermitUserEnvironment enabled.
>

  reply	other threads:[~2010-07-29  0:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-21 15:15 [PATCHv3] Updated patch series for providing mechanism to list available repositories Greg Brockman
2010-07-21 15:15 ` [PATCH 1/3] Allow creation of arbitrary git-shell commands Greg Brockman
2010-07-21 15:15 ` [PATCH 2/3] Add interactive mode to git-shell for user-friendliness Greg Brockman
2010-07-21 15:15 ` [PATCH 3/3] Add sample commands for git-shell Greg Brockman
2010-07-26 22:32 ` [PATCHv3] Updated patch series for providing mechanism to list available repositories Greg Brockman
2010-07-26 22:54   ` Ævar Arnfjörð Bjarmason
2010-07-26 23:18     ` Greg Brockman
2010-07-27  9:02       ` Jakub Narebski
2010-07-26 23:28     ` Jonathan Nieder
2010-07-27  0:20       ` Greg Brockman
2010-07-27  0:50         ` Jonathan Nieder
2010-07-27  7:16         ` Johannes Sixt
2010-07-27 17:41           ` Jonathan Nieder
2010-07-27 22:43             ` Greg Brockman
2010-07-28  0:33               ` Jonathan Nieder
2010-07-28  6:15                 ` Greg Brockman
2010-07-28  6:42                   ` Jonathan Nieder
2010-07-28  7:06                     ` Greg Brockman
2010-07-28 23:14                     ` Anders Kaseorg
2010-07-28 23:52                       ` Jonathan Nieder
2010-07-29  0:21                         ` Greg Brockman [this message]
2010-07-29  0:33                           ` Jonathan Nieder
2010-07-28  1:10               ` Jonathan Nieder

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=AANLkTikaBoMOEGvLU8FL4Cvw4zBecXytvAnAYTS9GBa3@mail.gmail.com \
    --to=gdb@mit.edu \
    --cc=andersk@mit.edu \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=jrnieder@gmail.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).