VAITP Dataset

← Back to the dataset

CVE-2026-100689

GitPython 3.1.61 allows path traversal via untrusted .gitmodules, leading to arbitrary directory creation/deletion.

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

GitPython before 3.1.62 does not validate the `path` field read from an untrusted .gitmodules file when updating submodules. While a prior fix (GHSA-hmq2-w58f-27jc) added Submodule._validated_name() to constrain the `name` field, and GitPython's own containment guard Submodule._to_relative_path() is applied in add() and move(), Submodule.update() derives the absolute checkout location from the raw `path` value without that guard. A .gitmodules entry containing directory traversal components (e.g., path = ../../../tmp/escaped) can therefore cause directories to be created via os.makedirs() outside the repository working tree, populated from the submodule URL on the clone path, and removed via shutil.rmtree() when force_remove is used. Exploitation requires an application flow that updates submodules at a non-HEAD commit (such as a historical-commit API); the common clone-then-update flow re-derives the path from a canonical tree lookup and is not affected. The issue is fixed in GitPython 3.1.62.

CVSS base score
8.7
Published
2026-09-26
OWASP
A04 Insecure Design
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.1.62 or later.

Vulnerable code sample

import os
from git import Repo, Submodule

def update_submodule(repo_path: str, submodule_name: str) -> None:
    """Update a submodule without validating its path."""
    repo = Repo(repo_path)
    # VULNERABLE: uses raw submodule.path from .gitmodules allowing path traversal
    sub = repo.submodule(submodule_name)
    target_path = os.path.join(repo.working_tree_dir, sub.path)  # may escape repo
    if not os.path.isdir(target_path):
        os.makedirs(target_path)
    sub.update(init=True, force=True)

Patched code sample

import os
from git import Repo, Submodule

def update_submodule(repo_path: str, submodule_name: str) -> None:
    """Update a submodule with path validation to prevent traversal."""
    repo = Repo(repo_path)
    # FIX: normalize and ensure submodule path stays within the repository
    sub = repo.submodule(submodule_name)
    normalized = os.path.normpath(sub.path)
    if normalized.startswith('..') or os.path.isabs(normalized):
        raise ValueError("Submodule path traversal detected")
    target_path = os.path.join(repo.working_tree_dir, normalized)
    if not os.path.isdir(target_path):
        os.makedirs(target_path)
    sub.update(init=True, force=True)

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:cve2026100689,
  title        = {{GitPython 3.1.61 allows path traversal via untrusted .gitmodules, leading to arbitrary directory creation/deletion.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-100689},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-100689/}}
}

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.