Junglewise Threat Intelligence

GitPython argument injection in IndexFile enables arbitrary file overwrite

Severity: high · CVSS 8.1 · Published 2026-08-07

Executive brief

GitPython is a popular Python library used to interact with Git repositories. A vulnerability in how it handles certain commands allows an attacker to overwrite or destroy any file on the system that the application has permission to access. This could lead to system instability, data loss, or the corruption of critical configuration files.

Technical details

An argument injection vulnerability exists in GitPython's IndexFile.from_tree, IndexFile.reset, and IndexFile.merge_tree methods. These methods fail to sanitize 'treeish' arguments before passing them to the underlying 'git read-tree' command and lack a '--' separator to demarcate positional arguments from options. An attacker can provide a string like '--index-output=/path/to/file' as a treeish argument, which the Git binary interprets as an instruction to write the index blob to that specific path, effectively overwriting any existing file. This exploit requires the attacker to have the ability to influence the arguments passed to these specific GitPython methods. The issue is fixed in version 3.1.58.

Affected products

  • gitpython-developers GitPython <= 3.1.57

Timeline

  • 2026-08-04: disclosed
  • 2026-08-07: advisory
  • 2026-08-07: patched: Fixed in version 3.1.58

References