GitPython: Arbitrary Git Repository Creation Outside the Working Tree via Unvalidated .gitmodules Submodule Name in GitPython
GitPython versions prior to 3.1.58 contain a vulnerability where an attacker-controlled submodule name in a cloned repository's .gitmodules file can cause GitPython to create and initialize a Git repository outside the intended working directory. This occurs because GitPython does not validate the submodule name, allowing directory traversal sequences that lead to repository creation at arbitrary filesystem paths during submodule initialization.
AI Analysis
Technical Summary
GitPython computes the on-disk location of a submodule's separate Git directory based on the submodule name from the .gitmodules file without validation. An attacker can craft a malicious repository with a submodule name containing directory traversal sequences (e.g., ../../../../some/path) that cause GitPython to create and initialize a full Git repository outside the intended clone directory when submodules are initialized via sm.update(init=True). This vulnerability arises because GitPython's implementation does not normalize or validate the submodule name, unlike core Git which blocks this attack class (CVE-2018-11235). The vulnerability affects GitPython versions before 3.1.58 and requires the victim to clone and initialize submodules from a malicious repository.
Potential Impact
An attacker who controls a repository that a victim clones and initializes submodules for using GitPython can cause arbitrary creation and initialization of Git repositories at attacker-chosen filesystem paths outside the intended working directory. This can lead to unauthorized file system modifications and potential interference with other repositories or system files. The vulnerability does not directly disclose data or escalate privileges but allows integrity impact by creating repositories in unintended locations.
Mitigation Recommendations
A patch is available in GitPython version 3.1.58 that addresses this vulnerability by validating submodule names to prevent directory traversal. Users should upgrade to GitPython 3.1.58 or later. Until upgraded, avoid cloning and initializing submodules from untrusted repositories using GitPython. Core Git itself is not affected as it already blocks this attack class. No additional mitigations are indicated by the vendor advisory.
GitPython: Arbitrary Git Repository Creation Outside the Working Tree via Unvalidated .gitmodules Submodule Name in GitPython
Description
GitPython versions prior to 3.1.58 contain a vulnerability where an attacker-controlled submodule name in a cloned repository's .gitmodules file can cause GitPython to create and initialize a Git repository outside the intended working directory. This occurs because GitPython does not validate the submodule name, allowing directory traversal sequences that lead to repository creation at arbitrary filesystem paths during submodule initialization.
CVSS v3.1
Score 8.2high
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 computes the on-disk location of a submodule's separate Git directory based on the submodule name from the .gitmodules file without validation. An attacker can craft a malicious repository with a submodule name containing directory traversal sequences (e.g., ../../../../some/path) that cause GitPython to create and initialize a full Git repository outside the intended clone directory when submodules are initialized via sm.update(init=True). This vulnerability arises because GitPython's implementation does not normalize or validate the submodule name, unlike core Git which blocks this attack class (CVE-2018-11235). The vulnerability affects GitPython versions before 3.1.58 and requires the victim to clone and initialize submodules from a malicious repository.
Potential Impact
An attacker who controls a repository that a victim clones and initializes submodules for using GitPython can cause arbitrary creation and initialization of Git repositories at attacker-chosen filesystem paths outside the intended working directory. This can lead to unauthorized file system modifications and potential interference with other repositories or system files. The vulnerability does not directly disclose data or escalate privileges but allows integrity impact by creating repositories in unintended locations.
Mitigation Recommendations
A patch is available in GitPython version 3.1.58 that addresses this vulnerability by validating submodule names to prevent directory traversal. Users should upgrade to GitPython 3.1.58 or later. Until upgraded, avoid cloning and initializing submodules from untrusted repositories using GitPython. Core Git itself is not affected as it already blocks this attack class. No additional mitigations are indicated by the vendor advisory.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-hmq2-w58f-27jc
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["PyPI"]
- Database Specific Severity
- HIGH
- Cvss Version
- 3.1
Threat ID: 6a774331bf8831d539b463ea
Added to database: 08/08/2026, 14:54:41 UTC
Last enriched: 08/08/2026, 15:41:27 UTC
Last updated: 08/08/2026, 22:12:39 UTC
Views: 9
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.