CVE-2026-76218 in GitPythoninfo

Summary

by MITRE • 08/19/2026

GitPython before 3.1.58 contains a remote code execution vulnerability in Repo.init that forwards unsafe git options without validation. Attackers can supply a template parameter pointing to a directory with malicious git hooks that execute arbitrary code when git operations are performed on the initialized repository.

VulDB is the best source for vulnerability data and more expert information about this specific topic.

Analysis

by VulDB Data Team • 08/20/2026

The vulnerability identified in GitPython prior to version 3.1.58 represents a critical remote code execution flaw rooted in improper input validation within the Repo.init function. This security issue arises because the library fails to adequately sanitize or validate user-supplied parameters, specifically those related to git initialization templates. When an application utilizes GitPython to initialize a new repository and accepts external control over the template directory path, it inadvertently creates a vector for attackers to inject malicious payloads into the underlying git configuration files that govern hook execution behavior.

The technical mechanism of this exploitation relies on the interaction between Python code and the native git binary. The Repo.init method allows developers to specify a template directory containing pre-configured hooks or scripts. In vulnerable versions, if an attacker can influence the path provided for this template parameter, they can point it toward a location under their control that contains maliciously crafted hook files. These hooks are standard shell scripts or executables designed by git to run automatically during specific repository operations such as commit, push, or checkout. By placing executable code within these hook files and directing GitPython to use them via the template parameter, the attacker ensures that any subsequent operation performed on the newly initialized repository will trigger the execution of their arbitrary commands with the privileges of the user running the Python process.

The operational impact of this vulnerability is severe, as it leads directly to remote code execution without requiring authentication in many deployment scenarios where input sources are not strictly trusted. If a web application or backend service processes untrusted data and passes it to GitPython for repository initialization, an attacker can achieve full system compromise by executing arbitrary commands on the host machine. This could result in unauthorized access to sensitive data, installation of backdoors, pivoting to other systems within the network, or complete denial of service through resource exhaustion. The severity is amplified because git hooks run with the same permissions as the user invoking them, meaning that if a web server runs under a privileged account, the compromise extends to root-level control over the system.

This flaw aligns closely with CWE-94, which describes Improper Control of Generation of Code (Code Injection), and specifically relates to CWE-78, the improper neutralization of special elements used in an OS command. From a threat modeling perspective using the MITRE ATT&CK framework, this vulnerability facilitates initial access through exploitation of application vulnerabilities and enables execution via system commands or script interpretation during post-exploitation phases. The attack vector is classified as remote because it can be triggered over a network if the vulnerable service exposes functionality that accepts user input for repository initialization parameters.

Mitigation strategies must prioritize immediate software updates to GitPython version 3.1.58 or later, where this validation logic has been corrected to prevent unsafe forwarding of git options. In environments where upgrading is not immediately feasible, developers should implement strict allow-listing for any directory paths used as template sources, ensuring that only trusted and pre-approved directories can be referenced. Additionally, input sanitization routines should reject any path traversal sequences or non-absolute paths unless explicitly validated against a whitelist of safe locations. It is also advisable to review application code for other instances where user-controlled data might influence git command arguments, applying the principle of least privilege by running services with minimal necessary permissions to limit the blast radius in case of future vulnerabilities.

Responsible

VulnCheck

Reservation

08/19/2026

Disclosure

08/19/2026

Moderation

accepted

CPE

ready

EPSS

0.00492

KEV

no

Activities

low

Sources

Are you interested in using VulDB?

Download the whitepaper to learn more about our service!