Junglewise Threat Intelligence

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

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

Technologies: GitPython Developers Gitpython. Vendors: Gitpython Project.

Executive brief

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.

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

Timeline

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

References

Related threats