Junglewise Threat Intelligence

GitPython arbitrary file read via pathspec parameters

Severity: medium · CVSS 6.5 · Published 2026-08-19

Executive brief

GitPython is a widely-used library for programmatic interaction with Git repositories. A vulnerability in versions prior to 3.1.58 allows attackers with low privileges to read arbitrary files on the system by passing specially-crafted parameters to file removal and branch checkout operations. The entire contents of readable files are disclosed in error messages that applications may log or display, potentially exposing sensitive data like configuration files or credentials.

Technical details

The vulnerability exists in IndexFile.remove() and Head.checkout() methods, which forward user-supplied keyword arguments directly to git rm and git checkout without validation. An attacker can supply --pathspec-from-file and --pathspec-file-nul parameters to cause Git to treat an entire file as a single pathspec. When the pathspec fails to match any tracked file, Git quotes the full file contents in an error message, which GitPython surfaces through GitCommandError.stderr. This is a CWE-73 (External Control of File Name or Path) and CWE-200 (Exposure of Sensitive Information) vulnerability. The attack requires low privileges (ability to invoke the library) and network reachability to a vulnerable application; no user interaction is required. The file must be readable by the process and must not match a tracked file path. A patch is available in GitPython 3.1.58 and later.

Affected products

  • GitPython Contributors GitPython < 3.1.58

Timeline

  • 2026-08-04: disclosed
  • 2026-08-04: patched: Fix available in GitPython 3.1.58

References