GitPython: command injection via unguarded Git options in `Repo.archive()`, `git.ls_remote()`, and arbitrary file overwrite via `Repo.iter_commits()` / `Repo.blame()`
GitPython versions prior to 3.1.51 contain multiple vulnerabilities due to insufficient validation of caller-supplied options in several public APIs. Specifically, `Repo.archive()` and `git.ls_remote()` allow arbitrary command execution by forwarding unsafe Git options without proper checks. Additionally, `Repo.iter_commits()` and `Repo.blame()` permit arbitrary file overwrite by placing unvalidated revision arguments before the end-of-options separator, enabling file truncation. These issues arise because the existing unsafe option checks are only applied to network commands and not extended to these other APIs.
AI Analysis
Technical Summary
GitPython spawns the Git binary with argument vectors constructed from caller inputs. To prevent command injection, it maintains a denylist of unsafe Git options enforced only on network commands (`clone_from`, `fetch`, `pull`, `push`). However, other APIs such as `Repo.archive()`, `git.ls_remote()`, `Repo.iter_commits()`, and `Repo.blame()` forward caller-controlled options or positional arguments directly to Git without invoking the unsafe option checks. This allows attackers to inject options like `--exec` or `--upload-pack` to execute arbitrary commands or use revision arguments starting with dashes to cause Git to open and truncate arbitrary files, leading to command execution and file overwrite vulnerabilities. The root cause is the incomplete application of `check_unsafe_options` and end-of-options discipline in these APIs.
Potential Impact
An attacker able to control inputs to `Repo.archive()` or `git.ls_remote()` can achieve arbitrary command execution on the host running GitPython. Inputs to `Repo.iter_commits()` or `Repo.blame()` can cause arbitrary file truncation or overwrite, potentially destroying critical files such as keys, configuration files, or lockfiles, impacting system integrity and availability. These vulnerabilities do not require elevated privileges or user interaction and can be exploited with local or remote input depending on usage context.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until an official fix is available, avoid passing untrusted or user-controlled inputs to `Repo.archive()`, `git.ls_remote()`, `Repo.iter_commits()`, and `Repo.blame()`. Restrict usage of these APIs to trusted inputs only. Monitor the GitPython project for updates that extend unsafe option checks to these APIs and apply patches promptly once released.
GitPython: command injection via unguarded Git options in `Repo.archive()`, `git.ls_remote()`, and arbitrary file overwrite via `Repo.iter_commits()` / `Repo.blame()`
Description
GitPython versions prior to 3.1.51 contain multiple vulnerabilities due to insufficient validation of caller-supplied options in several public APIs. Specifically, `Repo.archive()` and `git.ls_remote()` allow arbitrary command execution by forwarding unsafe Git options without proper checks. Additionally, `Repo.iter_commits()` and `Repo.blame()` permit arbitrary file overwrite by placing unvalidated revision arguments before the end-of-options separator, enabling file truncation. These issues arise because the existing unsafe option checks are only applied to network commands and not extended to these other APIs.
CVSS v3.1
Score 8.4high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
GitPython spawns the Git binary with argument vectors constructed from caller inputs. To prevent command injection, it maintains a denylist of unsafe Git options enforced only on network commands (`clone_from`, `fetch`, `pull`, `push`). However, other APIs such as `Repo.archive()`, `git.ls_remote()`, `Repo.iter_commits()`, and `Repo.blame()` forward caller-controlled options or positional arguments directly to Git without invoking the unsafe option checks. This allows attackers to inject options like `--exec` or `--upload-pack` to execute arbitrary commands or use revision arguments starting with dashes to cause Git to open and truncate arbitrary files, leading to command execution and file overwrite vulnerabilities. The root cause is the incomplete application of `check_unsafe_options` and end-of-options discipline in these APIs.
Potential Impact
An attacker able to control inputs to `Repo.archive()` or `git.ls_remote()` can achieve arbitrary command execution on the host running GitPython. Inputs to `Repo.iter_commits()` or `Repo.blame()` can cause arbitrary file truncation or overwrite, potentially destroying critical files such as keys, configuration files, or lockfiles, impacting system integrity and availability. These vulnerabilities do not require elevated privileges or user interaction and can be exploited with local or remote input depending on usage context.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until an official fix is available, avoid passing untrusted or user-controlled inputs to `Repo.archive()`, `git.ls_remote()`, `Repo.iter_commits()`, and `Repo.blame()`. Restrict usage of these APIs to trusted inputs only. Monitor the GitPython project for updates that extend unsafe option checks to these APIs and apply patches promptly once released.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-956x-8gvw-wg5v
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["PyPI"]
- Database Specific Severity
- HIGH
- Cvss Version
- 3.1
Threat ID: 6a600abf9c2644c7f8fe3123
Added to database: 07/22/2026, 00:11:43 UTC
Last enriched: 07/22/2026, 00:54:11 UTC
Last updated: 07/31/2026, 12:28:12 UTC
Views: 20
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.