Arbitrary Argument Injection Affecting gitpython package, versions [,3.1.51)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
1.02% (60th percentile)

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 Arbitrary Argument Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-GITPYTHON-18170201
  • published22 Jul 2026
  • disclosed21 Jul 2026
  • creditmiauzxw

Introduced: 21 Jul 2026

NewCVE-2026-67323  (opens in a new tab)
CWE-77  (opens in a new tab)
CWE-88  (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 Arbitrary Argument Injection via the Repo.archive(), Repo.iter_commits(), Repo.blame(), and Git.ls_remote() call paths in git/repo/base.py, git/objects/commit.py, and git/cmd.py. An attacker can execute arbitrary Git helpers or clobber files by supplying unsafe archive/ls-remote options or a revision string such as --output=/path to iter_commits() or blame(). In Repo.archive(), caller-controlled keyword arguments are forwarded into git archive, allowing options like --exec or --output; in Git.ls_remote(), upload_pack is turned into --upload-pack without rejection. In Repo.iter_commits() and Repo.blame(), a revision value placed before -- is parsed as a Git option, letting an attacker trigger file truncation or overwrite before revision parsing fails.

Notes

  • Repo.archive() is only dangerous when callers forward user-influenced remote, exec, or output values; the write-up’s command-execution and file-clobber behavior depends on those arguments being passed through as archive options, not on ordinary tree export use.
  • Repo.iter_commits() and Repo.blame() are exposed to the overwrite primitive when the revision string or rev_opts can begin with -; the affected path is the revision parser’s pre--- handling, so applications that only pass fixed refs or validated commit IDs miss the issue.

Workarounds

  • Use allow_unsafe_options=False (the default) on Repo.archive(), Repo.iter_commits(), Repo.blame(), and git.ls_remote() and do not pass user-controlled options such as exec, output, rev_opts, or upload_pack; this blocks attacker-supplied Git flags from reaching helper execution or file-overwrite options.
  • Set allow_unsafe_protocols=False on Repo.archive() and avoid remote= values that resolve to unsafe protocols such as ext::...; this prevents git archive from invoking an arbitrary remote helper path.

CVSS Base Scores

version 4.0
version 3.1