From 7a4f5dcb7bf3cbcbf6e438017efcdfe0bc0d36ca Mon Sep 17 00:00:00 2001
From: "GPT 5.6" <codex@openai.com>
Date: Sun, 26 Jul 2026 06:00:59 +0200
Subject: [PATCH] Block unsafe archive additions and bundle URI

GHSA-539m-9xh6-q6rr reports incomplete unsafe option lists for archive inputs
and clone bundle URLs. Caller-controlled archive additions can expose or inject
filesystem content, while clone --bundle-uri can dereference an additional
caller-controlled URL.

Extend the existing archive denylist with --add-file and --add-virtual-file,
and the clone denylist with --bundle-uri. Regression coverage exercises archive
kwargs plus both clone multi-option and keyword paths.

Git baseline: a23bace963d508bd96983cc637131392d3face18.
Documentation/git-archive.adoc defines --add-file/--add-virtual-file, and
Documentation/git-clone.adoc defines --bundle-uri as fetching from the supplied
URI.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
---
 git/repo/base.py   | 6 ++++++
 test/test_clone.py | 2 ++
 test/test_repo.py  | 4 ++++
 3 files changed, 12 insertions(+)

Index: GitPython-3.1.34.1693646983.2a2ae77/git/repo/base.py
===================================================================
--- GitPython-3.1.34.1693646983.2a2ae77.orig/git/repo/base.py
+++ GitPython-3.1.34.1693646983.2a2ae77/git/repo/base.py
@@ -149,6 +149,8 @@ class Repo(object):
         "-c",
         # Can install hooks that execute during clone:
         "--template",
+        # Fetches from a caller-controlled URL:
+        "--bundle-uri",
     ]
 
     unsafe_git_archive_options = [
@@ -157,6 +159,10 @@ class Repo(object):
         # Writes output to a caller-controlled filesystem path.
         "--output",
         "-o",
+        # Reads from a caller-controlled filesystem path:
+        "--add-file",
+        # Injects a caller-controlled path and contents:
+        "--add-virtual-file",
     ]
 
     unsafe_git_revision_options = [
Index: GitPython-3.1.34.1693646983.2a2ae77/test/test_clone.py
===================================================================
--- GitPython-3.1.34.1693646983.2a2ae77.orig/test/test_clone.py
+++ GitPython-3.1.34.1693646983.2a2ae77/test/test_clone.py
@@ -143,6 +143,7 @@ class TestClone(TestBase):
                 "-cprotocol.ext.allow=always",
                 "-vcprotocol.ext.allow=always",
                 f"--template={tmp_dir}",
+                f"--bundle-uri=file://{tmp_dir}",
             ]
             for unsafe_option in unsafe_options:
                 with self.assertRaises(UnsafeOptionError):
@@ -158,6 +159,7 @@ class TestClone(TestBase):
                 {"conf": "protocol.ext.allow=always"},
                 {"c": "protocol.ext.allow=always"},
                 {"template": tmp_dir},
+                {"bundle_uri": f"file://{tmp_dir}"},
             ]
             for unsafe_option in unsafe_options:
                 with self.assertRaises(UnsafeOptionError):
Index: GitPython-3.1.34.1693646983.2a2ae77/test/test_repo.py
===================================================================
--- GitPython-3.1.34.1693646983.2a2ae77.orig/test/test_repo.py
+++ GitPython-3.1.34.1693646983.2a2ae77/test/test_repo.py
@@ -399,6 +399,10 @@ class TestRepo(TestBase):
             with self.assertRaises(UnsafeOptionError):
                 self.rorepo.archive(io.BytesIO(), "0.1.6", output=output_marker)
             assert not osp.exists(output_marker)
+            with self.assertRaises(UnsafeOptionError):
+                self.rorepo.archive(io.BytesIO(), "0.1.6", add_file=output_marker)
+            with self.assertRaises(UnsafeOptionError):
+                self.rorepo.archive(io.BytesIO(), "0.1.6", add_virtual_file="file:content")
 
     def test_archive_rejects_unsafe_remote_protocol(self):
         with tempfile.TemporaryDirectory() as tdir:
