Junglewise Threat Intelligence

GitPython command injection via long-option prefix abbreviation bypass

Severity: high · CVSS 8.8 · Published 2026-07-21

Technologies: Gitpython-Developers Gitpython.

Executive brief

GitPython is a popular Python library used to interact with Git repositories. A security flaw allows an attacker to execute arbitrary commands on the system by providing specially crafted, abbreviated Git options (like 'upload_p' instead of 'upload-pack') to functions that perform clone, fetch, or push operations. This could lead to a full system takeover or unauthorized data access if the application processes untrusted input.

Technical details

GitPython implements a blocklist in `check_unsafe_options` to prevent the use of dangerous Git flags like `--upload-pack`. However, the validation logic uses exact string matching after a simple underscore-to-hyphen transformation. Because the underlying Git executable accepts any unambiguous prefix of a long option (e.g., `--upload-p` for `--upload-pack`), an attacker can bypass the blocklist by providing abbreviated keys. This leads to OS command injection when these keys are passed to Git subcommands such as clone, fetch, pull, or push. The vulnerability is present in versions up to 3.1.50 and is addressed in version 3.1.51.

Affected products

  • gitpython-developers GitPython <= 3.1.50

Timeline

  • 2026-07-12: disclosed
  • 2026-07-21: advisory
  • 2026-07-21: patched: Fixed in version 3.1.51

References