/

CVE-2026-76221

Severity:

HIGH RISK

(8.8)

Git Config Injection (CWE-74) in GitPython Validator

CVE-2026-76221

Analyzed

Vulnerability type

Category:

Injection

CWE:

CWE-74

Impact:

Arbitrary Command 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.58 contains a config-name injection flaw in its option-name validation logic. If an attacker can influence an option name, they may inject Git configuration directives that cause command execution or alter Git behavior during a later repository operation.

Affected context

The vulnerability occurs in applications that use GitPython to construct or validate Git configuration option names from attacker-influenced input. The risk is highest when those names are written into Git configuration and a later Git operation honors settings such as core.sshCommand or core.hooksPath.

Exploit preconditions

  • Attack surface: Application code that passes externally influenced values into GitPython configuration option-name handling
  • Required access: Ability to influence or supply an option name, directly or through an application-controlled configuration workflow
  • Trigger point: A subsequent Git operation that reads and applies the forged configuration directive
  • Why exploitation is possible: Inadequate validation permits special characters, including equals signs, hash symbols, and whitespace, to change the structure and meaning of a configuration entry

Why this happens

The underlying bug is insufficient neutralization and validation of configuration option names. Characters that should remain data can instead introduce separators, comments, or additional configuration syntax, allowing an attacker-controlled name to become a forged Git directive. This behavior maps to CWE-74, Injection, because untrusted input is incorporated into a command or configuration language without enforcing a strict data-only representation.

Potential impact

  • Arbitrary commands may execute in the context of a later Git operation.
  • Repository contents or generated artifacts could be modified.
  • SSH behavior or hook execution could be redirected.
  • Credentials, tokens, or other process-accessible data could be exposed.
  • Build, deployment, or source-control workflows could be disrupted or compromised.

General mitigation guidance

Mitigation generally focuses on treating configuration option names as a strict

allowlisted data type rather than as free-form strings.

Common defensive patterns include:

  • Rejecting option names containing configuration syntax, separators, comments, or whitespace unless explicitly required.
  • Using structured configuration APIs that separate option names from values and do not concatenate raw input.
  • Allowing only a narrow set of expected option names and values.
  • Preventing untrusted users from controlling Git configuration or repository hook paths.
  • Running Git operations with least privilege, restricted filesystem access, and minimal environment secrets.
  • Isolating repository-processing jobs and disabling unnecessary hooks or command overrides by policy.

How teams detect issues like this

Organizations can look for this issue through:

  • Static analysis rules identifying dynamically constructed Git configuration names.
  • Code review checks for string concatenation involving option names, equals signs, comments, or whitespace.
  • Tests that submit malformed and delimiter-containing names and verify strict rejection.
  • Runtime monitoring for unexpected core.sshCommand, core.hooksPath, or other command-related Git settings.
  • Policy enforcement that restricts repository hooks, SSH command overrides, and configuration writes in automated jobs.
  • Automated security review tools that flag injection-prone configuration APIs and missing allowlists.

Sources

SourceLink
github.comgithub.com/gitpython-developers/GitPython/security/advisories/GHSA-jm78-9fvv-mhgr
vulncheck.comvulncheck.com/advisories/gitpython-before-config-injection-via-option-name

Frequently asked

questions

It can be exploitable through a remote application interface when that interface

allows an attacker to influence Git configuration option names. Direct network

reachability to GitPython alone is not sufficient.

The attacker generally needs a data path that permits control of an option name or

configuration-writing input. The vulnerable directive must then be consumed by a

later Git operation.

Treat option names as structured, allowlisted data; reject configuration syntax and

avoid constructing Git directives from untrusted strings.

Apply strict input validation, use APIs that preserve the separation between names

and values, restrict hooks and command overrides, and execute repository operations

with minimal privileges and secrets.

Find out what's already
exploitable in your codebase.