# GitPython path traversal in clone_from() and clone() via --separate-git-dir

Source: https://junglewise.ai/threats/gitpython-path-traversal-in-clone-from-and-clone-via-separate-git-dir-76bb0c2e  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-08-25. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: high · CVSS 7.5 · Published 2026-08-25

GitPython's clone_from() and clone() methods are missing a safety check for the --separate-git-dir option, which allows attackers to redirect Git repository metadata (the .git directory) to arbitrary filesystem paths outside the intended clone destination. An attacker who can control the separate_git_dir parameter can create malicious Git hook directories at arbitrary locations, potentially leading to arbitrary code execution if those hooks are later executed by other Git operations.

Technologies: [Gitpython Project Gitpython](https://junglewise.ai/threats/technologies/gitpython). Vendors: [Gitpython Project](https://junglewise.ai/threats/vendors/gitpython-project).

## 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 7.5, published 25 August 2026.

**Which products and versions are affected?** Gitpython Project Gitpython < 3.1.59.

**Is there a fix for This vulnerability?** A patch was published on 2026-08-10: GitPython 3.1.59 released with patch 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 you run Gitpython Project Gitpython at an affected version. 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 exists because Repo.unsafe_git_clone_options (the denylist checked before executing git clone) does not include --separate-git-dir, despite the parallel denylist Repo.unsafe_git_init_options correctly blocking it for git init, and despite the clone() docstring explicitly documenting it as unsafe when allow_unsafe_options=False (the default). The git clone command accepts --separate-git-dir=&lt;path&gt; to redirect the entire .git metadata directory to an attacker-controlled path, leaving only a gitlink file at the intended destination. An attacker who can pass a separate_git_dir kwarg into Repo.clone_from() or Repo.clone() bypasses the denylist check and causes GitPython to execute git clone --separate-git-dir=&lt;attacker-path&gt; via subprocess. This allows creation of arbitrary directory trees (including hooks/ subdirectories) at any writable filesystem path, and can collide with existing repositories or shared caches to contaminate their metadata. If a later Git operation runs against the redirected directory, attacker-planted hooks can execute arbitrary code. No authentication is required; this affects any application that forwards caller-influenced separate_git_dir values to the clone API without its own validation. A patch is available in GitPython 3.1.59.

## Affected products

- GitPython GitPython < 3.1.59

## Timeline

- 2026-08-10: disclosed: Original advisory GHSA-8mcc-hrx5-hvxc published
- 2026-08-25: advisory: Duplicate advisory GHSA-7r39-6q8m-qw68 published
- 2026-08-10: patched: GitPython 3.1.59 released with patch

## References

- [https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-8mcc-hrx5-hvxc](https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-8mcc-hrx5-hvxc)
- [https://www.vulncheck.com/advisories/gitpython-before-path-traversal-via-separate-git-dir](https://www.vulncheck.com/advisories/gitpython-before-path-traversal-via-separate-git-dir)

## Related threats

- [GitPython ReDoS via catastrophic backtracking in Actor.name_email_regex](https://junglewise.ai/threats/cve-2026-87819-gitpython-redos-via-catastrophic-backtracking-in-actor-name-email)
- [GitPython argument injection in diff API via --no-index](https://junglewise.ai/threats/cve-2026-87818-gitpython-argument-injection-in-diff-api-via-no-index)
- [GitPython git directory impersonation leading to code execution](https://junglewise.ai/threats/cve-2026-87817-gitpython-git-directory-impersonation-leading-to-code-execution)
- [GitPython arbitrary file read in Repo.blame via incomplete option denylist](https://junglewise.ai/threats/cve-2026-78678-gitpython-arbitrary-file-read-in-repo-blame-via-incomplete-option)
- [GitPython clone_from() omits --separate-git-dir from denylist](https://junglewise.ai/threats/cve-2026-78677-gitpython-clone-from-omits-separate-git-dir-from-denylist)
