GitPython: Unguarded git option forwarding
Affects GitPythonSource GCVE Database
CVSS 7.5 High : upgrade to 3.1.58 soon.
Data as of 26 Oct 2026, 16:15 UTC
- Patch
- Available – fixed in 3.1.58
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:HWhat to do
Upgrade GitPython to 3.1.58.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
| PyPIGitPython | Affected
| Fixed in
|
Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.
AI-suggested
A patch is available that adds a check_unsafe_options guard to Repo.init(), including a denylist of unsafe options such as --template and --separate-git-dir. Users should upgrade to GitPython version 3.1.58 or later where this fix is implemented. Until patched, avoid passing untrusted input to the template parameter in Repo.init() to prevent arbitrary code execution.
Description
GitPython versions up to 3.1.57 have a vulnerability in the Repo.init() method where unsafe git options are forwarded without validation. Specifically, the --template option can be exploited by an attacker to plant malicious git hooks that execute arbitrary code during subsequent git operations. This occurs because Repo.init() directly passes kwargs to git init without checking for unsafe options, unlike the clone path which has protections. Exploitation requires the attacker to control the template directory and stage executable hooks. A fix is available that adds unsafe option checks to Repo.init().
References
- github.com/gitpython-developers/GitPython/security/advisories/GHSA-9rj7-rf2p-w77r (opens in a new tab)
- github.com/gitpython-developers/GitPython/pull/2204 (opens in a new tab)
- github.com/gitpython-developers/GitPython/commit/d9ddb55bdc66 (opens in a new tab)
- github.com/gitpython-developers/GitPython (opens in a new tab)
- github.com/gitpython-developers/GitPython/releases/tag/3.1.58 (opens in a new tab)
- nvd.nist.gov/vuln/detail/CVE-2026-76218 (opens in a new tab)
- vulncheck.com/advisories/gitpython-before-remote-code-execution-via-repo-init (opens in a new tab)