Kimi cli: GitPython: Repository content can impersonate the git directory, leading to arbitrary code execution (CVE-2026-87817)
Description
GitPython version 3.1.59 contains a vulnerability (CVE-2026-87817) where the library incorrectly resolves the git directory path by testing certain tracked files before the actual .git directory. This allows an attacker controlling a repository to craft files that impersonate the git directory, causing GitPython to treat attacker-controlled content as internal git data, including executable hooks. This leads to arbitrary code execution when the victim performs a commit via GitPython's index.commit() method. Additional impacts include unauthorized reading of files outside the repository and writing config files to attacker-chosen locations. The vulnerability affects services that open or clone untrusted repositories using GitPython. A patch is available to correct the directory resolution order and improve validation.
CVSS v3.1
Score 8.8high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
GitPython's Repo.__init__ method determines the git directory by testing candidate paths in an order that considers the real .git directory last. Early tests check for tracked files named gitdir, commondir, and HEAD, which are legal tracked files in git repositories. Because GitPython resolves git_dir to the working-tree root when these files exist, it treats attacker-controlled files as if they were inside the git directory, including hooks that it executes. This leads to arbitrary code execution when index.commit() is called. The vulnerability also allows reading files outside the repository via config includes and writing config files to attacker-chosen directories. The issue is present in GitPython 3.1.59 and was demonstrated with a proof-of-concept. Real git is unaffected. The vulnerability requires the victim to open or clone an attacker-controlled repository and perform a commit using GitPython. The vendor has provided remediation steps including reordering the directory checks, validating HEAD contents, and disabling merge_includes in config reading.
Potential Impact
An attacker controlling a repository that a victim opens or clones with GitPython 3.1.59 can execute arbitrary commands on the victim's system by placing malicious hooks in tracked files that GitPython misinterprets as internal git hooks. Additionally, the attacker can read sensitive files outside the repository by exploiting config includes and write configuration files to arbitrary locations. This can compromise CI runners, code scanning services, mirrors, dependency bots, and AI code-review tools that use GitPython to handle untrusted repositories. The vulnerability does not affect the real git client but only GitPython's library behavior.
Mitigation Recommendations
A patch is available for this vulnerability. Users should upgrade GitPython to a fixed version that tests the real .git directory before other candidate paths, validates HEAD contents, resolves hook paths correctly, and disables merge_includes in config reading. Until patched, avoid opening or cloning untrusted repositories with GitPython, and do not perform commits via GitPython's index.commit() on such repositories. Follow the vendor's advisory for the official fixed versions and remediation guidance.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- BREW-kimi-cli-CVE-2026-87817
- Osv Schema Version
- 1.7.3
- Ecosystems
- ["Homebrew"]
- Cvss Version
- 3.1
- State
- PUBLISHED
Threat ID: 6acaad8d2cdf04f65651436a
Added to database: 10/10/2026, 21:26:37 UTC
Last enriched: 10/10/2026, 21:32:02 UTC
Last updated: 10/10/2026, 21:32:02 UTC
Views: 5
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.