Executive brief
GitPython is a Python library used to interact with Git repositories. A vulnerability in how it handles certain commands allows an attacker to read arbitrary files from the system where the library is running. This could lead to the exposure of sensitive information like configuration files, passwords, or private keys, potentially compromising the entire server or application.
Technical details
The vulnerability exists in `IndexFile.remove()` and `Head.checkout()` because they forward `**kwargs` directly to underlying `git rm` and `git checkout` commands without validation or the use of `check_unsafe_options()`. By providing the `--pathspec-from-file` and `--pathspec-file-nul` arguments, an attacker can force Git to treat a target file as a single NUL-delimited pathspec. If the pathspec does not match any files in the repository, Git returns the entire content of the file within the error message surfaced by `GitCommandError.stderr`. This allows for an in-band arbitrary file read. The issue is addressed in version 3.1.58.
Affected products
- gitpython-developers GitPython <= 3.1.57
Timeline
- 2026-08-04: disclosed: Initial disclosure by reporter
- 2026-08-07: advisory: GitHub Advisory published
- 2026-08-07: patched: Version 3.1.58 released