Arbitrary Code Injection Affecting gitpython package, versions [,3.1.60)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.31% (24th 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 Code Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-GITPYTHON-19653595
  • published9 Sept 2026
  • disclosed9 Sept 2026
  • creditdharanivarma

Introduced: 9 Sep 2026

NewCVE-2026-87817  (opens in a new tab)
CWE-94  (opens in a new tab)

How to fix?

Upgrade GitPython to version 3.1.60 or higher.

Overview

GitPython is a python library used to interact with Git repositories

Affected versions of this package are vulnerable to Arbitrary Code Injection through Repo.__init__ and is_git_dir in git/repo/base.py and git/repo/fun.py. An attacker can execute arbitrary commands by supplying a repository whose tracked root files make GitPython treat the working-tree root as the git directory and then placing a malicious hooks/pre-commit there. When a victim opens or clones that repository and later calls repo.index.commit(), GitPython resolves the hook path inside attacker-controlled content instead of the real .git directory. That causes the pre-commit hook to run in the victim’s process, breaking the integrity of local repository operations.

Workarounds

  • Do not open or clone untrusted repositories with GitPython unless you trust their tracked root files; attacker-controlled HEAD, gitdir, commondir, and hooks/ content can be treated as repository metadata and lead to hook execution.
  • Avoid calling repo.index.commit() on repositories sourced from untrusted content; this is the operation that can execute a malicious tracked hooks/pre-commit in the victim process.

CVSS Base Scores

version 4.0
version 3.1