VAITP Dataset

← Back to the dataset

CVE-2026-110859

Argument injection in GitPython Head.checkout() enables file read via crafted branch name.

  • CVSS 8.7
  • CWE-88
  • Input Validation and Sanitization
  • Remote

GitPython before 3.2.0 contains an argument injection vulnerability in Head.checkout() that allows remote attackers to read arbitrary files by supplying a branch name parsed as a git option. Attackers can host a repository whose default branch is named –pathspec-from-file=, causing cloning applications that check out the active branch to leak file contents through GitCommandError messages.

CVSS base score
8.7
Published
2026-10-14
OWASP
A03 Injection
Orthogonal defect classification
Interface
Code defect classification
Incorrect Interface
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
GitPython
Fixed by upgrading
Yes

Solution

Upgrade GitPython to version 3.2.0 or later.

Vulnerable code sample

import os
from git import Repo, GitCommandError

def checkout_branch(repo_path: str, branch_name: str) -> None:
    """
    Clone a repository (if needed) and check out the given branch.
    """
    if not os.path.isdir(repo_path):
        Repo.clone_from("https://example.com/repo.git", repo_path)
    repo = Repo(repo_path)

    # VULNERABLE: branch name is passed directly to git checkout, allowing option injection
    try:
        repo.head.reference = repo.refs[branch_name]
        repo.head.checkout()
    except GitCommandError as e:
        # Propagate the error (may contain leaked file contents)
        raise e

Patched code sample

import os
from git import Repo, GitCommandError

def checkout_branch(repo_path: str, branch_name: str) -> None:
    """
    Clone a repository (if needed) and safely check out the given branch.
    """
    if not os.path.isdir(repo_path):
        Repo.clone_from("https://example.com/repo.git", repo_path)
    repo = Repo(repo_path)

    # FIX: validate branch name and use '--' separator to prevent option injection
    if branch_name.startswith('-') or ' ' in branch_name:
        raise ValueError("Invalid branch name")
    try:
        repo.head.reference = repo.refs[branch_name]
        repo.git.checkout('--', branch_name)
    except GitCommandError as e:
        raise e

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:cve2026110859,
  title        = {{Argument injection in GitPython Head.checkout() enables file read via crafted branch name.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-110859},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-110859/}}
}

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.