/

CVE-2026-67325

Severity:

HIGH RISK

(8.8)

Command Injection (CWE-78) via Git Option Abbreviation

CVE-2026-67325

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

GitPython before 3.1.51 contains a command injection weakness where its blocklist of dangerous git options does not account for git's long-option prefix abbreviation feature.

An attacker who can influence git command arguments may bypass the guard using abbreviated option names, leading git to resolve them to unsafe options and execute arbitrary commands.

Affected context

This vulnerability appears in applications that use GitPython to invoke git commands while relying on its built-in blocklist to filter dangerous options.

It becomes relevant when user-controlled or untrusted input can affect git subcommands or their options, and the environment uses a git version that supports long-option prefix abbreviation.

The issue is most acute in server-side or automated workflows where git operations are triggered based on external input, such as web hooks, API requests, or CI jobs.

Exploit preconditions

  • Attack surface: Interfaces that accept or derive git command arguments from untrusted or semi-trusted sources (e.g., repository URLs, refs, or user-specified options).
  • Required access: Ability to control or influence git options passed through GitPython, directly or indirectly, without strict validation or whitelisting.
  • Trigger point: Execution of a git command via GitPython where the blocklist attempts to filter dangerous options but is bypassed by using abbreviated long options such as upload_p.
  • Why exploitation is possible: The blocklist assumes full option names, while git accepts unique long-option prefixes and maps them to the corresponding dangerous options, allowing attackers to reach blocked behavior.

Why this happens

The underlying bug is an incomplete validation of command-line options used to construct git invocations.

GitPython implements a guard that blocks specific dangerous long options (such as --upload_pack) but assumes those options must be spelled out fully.

Git, however, treats unique prefixes of long options as equivalent, so abbreviated forms bypass the blocklist and are still treated as dangerous options by git.

This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, where input that influences command-line execution is validated using assumptions that do not match the actual behavior of the underlying command processor.

Potential impact

  • Attackers can trigger execution of arbitrary commands via git's dangerous helper options.
  • Compromise of the host running GitPython-based applications, including remote code execution in application or CI environments.
  • Unauthorized access to repositories, modification of code, or exfiltration of configuration and secrets reachable by the process.
  • Lateral movement within the environment if the compromised process has network or system-level privileges.

General mitigation guidance

Effective mitigation typically focuses on strict control of arguments passed to git and alignment between validation logic and the tool's actual behavior.

Common defensive patterns include:

  • Replacing blocklists with explicit allowlists of safe subcommands and options.
  • Normalizing or fully resolving long options before validation, ensuring that abbreviations cannot bypass checks.
  • Separating untrusted input from command construction by using structured APIs rather than raw command-line composition.
  • Running git operations under least-privilege accounts and isolating them via sandboxing, containers, or restricted execution environments.
  • Avoiding exposure of git options or subcommands directly to end users where possible, instead offering higher-level, constrained operations.

How teams detect issues like this

Detection efforts can prioritize both code-level and runtime indicators:

  • Static analysis rules that flag manual command construction, concatenation of user-controlled strings into git commands, or reliance on blocklists for dangerous options.
  • Code reviews focused on points where GitPython is used with user-influenced parameters, checking for strict allowlists and awareness of git's option abbreviation behavior.
  • Security policies in CI/CD pipelines that enforce patterns such as "no raw shell calls with user input" and "only whitelisted git operations allowed."
  • Use of automated security scanners or linters that recognize CWE-78 patterns in Python code, especially around subprocess calls and wrapper libraries.

Sources

SourceLink
github.comgithub.com/gitpython-developers/GitPython/security/advisories/GHSA-2f96-g7mh-g2hx
vulncheck.comvulncheck.com/advisories/gitpython-before-command-injection-via-option-prefix-abbreviation

Frequently asked

questions

It can be remotely exploitable when an application exposes git-related functionality over a network interface (such as HTTP APIs, web hooks, or automation endpoints) that passes user-controlled parameters into GitPython without robust validation.

An attacker needs the ability to influence git command arguments, options, or parameters used by GitPython—typically via user input, configuration fields, or repository metadata processed by the application.

The safest pattern is to adopt strict allowlists of permitted git subcommands and options, normalize or expand long options before validation, and avoid relying on blocklists alone, ensuring that no user input can introduce unexpected options.

Preventing similar issues involves designing interfaces that never pass raw, user-controlled input directly into command lines, using structured APIs, enforcing allowlists, validating assumptions about underlying tools (such as option abbreviation behavior), and integrating secure coding reviews or automated checks into the development lifecycle.

Find out what's already
exploitable in your codebase.