CVE-2026-87817: GitPython git directory impersonation leading to code execution

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

GitPython is a Python library used to interact with Git repositories. An attacker can create a malicious repository with specially crafted files that trick GitPython into treating the repository's working directory as the Git control directory. When a developer or automated service clones or opens this repository and performs a commit operation, the attacker's code executes with the same privileges as the GitPython user, potentially compromising the entire system or exposing sensitive credentials.

Technologies: Gitpython Project Gitpython, gitpython (PyPI). Vendors: Gitpython Project, PyPI.

Quick answers

Is CVE-2026-87817 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-87817 being exploited in the wild.
How severe is CVE-2026-87817?
High severity, with a CVSS score of 8.8, published 9 September 2026.
Which products and versions are affected?
gitpython (PyPI) <= 3.1.59, ECOSYSTEM:introduced=0,fixed=3.1.60.
Is there a fix for CVE-2026-87817?
Yes. gitpython (PyPI): upgrade to 3.1.60 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-87817 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-87817?
Check whether you run Gitpython Project 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.

How to fix

  • gitpython (PyPI): upgrade to 3.1.60 or later
    pip install "gitpython>=3.1.60"

Technical details

GitPython's Repo.__init__ method determines the git directory by testing candidate paths in an order that prioritizes tracked files (gitdir, commondir, HEAD) before testing the actual .git directory. An attacker can create a repository with ordinary tracked files at the root directory that satisfy these checks, causing GitPython to resolve git_dir to the working tree instead of the real .git directory. This allows the attacker to place a malicious pre-commit hook in a tracked hooks/ directory that executes when index.commit() is called. The vulnerability also enables arbitrary file reads via the tracked config file (with merge_includes enabled) and arbitrary file writes through an attacker-controlled commondir path. The attack is "silent"—git clone exits successfully, git fsck reports nothing, and standard repository checks pass. GitPython versions before 3.1.60 are affected; the fix involves validating .git before other candidates, validating hook paths through common_dir, and disabling merge_includes in config parsing.

Affected products

  • GitPython Developers GitPython before 3.1.60

Identifiers

  • CVE-2026-87817
  • GHSA-239g-whfq-7xj9
  • PYSEC-2026-3982

Timeline

  • 2026-08-26: disclosed: GitHub Security Advisory (GHSA-239g-whfq-7xj9) published
  • 2026-09-09: advisory: CVE-2026-87817 published

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.