GitPython: Arbitrary file truncation via git rev-list --output argument injection in unguarded Commit.count
GitPython versions up to 3.1.53 contain a vulnerability in the Commit.count() method where unguarded forwarding of options to git rev-list allows an attacker to specify an --output argument. This causes git rev-list to truncate an arbitrary file to zero bytes, resulting in file destruction. The vulnerability has medium severity with a CVSS score of 5.4. A patch is available that adds proper unsafe option checks to Commit.count().
AI Analysis
Technical Summary
The Commit.count() method in GitPython forwards keyword arguments directly to git rev-list without checking for unsafe options, unlike the sibling iter_items method which has such a guard. Specifically, passing an output parameter to count() results in git rev-list executing with --output=<path>, which truncates the specified file to zero bytes before processing revisions. This allows an attacker with the ability to influence the output argument to destroy or blank arbitrary files at the process privilege level. The vulnerability affects GitPython versions up to 3.1.53 and was confirmed by proof-of-concept truncation of files. The issue is distinct from previously fixed vulnerabilities in iter_commits and blame methods. The recommended fix is to add check_unsafe_options to Commit.count(), mirroring the protection in iter_items.
Potential Impact
An attacker able to control the output argument passed to Commit.count() can cause arbitrary files to be truncated to zero bytes, resulting in loss of file integrity and availability. The truncation occurs with the privileges of the running process. There is no content injection or confidentiality impact. The reachability is limited to contexts where the output argument can be influenced, and the impact is limited to file destruction (zero-byte truncation).
Mitigation Recommendations
A patch is available that adds unsafe option checks to Commit.count(), preventing injection of the --output argument. Users should upgrade to GitPython versions 3.1.56 or later where this fix is applied. Until patched, avoid passing untrusted input to Commit.count() keyword arguments, especially the output parameter.
GitPython: Arbitrary file truncation via git rev-list --output argument injection in unguarded Commit.count
Description
GitPython versions up to 3.1.53 contain a vulnerability in the Commit.count() method where unguarded forwarding of options to git rev-list allows an attacker to specify an --output argument. This causes git rev-list to truncate an arbitrary file to zero bytes, resulting in file destruction. The vulnerability has medium severity with a CVSS score of 5.4. A patch is available that adds proper unsafe option checks to Commit.count().
CVSS v3.1
Score 5.4medium
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The Commit.count() method in GitPython forwards keyword arguments directly to git rev-list without checking for unsafe options, unlike the sibling iter_items method which has such a guard. Specifically, passing an output parameter to count() results in git rev-list executing with --output=<path>, which truncates the specified file to zero bytes before processing revisions. This allows an attacker with the ability to influence the output argument to destroy or blank arbitrary files at the process privilege level. The vulnerability affects GitPython versions up to 3.1.53 and was confirmed by proof-of-concept truncation of files. The issue is distinct from previously fixed vulnerabilities in iter_commits and blame methods. The recommended fix is to add check_unsafe_options to Commit.count(), mirroring the protection in iter_items.
Potential Impact
An attacker able to control the output argument passed to Commit.count() can cause arbitrary files to be truncated to zero bytes, resulting in loss of file integrity and availability. The truncation occurs with the privileges of the running process. There is no content injection or confidentiality impact. The reachability is limited to contexts where the output argument can be influenced, and the impact is limited to file destruction (zero-byte truncation).
Mitigation Recommendations
A patch is available that adds unsafe option checks to Commit.count(), preventing injection of the --output argument. Users should upgrade to GitPython versions 3.1.56 or later where this fix is applied. Until patched, avoid passing untrusted input to Commit.count() keyword arguments, especially the output parameter.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-p538-c434-8v24
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["PyPI"]
- Database Specific Severity
- MODERATE
- Cvss Version
- 3.1
Threat ID: 6a710650bf32cb7a34392dd5
Added to database: 08/03/2026, 21:21:20 UTC
Last enriched: 08/03/2026, 21:23:59 UTC
Last updated: 08/04/2026, 01:04:01 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.