Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2026-76217

CVE-2026-76217: GitPython Information Disclosure Flaw

CVE-2026-76217 is an information disclosure vulnerability in GitPython that allows attackers to read arbitrary files through malicious git command parameters. This article covers technical details, affected versions, and mitigation.

Updated:

CVE-2026-76217 Overview

CVE-2026-76217 is an arbitrary file read vulnerability in GitPython versions before 3.1.58. The library fails to validate options passed to git rm and git checkout commands within the IndexFile.remove() and Head.checkout() methods. Attackers who can influence pathspec arguments can supply the --pathspec-from-file and --pathspec-file-nul parameters to read arbitrary files accessible to the process. Full file contents are then returned inside the GitCommandError.stderr attribute when the underlying Git command fails.

The issue is categorized under [CWE-73] (External Control of File Name or Path) and affects any Python application that passes untrusted input to the affected GitPython methods.

Critical Impact

Remote attackers with low privileges can read arbitrary files, including credentials, configuration, and source code, on systems where applications pass untrusted pathspec input to GitPython.

Affected Products

  • GitPython versions before 3.1.58
  • Python applications using IndexFile.remove() with attacker-influenced pathspec input
  • Python applications using Head.checkout() with attacker-influenced pathspec input

Discovery Timeline

  • 2026-08-19 - CVE-2026-76217 published to the National Vulnerability Database (NVD)
  • 2026-08-19 - Last updated in NVD database

Technical Details for CVE-2026-76217

Vulnerability Analysis

GitPython is a Python library used to interact with Git repositories. The vulnerability exists in two methods that forward user-supplied arguments to the underlying git binary without filtering Git command-line options.

The IndexFile.remove() method wraps git rm, and Head.checkout() wraps git checkout. Both accept pathspec arguments that are passed directly to the Git subprocess. Git itself supports options such as --pathspec-from-file=<file> and --pathspec-file-nul, which instruct Git to read pathspec entries from a file on disk.

When an attacker supplies --pathspec-from-file=/etc/passwd as a pathspec value, Git opens the target file and attempts to parse its contents as pathspecs. Because the contents are not valid Git pathspecs, Git raises an error and echoes the offending content back through stderr. GitPython captures this output and exposes it via the GitCommandError.stderr attribute, giving the attacker the full file contents.

Root Cause

The root cause is missing argument validation. GitPython does not distinguish between pathspec values and option flags. Any argument beginning with -- is forwarded to Git verbatim, enabling option injection into git rm and git checkout invocations.

Attack Vector

Exploitation requires an application to pass attacker-controlled input into IndexFile.remove() or Head.checkout() as a pathspec. Typical scenarios include web services that accept repository paths, file names, or branch operations from users. The attacker submits --pathspec-from-file=<target> in place of a normal path. The application invokes GitPython, Git reads the target file, and the resulting GitCommandError.stderr returns the file contents to the attacker channel, whether that is a log, an HTTP response, or an exception trace.

For technical details, see the GitHub Security Advisory and the VulnCheck Advisory.

Detection Methods for CVE-2026-76217

Indicators of Compromise

  • Process execution of git rm or git checkout with arguments containing --pathspec-from-file or --pathspec-file-nul.
  • Application logs or exception traces containing raw contents of sensitive files such as /etc/passwd, .env, or SSH private keys inside GitCommandError output.
  • HTTP responses from Git-backed services echoing filesystem content in error messages.

Detection Strategies

  • Instrument Python applications to log the full argument list passed to GitPython methods, and alert on any argument beginning with --pathspec.
  • Monitor child process creation of git on application hosts and flag command lines containing --pathspec-from-file= or --pathspec-file-nul.
  • Perform software composition analysis (SCA) on Python dependencies to identify GitPython installations below version 3.1.58.

Monitoring Recommendations

  • Enable command-line auditing (auditd on Linux, Sysmon Event ID 1 on Windows) for the git binary and forward events to a centralized log platform.
  • Correlate git process arguments with parent Python processes to detect abuse originating from web application workers.
  • Track file access patterns to sensitive paths from Git subprocesses spawned by service accounts.

How to Mitigate CVE-2026-76217

Immediate Actions Required

  • Upgrade GitPython to version 3.1.58 or later in all Python environments and container images.
  • Audit application code for calls to IndexFile.remove() and Head.checkout() that accept untrusted input.
  • Rotate any credentials, tokens, or keys that may have been exposed via GitCommandError.stderr in logs or responses.

Patch Information

The GitPython maintainers addressed the issue in version 3.1.58 by validating pathspec arguments and rejecting option-like values. Refer to the GitHub Security Advisory GHSA-hh9p-6wh2-4mfc for the fix commit and release notes.

Workarounds

  • Sanitize pathspec input by rejecting any value that begins with -- before passing it to GitPython.
  • Prepend the -- end-of-options separator to pathspec argument lists so Git treats subsequent tokens as literal paths.
  • Run Git-invoking application workers under a low-privileged account with filesystem access limited to the repository directory.
  • Suppress GitCommandError.stderr from user-facing responses and logs to prevent leakage of any residual file content.
bash
# Configuration example: pin the patched GitPython version
pip install 'GitPython>=3.1.58'

# Verify the installed version
python -c "import git; print(git.__version__)"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.