mirror of
https://git.yoctoproject.org/poky
synced 2026-03-10 01:09:40 +01:00
CVE-2024-32002: Git is a revision control system. Prior to versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4, repositories with submodules can be crafted in a way that exploits a bug in Git whereby it can be fooled into writing files not into the submodule's worktree but into a `.git/` directory. This allows writing a hook that will be executed while the clone operation is still running, giving the user no opportunity to inspect the code that is being executed. The problem has been patched in versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4. If symbolic link support is disabled in Git (e.g. via `git config --global core.symlinks false`), the described attack won't work. As always, it is best to avoid cloning repositories from untrusted sources. CVE-2024-32004: Git is a revision control system. Prior to versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4, an attacker can prepare a local repository in such a way that, when cloned, will execute arbitrary code during the operation. The problem has been patched in versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4. As a workaround, avoid cloning repositories from untrusted sources. CVE-2024-32020: Git is a revision control system. Prior to versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4, local clones may end up hardlinking files into the target repository's object database when source and target repository reside on the same disk. If the source repository is owned by a different user, then those hardlinked files may be rewritten at any point in time by the untrusted user. Cloning local repositories will cause Git to either copy or hardlink files of the source repository into the target repository. This significantly speeds up such local clones compared to doing a "proper" clone and saves both disk space and compute time. When cloning a repository located on the same disk that is owned by a different user than the current user we also end up creating such hardlinks. These files will continue to be owned and controlled by the potentially-untrusted user and can be rewritten by them at will in the future. The problem has been patched in versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4. CVE-2024-32021: Git is a revision control system. Prior to versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4, when cloning a local source repository that contains symlinks via the filesystem, Git may create hardlinks to arbitrary user-readable files on the same filesystem as the target repository in the `objects/` directory. Cloning a local repository over the filesystem may creating hardlinks to arbitrary user-owned files on the same filesystem in the target Git repository's `objects/` directory. When cloning a repository over the filesystem (without explicitly specifying the `file://` protocol or `--no-local`), the optimizations for local cloning will be used, which include attempting to hard link the object files instead of copying them. While the code includes checks against symbolic links in the source repository, which were added during the fix for CVE-2022-39253, these checks can still be raced because the hard link operation ultimately follows symlinks. If the object on the filesystem appears as a file during the check, and then a symlink during the operation, this will allow the adversary to bypass the check and create hardlinks in the destination objects directory to arbitrary, user-readable files. The problem has been patched in versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4. CVE-2024-32465: Git is a revision control system. The Git project recommends to avoid working in untrusted repositories, and instead to clone it first with `git clone --no-local` to obtain a clean copy. Git has specific protections to make that a safe operation even with an untrusted source repository, but vulnerabilities allow those protections to be bypassed. In the context of cloning local repositories owned by other users, this vulnerability has been covered in CVE-2024-32004. But there are circumstances where the fixes for CVE-2024-32004 are not enough: For example, when obtaining a `.zip` file containing a full copy of a Git repository, it should not be trusted by default to be safe, as e.g. hooks could be configured to run within the context of that repository. The problem has been patched in versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4. As a workaround, avoid using Git in repositories that have been obtained via archives from untrusted sources. References: https://nvd.nist.gov/vuln/detail/CVE-2024-32002 https://nvd.nist.gov/vuln/detail/CVE-2024-32004 https://nvd.nist.gov/vuln/detail/CVE-2024-32020 https://nvd.nist.gov/vuln/detail/CVE-2024-32021 https://nvd.nist.gov/vuln/detail/CVE-2024-32465 (From OE-Core rev: 209c41377abf6853455b00af3923f1b244a3766b) Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
96 lines
3.2 KiB
Diff
96 lines
3.2 KiB
Diff
From 5c5a4a1c05932378d259b1fdd9526cab971656a2 Mon Sep 17 00:00:00 2001
|
|
From: Filip Hejsek <filip.hejsek@gmail.com>
|
|
Date: Sun, 28 Jan 2024 04:29:33 +0100
|
|
Subject: [PATCH] t0411: add tests for cloning from partial repo
|
|
|
|
Cloning from a partial repository must not fetch missing objects into
|
|
the partial repository, because that can lead to arbitrary code
|
|
execution.
|
|
|
|
Add a couple of test cases, pretending to the `upload-pack` command (and
|
|
to that command only) that it is working on a repository owned by
|
|
someone else.
|
|
|
|
Helped-by: Jeff King <peff@peff.net>
|
|
Signed-off-by: Filip Hejsek <filip.hejsek@gmail.com>
|
|
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
|
|
CVE: CVE-2024-32004
|
|
|
|
Upstream-Status: Backport [https://github.com/git/git/commit/5c5a4a1c05932378d259b1fdd9526cab971656a2]
|
|
|
|
Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
|
|
---
|
|
t/t0411-clone-from-partial.sh | 60 +++++++++++++++++++++++++++++++++++
|
|
1 file changed, 60 insertions(+)
|
|
create mode 100755 t/t0411-clone-from-partial.sh
|
|
|
|
diff --git a/t/t0411-clone-from-partial.sh b/t/t0411-clone-from-partial.sh
|
|
new file mode 100755
|
|
index 0000000..fb72a0a
|
|
--- /dev/null
|
|
+++ b/t/t0411-clone-from-partial.sh
|
|
@@ -0,0 +1,60 @@
|
|
+#!/bin/sh
|
|
+
|
|
+test_description='check that local clone does not fetch from promisor remotes'
|
|
+
|
|
+. ./test-lib.sh
|
|
+
|
|
+test_expect_success 'create evil repo' '
|
|
+ git init tmp &&
|
|
+ test_commit -C tmp a &&
|
|
+ git -C tmp config uploadpack.allowfilter 1 &&
|
|
+ git clone --filter=blob:none --no-local --no-checkout tmp evil &&
|
|
+ rm -rf tmp &&
|
|
+
|
|
+ git -C evil config remote.origin.uploadpack \"\$TRASH_DIRECTORY/fake-upload-pack\" &&
|
|
+ write_script fake-upload-pack <<-\EOF &&
|
|
+ echo >&2 "fake-upload-pack running"
|
|
+ >"$TRASH_DIRECTORY/script-executed"
|
|
+ exit 1
|
|
+ EOF
|
|
+ export TRASH_DIRECTORY &&
|
|
+
|
|
+ # empty shallow file disables local clone optimization
|
|
+ >evil/.git/shallow
|
|
+'
|
|
+
|
|
+test_expect_failure 'local clone must not fetch from promisor remote and execute script' '
|
|
+ rm -f script-executed &&
|
|
+ test_must_fail git clone \
|
|
+ --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
|
|
+ evil clone1 2>err &&
|
|
+ ! grep "fake-upload-pack running" err &&
|
|
+ test_path_is_missing script-executed
|
|
+'
|
|
+
|
|
+test_expect_failure 'clone from file://... must not fetch from promisor remote and execute script' '
|
|
+ rm -f script-executed &&
|
|
+ test_must_fail git clone \
|
|
+ --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
|
|
+ "file://$(pwd)/evil" clone2 2>err &&
|
|
+ ! grep "fake-upload-pack running" err &&
|
|
+ test_path_is_missing script-executed
|
|
+'
|
|
+
|
|
+test_expect_failure 'fetch from file://... must not fetch from promisor remote and execute script' '
|
|
+ rm -f script-executed &&
|
|
+ test_must_fail git fetch \
|
|
+ --upload-pack="GIT_TEST_ASSUME_DIFFERENT_OWNER=true git-upload-pack" \
|
|
+ "file://$(pwd)/evil" 2>err &&
|
|
+ ! grep "fake-upload-pack running" err &&
|
|
+ test_path_is_missing script-executed
|
|
+'
|
|
+
|
|
+test_expect_success 'pack-objects should fetch from promisor remote and execute script' '
|
|
+ rm -f script-executed &&
|
|
+ echo "HEAD" | test_must_fail git -C evil pack-objects --revs --stdout >/dev/null 2>err &&
|
|
+ grep "fake-upload-pack running" err &&
|
|
+ test_path_is_file script-executed
|
|
+'
|
|
+
|
|
+test_done
|
|
--
|
|
2.40.0
|