GitPython: Unguarded git read-tree option forwarding in IndexFile.from_tree/reset/merge_tree enables arbitrary file overwrite
GitPython versions up to 3.1.57 contain a vulnerability in the IndexFile.from_tree, reset, and merge_tree methods where unguarded forwarding of git read-tree options allows an attacker to overwrite arbitrary files. The flaw arises because these methods append caller-controlled treeish strings to git read-tree commands without proper unsafe option checks or separators, enabling injection of the --index-output option to specify arbitrary file paths. This leads to arbitrary file overwrite with a valid git-index blob, potentially destroying or corrupting files accessible by the host process.
AI Analysis
Technical Summary
The vulnerability in GitPython (<=3.1.57) involves the IndexFile.from_tree, reset, and merge_tree methods calling git read-tree with caller-influenced positional arguments without safety checks or a '--' separator. This allows an attacker to inject the '--index-output' option, which directs git read-tree to write the index output to an arbitrary file path controlled by the attacker. The last occurrence of this option wins, enabling overwriting of arbitrary files with a valid git-index blob. The vulnerability does not allow arbitrary code execution but can cause significant file corruption or destruction at the privileges of the host process. The issue was not fixed by prior commits that guarded other git commands, and the recommended fix involves adding unsafe option checks or a '--' separator to block injection of path-taking options.
Potential Impact
An attacker able to control the treeish argument to these methods can overwrite arbitrary files on the host system with a valid git-index blob. This can lead to destruction or corruption of important files such as configuration files or user data, causing integrity and availability impacts. The attack requires privileges to execute the vulnerable methods but does not allow direct code execution. The impact severity is high due to the potential for destructive file overwrite.
Mitigation Recommendations
A patch is available for this vulnerability. The recommended remediation is to apply the official fix that adds checks for unsafe options and/or inserts a '--' separator before positional treeish arguments in the affected methods to prevent injection of the '--index-output' option. Until patched, avoid passing untrusted input to IndexFile.from_tree, reset, or merge_tree methods. Check the vendor advisory or GitPython repository for the latest patched versions and upgrade accordingly.
GitPython: Unguarded git read-tree option forwarding in IndexFile.from_tree/reset/merge_tree enables arbitrary file overwrite
Description
GitPython versions up to 3.1.57 contain a vulnerability in the IndexFile.from_tree, reset, and merge_tree methods where unguarded forwarding of git read-tree options allows an attacker to overwrite arbitrary files. The flaw arises because these methods append caller-controlled treeish strings to git read-tree commands without proper unsafe option checks or separators, enabling injection of the --index-output option to specify arbitrary file paths. This leads to arbitrary file overwrite with a valid git-index blob, potentially destroying or corrupting files accessible by the host process.
CVSS v3.1
Score 8.1high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability in GitPython (<=3.1.57) involves the IndexFile.from_tree, reset, and merge_tree methods calling git read-tree with caller-influenced positional arguments without safety checks or a '--' separator. This allows an attacker to inject the '--index-output' option, which directs git read-tree to write the index output to an arbitrary file path controlled by the attacker. The last occurrence of this option wins, enabling overwriting of arbitrary files with a valid git-index blob. The vulnerability does not allow arbitrary code execution but can cause significant file corruption or destruction at the privileges of the host process. The issue was not fixed by prior commits that guarded other git commands, and the recommended fix involves adding unsafe option checks or a '--' separator to block injection of path-taking options.
Potential Impact
An attacker able to control the treeish argument to these methods can overwrite arbitrary files on the host system with a valid git-index blob. This can lead to destruction or corruption of important files such as configuration files or user data, causing integrity and availability impacts. The attack requires privileges to execute the vulnerable methods but does not allow direct code execution. The impact severity is high due to the potential for destructive file overwrite.
Mitigation Recommendations
A patch is available for this vulnerability. The recommended remediation is to apply the official fix that adds checks for unsafe options and/or inserts a '--' separator before positional treeish arguments in the affected methods to prevent injection of the '--index-output' option. Until patched, avoid passing untrusted input to IndexFile.from_tree, reset, or merge_tree methods. Check the vendor advisory or GitPython repository for the latest patched versions and upgrade accordingly.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-4gmw-gg2m-w46p
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["PyPI"]
- Database Specific Severity
- HIGH
- Cvss Version
- 3.1
Threat ID: 6a774331bf8831d539b4641b
Added to database: 08/08/2026, 14:54:41 UTC
Last enriched: 08/08/2026, 15:42:06 UTC
Last updated: 08/08/2026, 16:02:47 UTC
Views: 5
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.