CVE-2026-87817

GitPython before 3.1.60 Remote Code Execution via Git Directory Impersonation

Published Sep 9, 2026 CVSS 4.0 · 8.7 High EPSS < 1% KEV · Not listed
Description
GitPython before 3.1.60 fails to properly validate the git directory location, allowing attackers to impersonate the git directory using tracked files like gitdir, commondir, and HEAD. Attackers can execute arbitrary code by placing a malicious pre-commit hook in the tracked hooks directory that executes when a victim calls index.commit() on a cloned or opened repository.

Analysis

AI-generated

Technical impact

GitPython before 3.1.60 does not validate the location of the git directory, which lets an attacker impersonate the directory using tracked files such as gitdir, commondir, and HEAD. By placing a malicious pre‑commit hook in the tracked hooks directory, an attacker can cause arbitrary code execution when a victim runs index.commit() on a repository that the attacker controls. This flaw is an instance of the CWE‑94 code‑injection weakness and CWE‑22 directory traversal weakness.

Affected Systems

Affected vendors and products include the GitPython library developed by the GitPython developers. All versions prior to 3.1.60 are vulnerable.

Risk and Exploitability

The flaw carries a high CVSS score of 8.7, indicating significant risk for confidentiality, integrity, and availability. Because the EPSS score is not available, the exact likelihood of exploitation is uncertain, but the vulnerability is listed in no KEV catalog. Exploitation requires that the attacker can supply or influence the repository content that the application will commit; once the victim executes index.commit(), the malicious pre‑commit hook will run with the same privileges as the application. Therefore, the risk is high for systems that automatically commit untrusted code.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade GitPython to version 3.1.60 or later, which includes proper validation of git directory location.
  • Avoid performing commits on repositories that originate from untrusted sources or that can be modified by attackers.
  • If upgrading is not immediately possible, disable or sanitize pre‑commit hooks by configuring hook directories as read‑only or removing hooks from untrusted repositories before calling commit.

Generated by OpenCVE AI on September 10, 2026 at 02:03 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4872-1 python-git security update
Github GHSA Github GHSA GHSA-239g-whfq-7xj9 GitPython: Repository content can impersonate the git directory, leading to arbitrary code execution
History
Type Values Removed Values Added
CPEs cpe:2.3:a:gitpython_project:gitpython:*:*:*:*:*:python:*:*
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'none', 'Technical Impact': 'total'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Gitpython-developers
Gitpython-developers gitpython
Vendors & Products Gitpython-developers
Gitpython-developers gitpython
Type Values Removed Values Added
Description GitPython before 3.1.60 fails to properly validate the git directory location, allowing attackers to impersonate the git directory using tracked files like gitdir, commondir, and HEAD. Attackers can execute arbitrary code by placing a malicious pre-commit hook in the tracked hooks directory that executes when a victim calls index.commit() on a cloned or opened repository.
Title GitPython before 3.1.60 Remote Code Execution via Git Directory Impersonation
First Time appeared Gitpython Project
Gitpython Project gitpython
Weaknesses CWE-94
CPEs cpe:2.3:a:gitpython_project:gitpython:*:*:*:*:*:*:*:*
Vendors & Products Gitpython Project
Gitpython Project gitpython
References
Metrics cvssV3_1

{'score': 8.8, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H'}

cvssV4_0

{'score': 8.7, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N'}

Weaknesses
  • CWE-22

    Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

  • CWE-94

    Improper Control of Generation of Code ('Code Injection')

Sources

Status
PUBLISHED
Assigner
VulnCheck
Published
Updated
Oct 8, 2026, 3:25 PM
Reserved
Sep 9, 2026, 10:32 AM
Status
Analyzed
Published
Sep 9, 2026, 12:17 PM
Modified
Sep 16, 2026, 3:24 PM
Severity
Important
Public date
Sep 9, 2026, 11:21 AM