Junglewise Threat Intelligence

GitPython command injection in Repo.init via template option

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

Executive brief

GitPython, a popular Python library for interacting with Git repositories, contains a vulnerability that allows for arbitrary command execution. If an application using this library allows a user to influence the parameters of a new repository initialization, an attacker can plant malicious scripts that run automatically during subsequent Git operations. This could lead to a full system compromise or unauthorized access to sensitive data handled by the application.

Technical details

A command injection vulnerability exists in GitPython's `Repo.init()` method due to improper neutralization of argument delimiters. The method forwards keyword arguments directly to the underlying `git init` command without validating them against a denylist of unsafe options. An attacker who can control the `template` argument can point it to a malicious directory containing executable Git hooks. These hooks are copied into the new repository's `.git/hooks` directory and executed during the next Git operation (e.g., a commit). The vulnerability also affects the `--separate-git-dir` option. This issue is patched in version 3.1.58.

Affected products

  • gitpython-developers GitPython <= 3.1.57

Timeline

  • 2026-08-04: disclosed
  • 2026-08-04: patched: Version 3.1.58 released
  • 2026-08-07: advisory

References