VAITP Dataset

← Back to the dataset

CVE-2026-114145

GitPython allows malicious submodule paths to write executable hooks before validation.

  • CVSS 7.5
  • CWE-696
  • Input Validation and Sanitization
  • Remote

GitPython is a python library used to interact with Git repositories. Prior to 3.2.1, create_submodule() in git/objects/submodule/base.py accepts an attacker-influenced submodule path such as .git/hooks and invokes _clone_repo() before safely rejecting the destination. In 3.1.x, _validate_repo_path() does not exist and the call succeeds silently, while in 3.2.0 and later affected revisions the check in git/index/base.py raises ValueError only after the clone has written to disk and does not remove the planted file. An attacker-controlled submodule can therefore place an executable post-checkout hook that a later Git operation executes. Exploitation requires an application to accept an untrusted submodule path and a clone destination such as .git/hooks that is empty enough for Git to clone into it, which commonly means that default sample hooks are absent. This issue is fixed in version 3.2.1.

CVSS base score
7.5
Published
2026-10-21
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Path Traversal
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
GitPython
Fixed by upgrading
Yes

Solution

Upgrade GitPython to version 3.2.1 or later.

Vulnerable code sample

import os
from git import Repo

def add_submodule(repo_dir, url, submodule_path):
    """
    Clones a submodule into the given repository.
    """
    repo = Repo(repo_dir)
    # VULNERABLE: accepts attacker‑controlled path like ".git/hooks"
    repo.create_submodule(name=os.path.basename(submodule_path),
                          path=submodule_path,
                          url=url)

Patched code sample

import os
from git import Repo

def add_submodule(repo_dir, url, submodule_path):
    """
    Clones a submodule into the given repository.
    """
    repo = Repo(repo_dir)
    # FIX: reject paths that would write inside the .git directory
    if os.path.normpath(submodule_path).startswith('.git'):
        raise ValueError("Submodule path must not be inside .git")
    repo.create_submodule(name=os.path.basename(submodule_path),
                          path=submodule_path,
                          url=url)

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.

  • fix(submodule): validate destinations before mutation (gitpython-developers/GitPython)
    git/objects/submodule/base.py, git/objects/submodule/base.py · Submodule.module, git/objects/submodule/base.py · Submodule.move, git/objects/submodule/base.py · Submodule.rename, git/objects/submodule/base.py · Submodule._checked_abspath, git/objects/submodule/base.py · Submodule._checkout_abspath, git/objects/submodule/base.py · Submodule._clone_repo, git/objects/submodule/base.py · Submodule._module_abspath, git/objects/submodule/base.py · Submodule._to_relative_path, git/objects/submodule/base.py · Submodule._validated_name

Cite this entry

@misc{vaitp:cve2026114145,
  title        = {{GitPython allows malicious submodule paths to write executable hooks before validation.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-114145},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-114145/}}
}

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.