<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/setup.c, branch v2.40.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.40.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.40.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-04-19T10:38:24Z</updated>
<entry>
<title>init.templateDir: consider this config setting protected</title>
<updated>2024-04-19T10:38:24Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2024-03-29T12:15:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4412a04fe6f7e632269a6668a4f367230ca2c0e0'/>
<id>urn:sha1:4412a04fe6f7e632269a6668a4f367230ca2c0e0</id>
<content type='text'>
The ability to configuring the template directory is a delicate feature:
It allows defining hooks that will be run e.g. during a `git clone`
operation, such as the `post-checkout` hook.

As such, it is of utmost importance that Git would not allow that config
setting to be changed during a `git clone` by mistake, allowing an
attacker a chance for a Remote Code Execution, allowing attackers to run
arbitrary code on unsuspecting users' machines.

As a defense-in-depth measure, to prevent minor vulnerabilities in the
`git clone` code from ballooning into higher-serverity attack vectors,
let's make this a protected setting just like `safe.directory` and
friends, i.e. ignore any `init.templateDir` entries from any local
config.

Note: This does not change the behavior of any recursive clone (modulo
bugs), as the local repository config is not even supposed to be written
while cloning the superproject, except in one scenario: If a config
template is configured that sets the template directory. This might be
done because `git clone --recurse-submodules --template=&lt;directory&gt;`
does not pass that template directory on to the submodules'
initialization.

Another scenario where this commit changes behavior is where
repositories are _not_ cloned recursively, and then some (intentional,
benign) automation configures the template directory to be used before
initializing the submodules.

So the caveat is that this could theoretically break existing processes.

In both scenarios, there is a way out, though: configuring the template
directory via the environment variable `GIT_TEMPLATE_DIR`.

This change in behavior is a trade-off between security and
backwards-compatibility that is struck in favor of security.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
</content>
</entry>
<entry>
<title>init: refactor the template directory discovery into its own function</title>
<updated>2024-04-17T20:30:10Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2024-03-29T10:45:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=df93e407f0618e4a8265ac619dc7f4c7005155bc'/>
<id>urn:sha1:df93e407f0618e4a8265ac619dc7f4c7005155bc</id>
<content type='text'>
We will need to call this function from `hook.c` to be able to prevent
hooks from running that were written as part of a `clone` but did not
originate from the template directory.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
</content>
</entry>
<entry>
<title>fetch/clone: detect dubious ownership of local repositories</title>
<updated>2024-04-17T20:29:54Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2024-04-10T12:39:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f4aa8c8bb11dae6e769cd930565173808cbb69c8'/>
<id>urn:sha1:f4aa8c8bb11dae6e769cd930565173808cbb69c8</id>
<content type='text'>
When cloning from somebody else's repositories, it is possible that,
say, the `upload-pack` command is overridden in the repository that is
about to be cloned, which would then be run in the user's context who
started the clone.

To remind the user that this is a potentially unsafe operation, let's
extend the ownership checks we have already established for regular
gitdir discovery to extend also to local repositories that are about to
be cloned.

This protection extends also to file:// URLs.

The fixes in this commit address CVE-2024-32004.

Note: This commit does not touch the `fetch`/`clone` code directly, but
instead the function used implicitly by both: `enter_repo()`. This
function is also used by `git receive-pack` (i.e. pushes), by `git
upload-archive`, by `git daemon` and by `git http-backend`. In setups
that want to serve repositories owned by different users than the
account running the service, this will require `safe.*` settings to be
configured accordingly.

Also note: there are tiny time windows where a time-of-check-time-of-use
("TOCTOU") race is possible. The real solution to those would be to work
with `fstat()` and `openat()`. However, the latter function is not
available on Windows (and would have to be emulated with rather
expensive low-level `NtCreateFile()` calls), and the changes would be
quite extensive, for my taste too extensive for the little gain given
that embargoed releases need to pay extra attention to avoid introducing
inadvertent bugs.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
</content>
</entry>
<entry>
<title>Merge branch 'js/safe-directory-plus'</title>
<updated>2022-08-15T06:19:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-08-15T06:19:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7fac7b563b0d4f174b30bfbedab67e59af8cce84'/>
<id>urn:sha1:7fac7b563b0d4f174b30bfbedab67e59af8cce84</id>
<content type='text'>
Platform-specific code that determines if a directory is OK to use
as a repository has been taught to report more details, especially
on Windows.

* js/safe-directory-plus:
  mingw: handle a file owned by the Administrators group correctly
  mingw: be more informative when ownership check fails on FAT32
  mingw: provide details about unsafe directories' ownership
  setup: prepare for more detailed "dubious ownership" messages
  setup: fix some formatting
