CVE-2026-87817: GitPython · Repository content can impersonate the git directory, leading to arbitrary code execution
Affects legitSource GCVE Database
Not known to be exploited · CVSS 8.7 High : upgrade to 1.2.0.post0_15 soon.
Data as of 26 Oct 2026, 19:12 UTC
- Patch
- Available – fixed in 1.2.0.post0_15
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:NExploitation evidence
Disclosed: evidence found.
CVE published 9 Sep 2026
Detectable: no evidence on record.
No public nuclei template indexed
Weaponised: no evidence on record.
No public exploit code indexed in Metasploit or Exploit-DB
Exploited in the wildExploited: no evidence on record.
Not in CISA KEV and no source reports exploitation
Observed by OffSeq MirageSeen by Mirage: no evidence on record.
No attack traffic recorded by OffSeq Mirage sensors
A missing step is not evidence of safety. Sources: cve.org (opens in a new tab), the Metasploit, Exploit-DB and nuclei-templates index as of 26 Oct 2026.
What to do
Upgrade legit to 1.2.0.post0_15.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
Homebrewlegitpkg:brew/legitOther threats | Affected
| Fixed in
|
Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.
AI-suggested
A fix is available in GitPython version 1.2.0.post0_15. Users and services relying on GitPython to open or clone untrusted repositories should upgrade to this fixed version. The fix involves changing the order of git directory detection to test the real .git directory first, validating HEAD contents, resolving hook paths through the common_dir, and disabling merge_includes in config reading. Until upgraded, avoid performing commits via GitPython on untrusted repositories to prevent code execution.
Description
GitPython version 3.1.59 contains a vulnerability where the repository's git directory is misresolved, allowing attacker-controlled repository content to impersonate the .git directory. This leads to arbitrary code execution when a victim performs a commit using GitPython's native index.commit() method. The vulnerability also allows reading sensitive files outside the repository and writing config files to attacker-chosen locations. The issue arises because GitPython tests candidate git directory paths in an order that considers the real .git directory last, causing it to treat the working tree root as the git directory if certain tracked files exist. This flaw affects services that open or clone untrusted repositories using GitPython. A fix is available in version 1.2.0.post0_15.
References
- github.com/gitpython-developers/GitPython/security/advisories/GHSA-239g-whfq-7xj9 (opens in a new tab)
- nvd.nist.gov/vuln/detail/CVE-2026-87817 (opens in a new tab)
- github.com/gitpython-developers/GitPython/pull/2218 (opens in a new tab)
- github.com/gitpython-developers/GitPython/commit/c7cf4d13b1ed0a2e70f2a1f3c6b4fc6c2652cf0b (opens in a new tab)
- github.com/gitpython-developers/GitPython (opens in a new tab)
- github.com/gitpython-developers/GitPython/releases/tag/3.1.60 (opens in a new tab)
- github.com/pypa/advisory-database/tree/main/vulns/gitpython/PYSEC-2026-3982.yaml (opens in a new tab)
- vulncheck.com/advisories/gitpython-before-3.1.60-remote-code-execution-via-git-directory-impersonation (opens in a new tab)