]> git.ipfire.org Git - thirdparty/git.git/commit
Allow cloning from repositories owned by another user
authorbrian m. carlson <sandals@crustytoothpaste.net>
Fri, 15 Nov 2024 00:54:04 +0000 (00:54 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 15 Nov 2024 02:05:06 +0000 (11:05 +0900)
commit0ffb5a6bf1b0fd9ce0c0b1fd9ce9fd30b89a2563
treeaff1cd1de7fbda43cb6303a3ce776928593b8397
parent46698a8ea13f244aac74366d2ee66a88e92e001a
Allow cloning from repositories owned by another user

Historically, Git has allowed users to clone from an untrusted
repository, and we have documented that this is safe to do so:

    `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.

However, this was broken by f4aa8c8bb1 ("fetch/clone: detect dubious
ownership of local repositories", 2024-04-10) in an attempt to make
things more secure.  That change resulted in a variety of problems when
cloning locally and over SSH, but it did not change the stated security
boundary.  Because the security boundary has not changed, it is safe to
adjust part of the code that patch introduced.

To do that and restore the previous functionality, adjust enter_repo to
take two flags instead of one.

The two bits are

 - ENTER_REPO_STRICT: callers that require exact paths (as opposed
   to allowing known suffixes like ".git", ".git/.git" to be
   omitted) can set this bit.  Corresponds to the "strict" parameter
   that the flags word replaces.

 - ENTER_REPO_ANY_OWNER_OK: callers that are willing to run without
   ownership check can set this bit.

The former is --strict-paths option of "git daemon".  The latter is
set only by upload-pack, which honors the claimed security boundary.

Note that local clones across ownership boundaries require --no-local so
that upload-pack is used.  Document this fact in the manual page and
provide an example.

This patch was based on one written by Junio C Hamano.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-clone.txt
builtin/upload-pack.c
daemon.c
path.c
path.h
t/t0411-clone-from-partial.sh
t/t5605-clone-local.sh