# GitPython git directory validation bypass allowing arbitrary code execution

Source: https://junglewise.ai/threats/duplicate-advisory-repository-content-can-impersonate-the-git-directory-71186b92  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-09-09. Updated: 2026-10-01  
License: CC BY 4.0 with a link back

Severity: high · CVSS 8.8 · Published 2026-09-09

GitPython is a Python library for interacting with Git repositories. A flaw in directory validation allows an attacker to trick GitPython into treating attacker-controlled tracked files as the git directory, enabling execution of arbitrary code via malicious pre-commit hooks when a victim commits to a cloned or opened repository.

Technologies: [GitPython Developers GitPython](https://junglewise.ai/threats/technologies/gitpython-developers-gitpython), [gitpython (PyPI)](https://junglewise.ai/threats/technologies/pypi-gitpython). Vendors: [GitPython Developers](https://junglewise.ai/threats/vendors/gitpython-developers), [PyPI](https://junglewise.ai/threats/vendors/pypi).

## 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.8, published 9 September 2026.

**Which products and versions are affected?** GitPython Developers GitPython <= 3.1.59; gitpython (PyPI) <= 3.1.59.

**Is there a fix for This vulnerability?** A patch was published on 2026-09-09: Version 3.1.60 or later 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 Developers GitPython or gitpython (PyPI) 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

GitPython fails to properly validate git directory location by testing candidate paths in an unsafe order, checking tracked files (gitdir, commondir, HEAD) before the actual .git directory. This allows attackers to place malicious pre-commit hooks in the repository root that execute when index.commit() is called. The vulnerability affects versions up to 3.1.59 and requires user interaction (calling commit on a cloned or opened repository).

## Affected products

- GitPython developers GitPython <= 3.1.59

## Timeline

- 2026-08-26: disclosed
- 2026-09-09: advisory
- 2026-09-09: patched: Version 3.1.60 or later

## References

- [https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-239g-whfq-7xj9](https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-239g-whfq-7xj9)

## Related threats

- [GitPython command wrappers omit unsafe protocol and option checks](https://junglewise.ai/threats/cve-2026-110857-gitpython-command-wrappers-omit-unsafe-protocol-and-option)
- [GitPython submodule path traversal to arbitrary hook execution](https://junglewise.ai/threats/cve-2026-114145-gitpython-is-a-python-library-used-to-interact-with-git)
- [GitPython symlink following in Submodule.move()](https://junglewise.ai/threats/cve-2026-110860-gitpython-from-3-1-62-before-3-2-0-contains-a-symlink-following)
- [GitPython argument injection in Head.checkout()](https://junglewise.ai/threats/cve-2026-110859-gitpython-before-3-2-0-contains-an-argument-injection)
- [GitPython remote code execution in Remote.pull() refspec argument](https://junglewise.ai/threats/cve-2026-110858-gitpython-from-3-1-30-before-3-2-0-contains-a-remote-code)
