# GitPython path traversal via unvalidated .gitmodules submodule name

Source: https://junglewise.ai/threats/gitpython-path-traversal-via-unvalidated-gitmodules-submodule-name-d3186e91  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-08-19. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: high · CVSS 8.2 · Published 2026-08-19

GitPython is a Python library that developers use to interact with Git repositories programmatically. When cloning a repository containing Git submodules, GitPython fails to validate submodule names from .gitmodules configuration files, allowing an attacker to create Git repositories at arbitrary locations on the victim's filesystem outside the intended clone directory. This could enable attackers to write malicious code or data to sensitive system locations if a user clones and initializes submodules from a malicious repository.

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** High severity, with a CVSS score of 8.2, published 19 August 2026.

**Which products and versions are affected?** GitPython-developers GitPython <=3.1.57.

**Is there a fix for This vulnerability?** A patch was published on 2026-08-04: Fix released in GitPython 3.1.58 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network, in a software library.

**Am I affected?** Check whether anything you run is named in the advisory. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

The vulnerability is a path traversal flaw (CWE-22) in GitPython's submodule handling. The root cause lies in src/GitPython/git/objects/submodule/util.py and src/GitPython/git/objects/submodule/base.py, where the sm_name() function extracts the submodule name from .gitmodules without validation. Unlike the submodule path (which is tree-validated), the name is used directly in Submodule._module_abspath() to construct the on-disk Git directory path via os.path.join(parent_repo.git_dir, "modules", name), which does not normalize path traversal sequences like "../". When submodule initialization is triggered (submodule_update(init=True)), this path is passed to os.makedirs() and git clone --separate-git-dir, creating a fully initialized Git repository at an attacker-controlled location outside the clone directory. The attack requires that a victim clone a malicious repository and run submodule initialization—a routine, often automatic operation in CI/CD pipelines. No authentication is required. The vulnerability is fixed in GitPython 3.1.58; prior versions up to 3.1.57 are affected.

## Affected products

- GitPython-developers GitPython <=3.1.57

## Timeline

- 2026-08-04: disclosed
- 2026-08-04: patched: Fix released in GitPython 3.1.58

## References

- [https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-hmq2-w58f-27jc](https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-hmq2-w58f-27jc)
- [https://www.vulncheck.com/advisories/gitpython-before-path-traversal-via-gitmodules-submodule-name](https://www.vulncheck.com/advisories/gitpython-before-path-traversal-via-gitmodules-submodule-name)
