Executive brief
GitPython is a widely-used library that enables Python applications to interact with Git repositories. The library fails to validate dangerous command-line options passed through certain methods, allowing attackers with repository access to overwrite arbitrary files on the system or read sensitive files. An attacker can commit malicious files to a repository and use specially crafted method parameters to achieve file write/read operations outside the repository directory.
Technical details
GitPython blocks dangerous git options via Git.check_unsafe_options(), but this guard is inconsistently applied across the codebase. IndexFile.checkout() and TagReference.create() forward **kwargs directly to git commands without validation. IndexFile.checkout() forwards unguarded options to git checkout-index, allowing the --prefix flag to write repository content to arbitrary filesystem paths with full attacker control over both destination and content. TagReference.create() forwards unguarded options to git tag, allowing the -F flag to read arbitrary files and return their contents in-band via the tag message. Both require authentication (PR branch access or repository clone), but impact is high: file overwrites enable code execution via authorized_keys/.bashrc/.git/hooks injection, and arbitrary file reads expose sensitive data. Patches are available in version 3.1.57 and later.
Affected products
- GitPython GitPython before 3.1.57
Timeline
- 2026-07-26: disclosed
- 2026-08-13: advisory: CVE-2026-73620 published
- 2026-07-26: patched: Fixed in version 3.1.57