</content>
</entry>
<entry>
<title>setup: prepare for more detailed "dubious ownership" messages</title>
<updated>2022-08-08T16:25:40Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2022-08-08T13:27:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=17d3883fe9c88b823002ad9fafb42313ddc3d3d5'/>
<id>urn:sha1:17d3883fe9c88b823002ad9fafb42313ddc3d3d5</id>
<content type='text'>
When verifying the ownership of the Git directory, we sometimes would
like to say a bit more about it, e.g. when using a platform-dependent
code path (think: Windows has the permission model that is so different
from Unix'), but only when it is a appropriate to actually say
something.

To allow for that, collect that information and hand it back to the
caller (whose responsibility it is to show it or not).

Note: We do not actually fill in any platform-dependent information yet,
this commit just adds the infrastructure to be able to do so.

Based-on-an-idea-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>setup: fix some formatting</title>
<updated>2022-08-08T16:24:00Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2022-08-08T13:27:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d51e1dff980b9fc87002436b6ab36120a39816b1'/>
<id>urn:sha1:d51e1dff980b9fc87002436b6ab36120a39816b1</id>
<content type='text'>
In preparation for touching code that was introduced in 3b0bf2704980
(setup: tighten ownership checks post CVE-2022-24765, 2022-05-10) and
that was formatted differently than preferred in the Git project, fix
the indentation before actually modifying the code.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>setup.c: create `safe.bareRepository`</title>
<updated>2022-07-14T22:08:29Z</updated>
<author>
<name>Glen Choo</name>
<email>chooglen@google.com</email>
</author>
<published>2022-07-14T21:28:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8d1a7448206e11cdea657c35b04cc49db39be933'/>
<id>urn:sha1:8d1a7448206e11cdea657c35b04cc49db39be933</id>
<content type='text'>
There is a known social engineering attack that takes advantage of the
fact that a working tree can include an entire bare repository,
including a config file. A user could run a Git command inside the bare
repository thinking that the config file of the 'outer' repository would
be used, but in reality, the bare repository's config file (which is
attacker-controlled) is used, which may result in arbitrary code
execution. See [1] for a fuller description and deeper discussion.

A simple mitigation is to forbid bare repositories unless specified via
`--git-dir` or `GIT_DIR`. In environments that don't use bare
repositories, this would be minimally disruptive.

Create a config variable, `safe.bareRepository`, that tells Git whether
or not to die() when working with a bare repository. This config is an
enum of:

- "all": allow all bare repositories (this is the default)
- "explicit": only allow bare repositories specified via --git-dir
  or GIT_DIR.

If we want to protect users from such attacks by default, neither value
will suffice - "all" provides no protection, but "explicit" is
impractical for bare repository users. A more usable default would be to
allow only non-embedded bare repositories ([2] contains one such
proposal), but detecting if a repository is embedded is potentially
non-trivial, so this work is not implemented in this series.

[1]: https://lore.kernel.org/git/kl6lsfqpygsj.fsf@chooglen-macbookpro.roam.corp.google.com
[2]: https://lore.kernel.org/git/5b969c5e-e802-c447-ad25-6acc0b784582@github.com

Signed-off-by: Glen Choo &lt;chooglen@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>safe.directory: use git_protected_config()</title>
<updated>2022-07-14T22:08:29Z</updated>
<author>
<name>Glen Choo</name>
<email>chooglen@google.com</email>
</author>
<published>2022-07-14T21:28:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6061601d9f1f1c95da5f9304c319218f7cc3ec75'/>
<id>urn:sha1:6061601d9f1f1c95da5f9304c319218f7cc3ec75</id>
<content type='text'>
Use git_protected_config() to read `safe.directory` instead of
read_very_early_config(), making it 'protected configuration only'.

As a result, `safe.directory` now respects "-c", so update the tests and
docs accordingly. It used to ignore "-c" due to how it was implemented,
not because of security or correctness concerns [1].

[1] https://lore.kernel.org/git/xmqqlevabcsu.fsf@gitster.g/

Signed-off-by: Glen Choo &lt;chooglen@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Sync with Git 2.37.1</title>
<updated>2022-07-11T23:08:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-07-11T23:08:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f2e5255fc2d3a043f37e259012e1ccd013d6e4b8'/>
<id>urn:sha1:f2e5255fc2d3a043f37e259012e1ccd013d6e4b8</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Merge branch 'cr/setup-bug-typo'</title>
<updated>2022-07-11T22:38:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-07-11T22:38:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6d65013bb7259fff9e6dc1044786253759c841a4'/>
<id>urn:sha1:6d65013bb7259fff9e6dc1044786253759c841a4</id>
<content type='text'>
Typofix in a BUG() message.

* cr/setup-bug-typo:
  setup: fix function name in a BUG() message
</content>
</entry>
</feed>
