From ffcb5359e87619f4fe4a70a4aff5f08c5580ba97 Mon Sep 17 00:00:00 2001
From: "GPT 5.6" <codex@openai.com>
Date: Wed, 22 Jul 2026 04:43:26 +0200
Subject: [PATCH] fix: reject unsafe clone templates

<!-- agent -->

Treat git clone --template as unsafe because caller-controlled
templates can install hooks that execute during clone.

Add regression coverage for both direct option and keyword forms.

References GHSA-6p8h-3wgx-97gf.
Validated against Git baseline a23bace9.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
---
 git/repo/base.py   | 5 +++++
 test/test_clone.py | 2 ++
 2 files changed, 7 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
@@ -147,6 +147,8 @@ class Repo(object):
         # https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---configltkeygtltvaluegt
         "--config",
         "-c",
+        # Can install hooks that execute during clone:
+        "--template",
     ]
 
     unsafe_git_archive_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
@@ -142,6 +142,7 @@ class TestClone(TestBase):
                 "-c protocol.ext.allow=always",
                 "-cprotocol.ext.allow=always",
                 "-vcprotocol.ext.allow=always",
+                f"--template={tmp_dir}",
             ]
             for unsafe_option in unsafe_options:
                 with self.assertRaises(UnsafeOptionError):
@@ -156,6 +157,7 @@ class TestClone(TestBase):
                 {"config": "protocol.ext.allow=always"},
                 {"conf": "protocol.ext.allow=always"},
                 {"c": "protocol.ext.allow=always"},
+                {"template": tmp_dir},
             ]
             for unsafe_option in unsafe_options:
                 with self.assertRaises(UnsafeOptionError):
