Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

GitPython: Unguarded git option forwarding in Repo.init enables arbitrary command execution via --template clone hooks

0
High
Published: 08/07/2026 (08/07/2026, 15:36:43 UTC)
Source: GCVE Database
Product: GitPython

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().

CVSS v3.1

Score 7.5high

Attack Vector
Network
Attack Complexity
High
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H

Affected software

PyPIghsa
GitPython
Affected versions
<3.1.58

Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 08/08/2026, 15:41:49 UTC

Technical Analysis

The vulnerability exists in GitPython's Repo.init() method, which forwards all keyword arguments directly to the underlying git init command without any guard against unsafe options. The --template option allows specifying a directory whose hooks are copied into the new repository's .git/hooks directory. An attacker who can control the template directory can plant malicious hooks that execute arbitrary code on the next git operation. Unlike git clone, which has a denylist for unsafe options, Repo.init() lacks such checks, making it vulnerable. The attack requires two conditions: the application must forward a template kwarg controlled by the attacker, and the attacker must stage an executable hook directory at a known path. This vulnerability is tracked as GHSA-9rj7-rf2p-w77r and affects GitPython versions prior to 3.1.58.

Potential Impact

Successful exploitation results in arbitrary code execution with the privileges of the host process running the git operation. The attack complexity is high because the attacker must both stage an executable hook directory and influence the template argument passed to Repo.init(). The impact includes full compromise of the affected environment through malicious git hooks triggered on subsequent git commands.

Mitigation Recommendations

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.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Gcve Source
db.gcve.eu
Osv Id
GHSA-9rj7-rf2p-w77r
Osv Schema Version
1.4.0
Aliases
[]
Ecosystems
["PyPI"]
Database Specific Severity
HIGH
Cvss Version
3.1

Threat ID: 6a774331bf8831d539b46414

Added to database: 08/08/2026, 14:54:41 UTC

Last enriched: 08/08/2026, 15:41:49 UTC

Last updated: 08/08/2026, 16:02:47 UTC

Views: 5

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses