GitPython: Arbitrary file truncation via git rev-list --output argument injection in unguarded Commit.count
Affects GitPythonSource GCVE Database
CVSS 5.4 Medium : upgrade to 3.1.56 when convenient.
Data as of 3 Aug 2026, 21:23 UTC
- Patch
- Available – fixed in 3.1.56
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:LWhat to do
Upgrade GitPython to 3.1.56.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
| PyPIGitPython | Affected
| Fixed in
|
Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.
AI-suggested
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.
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().
References
- github.com/gitpython-developers/GitPython/security/advisories/GHSA-p538-c434-8v24 (opens in a new tab)
- github.com/gitpython-developers/GitPython/pull/2184 (opens in a new tab)
- github.com/gitpython-developers/GitPython/commit/38553b6fddc7f6a667cdb45a6762343a08fc72b2 (opens in a new tab)
- github.com/gitpython-developers/GitPython (opens in a new tab)
- github.com/gitpython-developers/GitPython/releases/tag/3.1.56 (opens in a new tab)