VAITP Dataset

← Back to the dataset

CVE-2026-76221

GitPython < 3.1.58 allows config‑name injection via crafted option names.

  • CVSS 8.7
  • CWE-74
  • Input Validation and Sanitization
  • Local

GitPython before 3.1.58 contains a config-name injection vulnerability in the option-name validator that allows attackers to forge arbitrary git-config directives by injecting equals signs, hash symbols, and whitespace into option names. Attackers can inject malicious option names like 'sshCommand = touch /tmp/RCE #' to execute arbitrary commands via core.sshCommand or core.hooksPath on the next git operation.

CVSS base score
8.7
Published
2026-08-19
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Local
Impact
Arbitrary Code Execution
Affected component
GitPython
Fixed by upgrading
Yes

Solution

Upgrade GitPython to version 3.1.58 or newer.

Vulnerable code sample

from git import Repo

def set_git_option(repo_path: str, option_name: str, option_value: str) -> None:
    """
    Set a git configuration option directly using the provided name.
    """
    repo = Repo(repo_path)
    # VULNERABLE: option_name is not validated, allowing injection via '=', '#', or whitespace
    with repo.config_writer() as cfg:
        cfg.set_value(option_name, option_value)

Patched code sample

from git import Repo
import re

def set_git_option(repo_path: str, option_name: str, option_value: str) -> None:
    """
    Set a git configuration option after validating the option name.
    """
    repo = Repo(repo_path)
    # FIX: reject option names containing '=', '#', or whitespace to prevent injection
    if re.search(r'[=\s#]', option_name):
        raise ValueError("Invalid git config option name")
    with repo.config_writer() as cfg:
        cfg.set_value(option_name, option_value)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve202676221,
  title        = {{GitPython < 3.1.58 allows config‑name injection via crafted option names.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-76221},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-76221/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.