Command Injection Affecting gitpython package, versions [3.1.50,3.1.51)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Command Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-GITPYTHON-18170134
  • published22 Jul 2026
  • disclosed21 Jul 2026
  • creditFaze-up

Introduced: 21 Jul 2026

New CVE NOT AVAILABLE CWE-78  (opens in a new tab)

How to fix?

Upgrade GitPython to version 3.1.51 or higher.

Overview

GitPython is a python library used to interact with Git repositories

Affected versions of this package are vulnerable to Command Injection via the _canonicalize_option_name function in git/cmd.py. An attacker can execute a local helper command by supplying joined short clone options such as -u<upload-pack> or -c<config> through Repo.clone_from(..., multi_options=...) while allow_unsafe_options=False is in effect. The vulnerable normalization path only stripped the leading dash and compared the full joined token, so -u/path/to/helper did not match the blocked -u option even though Git treats it as --upload-pack=<helper>. This lets attacker-controlled clone options run the helper during repository cloning, bypassing GitPython’s default unsafe-option protection and causing arbitrary local command execution on the host that performs the clone.

Notes

  • The bypass only matters for callers feeding attacker-controlled values into multi_options; ordinary upload_pack= / config= keyword arguments are a separate path and are not the trigger here.
  • The vulnerable normalization also missed joined short forms with embedded values such as -u<helper> and -c<key>=<value>; long forms like --upload-pack=... were already handled by the unsafe-option list.

Workarounds

  • Ensure untrusted input is not passed into Repo.clone_from(..., multi_options=...); restrict multi_options to trusted, application-defined values so an attacker cannot supply joined short clone options like -u<helper> or -c<key>=<value> to trigger helper execution during clone.

CVSS Base Scores

version 4.0
version 3.1