CVE-2026-78677
GitPython 3.1.58‑59 lets attackers use –separate-git-dir to create arbitrary git dirs outside the clone target.
- CVSS 8.7
- CWE-22
- Input Validation and Sanitization
- Remote
GitPython before 3.1.59 omits –separate-git-dir from unsafe_git_clone_options, allowing attackers to create arbitrary git directories outside the intended clone destination. Attackers can pass a separate_git_dir parameter to Repo.clone_from() or Repo.clone() to redirect repository metadata to an attacker-controlled filesystem path, enabling arbitrary directory creation and potential hook execution.
- CWE
- CWE-22
- CVSS base score
- 8.7
- Published
- 2026-08-25
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Interface
- 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.59 or later.
Vulnerable code sample
import os
from git import Repo
def clone_repository(src_url: str, dest_path: str, separate_git_dir: str):
"""
Clone a remote repository, allowing the caller to specify a separate .git directory.
"""
# VULNERABLE: passes user‑controlled separate_git_dir directly to GitPython
repo = Repo.clone_from(
src_url,
dest_path,
**{"separate_git_dir": separate_git_dir}
)
return repoPatched code sample
import os
from git import Repo
def clone_repository(src_url: str, dest_path: str, separate_git_dir: str):
"""
Clone a remote repository, sanitizing the separate_git_dir to prevent path traversal.
"""
# FIX: ensure separate_git_dir resolves inside dest_path before passing to GitPython
abs_dest = os.path.abspath(dest_path)
abs_sep = os.path.abspath(separate_git_dir)
if not abs_sep.startswith(abs_dest + os.sep):
raise ValueError("separate_git_dir must be inside the destination path")
repo = Repo.clone_from(
src_url,
dest_path,
**{"separate_git_dir": abs_sep}
)
return repoPublished 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.
- Block separate git directories during clone (gitpython-developers/GitPython)
git/objects/submodule/base.py,git/objects/submodule/base.py · Submodule._clone_repo,git/repo/base.py
Cite this entry
@misc{vaitp:cve202678677,
title = {{GitPython 3.1.58‑59 lets attackers use --separate-git-dir to create arbitrary git dirs outside the clone target.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-78677},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-78677/}}
}
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 ::
