GitPython arbitrary file read via pathspec parameters

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

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.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Medium severity, with a CVSS score of 6.5, published 19 August 2026.
Which products and versions are affected?
GitPython Contributors GitPython < 3.1.58.
Is there a fix for This vulnerability?
A patch was published on 2026-08-04: Fix available in GitPython 3.1.58 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network.
Am I affected?
Check whether anything you run is named in the advisory. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

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

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.