Junglewise Threat Intelligence

CVE-2026-87818: GitPython argument injection in diff API via --no-index

CVE-2026-87818 · Severity: medium · CVSS 6.5 · Published 2026-09-09

Technologies: GitPython Developers Gitpython. Vendors: PyPI, Gitpython Project.

Executive brief

GitPython is a popular library that allows developers to interact with Git repositories programmatically. Version 3.1.59 fails to properly restrict dangerous command-line options in its diff API, allowing attackers to read arbitrary files from the system if an application exposes the diff results to user input. By repeatedly querying files with specific patterns, attackers can extract sensitive single-line secrets like passwords or tokens through careful observation of success or error responses.

Technical details

The vulnerability is an argument injection flaw (CWE-88) in GitPython's high-level diff API. The library failed to classify the --no-index option as unsafe when allow_unsafe_options=False (the default). The --no-index flag changes Git's interpretation of path arguments from repository-relative pathspecs to arbitrary filesystem paths. When combined with the still-allowed -I/--ignore-matching-lines option, attackers can create a content-dependent Boolean oracle: matching patterns return success with an empty DiffIndex, while non-matching patterns raise GitCommandError with exit code 1. An embedding application that forwards user-influenced diff options and paths while exposing this success/error distinction can be repeatedly queried to recover single-line secrets. The attack requires the attacker to influence diff options, both path operands, and repeated requests, but no authentication or special privileges. A fix (version 3.1.60+) classifies --no-index as unsafe unless explicitly allowed.

Affected products

  • GitPython Developers GitPython 3.1.59

Timeline

  • 2026-08-26: disclosed: GitHub Security Advisory GHSA-whh4-5q6c-9v3x published
  • 2026-09-09: advisory: CVE-2026-87818 published on NVD

References

Related threats