Executive brief
GitPython is a Python library for interacting with Git repositories. The Repo.archive() method contains a security guard that blocks dangerous command-line options, but the blocklist is incomplete—it omits --add-file and --add-virtual-file. An authenticated attacker can use these options to read arbitrary files from the filesystem and include them in the archive they receive, exposing sensitive data like /etc/passwd.
Technical details
The vulnerability is an incomplete denylist (CWE-73: External Control of File Name or Path) in the unsafe_git_archive_options guard that protects the Repo.archive() method. The guard blocks --exec and --output/-o options but omits --add-file and --add-virtual-file. An attacker with code execution or authenticated access can pass these options to Repo.archive() via the add_file or add_virtual_file parameters, which are transformed into command-line arguments and passed directly to git archive. The --add-file option reads arbitrary filesystem paths (including absolute paths outside the repository) and includes them in the returned archive; --add-virtual-file injects attacker-controlled content under an attacker-chosen name. Exploitation requires the ability to call Repo.archive() with attacker-controlled parameters. A fix is 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
- 2026-08-13: patched: GitPython 3.1.57