From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "W. Michael Petullo" <mike@flyn.org>, Jeff King <peff@peff.net>,
git@vger.kernel.org
Subject: Re: Git clone reads safe.directory differently?
Date: Tue, 30 Jul 2024 23:05:24 +0000 [thread overview]
Message-ID: <ZqlxtGIyz0G9jlJr@tapette.crustytoothpaste.net> (raw)
In-Reply-To: <xmqqv80m8pha.fsf@gitster.g>
[-- Attachment #1: Type: text/plain, Size: 3145 bytes --]
On 2024-07-30 at 22:49:37, Junio C Hamano wrote:
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
>
> > I think if we're using --no-local (that is, if we're using upload-pack
> > instead of creating symlinks), then we should not complain about the
> > repository ownership. It's supposed to always be safe to clone or fetch
> > from an untrusted repository, and we shouldn't complain about that.
>
> The safety is promised by "git fetch" when you fetch from some other
> machine because the only thing you will be seeing from that
> untrusted source is a bytestream that is the packfile, plus the tips
> of their histories---nothing runs as yourself in this exchange other
> than what you control, i.e. "git fetch", locally defined hooks and
> filters defined by your configuration.. They cannot affect your
> configuration file and hooks that may name extra programs that may
> run as you while fetching or cloning.
>
> When you are using "--no-local" on the same machine, I do not think
> there is any guarantee that "upload-pack" side is safe. And that is
> where the safe.directory thing needs to kick in.
>
> Stepping into an untrusted repository and running git operations
> opens up the user the Git process runs as to attacks by the
> untrusted repository, i.e. you may invoke hooks on the upload-pack
> side, defined in the source repository that is controlled by others,
> and that is where the safe.directory thing kicks in. You need to
> declare that you trust that source repository.
I don't believe git-upload-pack invokes hooks. At least, I don't see
any documented to do so, and I'm not aware of any from my experience
hosting repositories. Certainly git-receive-pack does so, which I can
understand as a problem, but upload-pack should not.
And the manual page does say this:
Most Git commands should not be run in an untrusted `.git` directory
(see the section `SECURITY` in git(1)). `upload-pack` tries to
avoid any dangerous configuration options or hooks from the repository
it's serving, making it safe to clone an untrusted directory and run
commands on the resulting clone.
The git(1) manual page also says this:
If you have an untrusted `.git` directory, you should first clone it
with `git clone --no-local` to obtain a clean copy. Git does restrict
the set of options and hooks that will be run by `upload-pack`, which
handles the server side of a clone or fetch, but beware that the
surface area for attack against `upload-pack` is large, so this does
carry some risk. The safest thing is to serve the repository as an
unprivileged user (either via git-daemon(1), ssh, or using
other tools to change user ids). See the discussion in the `SECURITY`
section of git-upload-pack(1).
I think that has been traditionally the policy that we've had here, and
given that we document that it is safe to do so, I think it should be
fine. This documentation apparently came from Peff, who I think should
be reasonably well informed on such matters.
--
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
next prev parent reply other threads:[~2024-07-30 23:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-27 16:14 Git clone reads safe.directory differently? W. Michael Petullo
2024-07-27 21:58 ` Jeff King
2024-07-28 15:27 ` W. Michael Petullo
2024-07-28 22:48 ` Jeff King
2024-07-30 11:37 ` W. Michael Petullo
2024-07-30 22:28 ` brian m. carlson
2024-07-30 22:49 ` Junio C Hamano
2024-07-30 22:55 ` Junio C Hamano
2024-07-30 23:05 ` brian m. carlson [this message]
2024-07-31 7:28 ` Jeff King
2024-07-31 16:23 ` Junio C Hamano
2024-07-31 22:08 ` Junio C Hamano
2024-08-01 6:14 ` Jeff King
2024-08-01 14:59 ` Junio C Hamano
2024-08-01 21:26 ` brian m. carlson
2024-08-01 21:52 ` Junio C Hamano
2024-08-05 9:47 ` Jeff King
2024-08-05 15:34 ` W. Michael Petullo
2024-08-05 15:49 ` Junio C Hamano
2024-08-01 6:08 ` Jeff King
2024-07-31 7:19 ` Jeff King
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=ZqlxtGIyz0G9jlJr@tapette.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mike@flyn.org \
--cc=peff@peff.net \
/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).