CVE-2026-73621
GitPython Commit.count injection lets attacker truncate files via –output
- CVSS 5.3
- CWE-88
- Input Validation and Sanitization
- Remote
GitPython before 3.1.56 contains an argument injection vulnerability in the Commit.count() method, which forwards keyword arguments to 'git rev-list' without the check_unsafe_options guard present in the sibling iter_items method. An attacker who can control options passed to Commit.count (e.g., via an application that forwards a user-supplied options dict) can supply output=, causing 'git rev-list –output=' to open and truncate the target file to zero bytes before revision parsing. This allows destruction/blanking of an arbitrary file at the process's privilege level (no content control, 0-byte truncation).
- CWE
- CWE-88
- CVSS base score
- 5.3
- Published
- 2026-08-13
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- GitPython
- Fixed by upgrading
- Yes
Solution
Upgrade GitPython to version 3.1.56 or later.
Vulnerable code sample
import sys
from git import Repo
def count_commits(repo_path: str, ref: str, user_options: dict):
"""Count commits reachable from `ref` using user supplied git options."""
repo = Repo(repo_path)
commit = repo.commit(ref)
# VULNERABLE: forwards unchecked options to git rev-list, allowing 'output=' injection
return commit.count(**user_options)
# Example usage (omitted)Patched code sample
import sys
from git import Repo
def count_commits(repo_path: str, ref: str, user_options: dict):
"""Count commits reachable from `ref` using user supplied git options."""
repo = Repo(repo_path)
commit = repo.commit(ref)
# FIX: filter out unsafe git options before forwarding
safe_options = {k: v for k, v in user_options.items() if k != "output"}
return commit.count(**safe_options)
# Example usage (omitted)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: reject unsafe output options in Commit.count (gitpython-developers/GitPython)
git/objects/commit.py · Commit.count
Cite this entry
@misc{vaitp:cve202673621,
title = {{GitPython Commit.count injection lets attacker truncate files via --output}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-73621},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-73621/}}
}
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 ::
