Executive brief
GitPython, a popular Python library for interacting with Git repositories, contains vulnerabilities that allow attackers to execute arbitrary commands or overwrite files on the host system. By providing specially crafted inputs to certain functions like archiving or commit listing, an attacker can bypass security checks to run malicious code or destroy critical system files. This could lead to full system compromise, data loss, or service outages depending on how the library is integrated into an application.
Technical details
GitPython fails to apply its 'check_unsafe_options' enforcement to several public APIs, leading to command injection and file manipulation primitives. Specifically, Repo.archive() and git.ls_remote() allow attackers to inject unsafe Git options like '--exec' or '--upload-pack' through keyword arguments, leading to arbitrary command execution. Additionally, Repo.iter_commits() and Repo.blame() do not validate the 'rev' positional argument for leading dashes, allowing an attacker to pass options like '--output=/path/to/file' which Git processes by opening and truncating the specified file before revision validation. These issues stem from an incomplete application of the security fixes previously introduced for network-related commands. The vulnerabilities are addressed in version 3.1.51.
Affected products
- gitpython-developers GitPython <= 3.1.50
Timeline
- 2026-07-12: advisory: GitHub Advisory published
- 2026-07-21: disclosed: Public disclosure date