Executive brief
GitPython is a popular library used by developers to interact with Git repositories. A vulnerability in its 'diff' functionality allows an attacker to overwrite or corrupt any file on the system that the application has permission to access. This could lead to a complete system takeover if critical configuration files or security keys are replaced.
Technical details
An argument injection vulnerability exists in GitPython's `Diffable.diff()` method. The method fails to use `check_unsafe_options` when forwarding keyword arguments to the underlying Git command. Additionally, it inserts the `other` reference argument before the `--` separator, allowing an attacker to inject the `--output=<path>` flag. By controlling either a keyword argument or the reference string, a remote attacker with low privileges can force Git to write diff output to an arbitrary file path, leading to file overwrite or corruption. This affects classes that mix in `Diffable`, including `Commit`, `Tree`, `IndexFile`, and `Submodule`. The issue is fixed in version 3.1.54.
Affected products
- gitpython-developers GitPython <= 3.1.53
Timeline
- 2026-07-22: disclosed: Initial report and publication to repository
- 2026-07-24: advisory: GitHub Advisory published
- 2026-07-24: patched: Version 3.1.54 released