fsck: warn about symlink pointing inside a gitdir

In the wake of fixing a vulnerability where `git clone` mistakenly
followed a symbolic link that it had just written while checking out
files, writing into a gitdir, let's add some defense-in-depth by
teaching `git fsck` to report symbolic links stored in its trees that
point inside `.git/`.

Even though the Git project never made any promises about the exact
shape of the `.git/` directory's contents, there are likely repositories
out there containing symbolic links that point inside the gitdir. For
that reason, let's only report these as warnings, not as errors.
Security-conscious users are encouraged to configure
`fsck.symlinkPointsToGitDir = error`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2024-04-10 18:01:13 +02:00
parent 20f3588efc
commit a33fea0886
4 changed files with 117 additions and 0 deletions

View File

@ -157,6 +157,18 @@
`nullSha1`::
(WARN) Tree contains entries pointing to a null sha1.
`symlinkPointsToGitDir`::
(WARN) Symbolic link points inside a gitdir.
`symlinkTargetBlob`::
(ERROR) A non-blob found instead of a symbolic link's target.
`symlinkTargetLength`::
(WARN) Symbolic link target longer than maximum path length.
`symlinkTargetMissing`::
(ERROR) Unable to read symbolic link target's blob.
`treeNotSorted`::
(ERROR) A tree is not properly sorted.