/

CVE-2026-69097

Severity:

HIGH RISK

(7.0)

Config Injection (CWE-74) in GitPython Submodule Handling

CVE-2026-69097

Analyzed

Vulnerability type

Category:

Injection

CWE:

CWE-74

Impact:

Remote Code Execution via Config Injection

Severity:

HIGH RISK

(7.0)

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 fails to correctly escape submodule names when writing git configuration, allowing crafted names to inject arbitrary config directives into .git/config.

If an attacker can influence submodule names used in create_submodule or clone_from, they may insert dangerous keys like core.sshCommand and gain remote code execution when Git performs SSH operations.

Affected context

This vulnerability appears in applications and automation that rely on GitPython (before 3.1.53) to manage repositories and submodules.

It is relevant when:

  • GitPython processes repositories or submodules whose names are derived from untrusted or semi-trusted input
  • The resulting repositories are initialized with a .git/config that Git later uses for SSH or other external commands
  • Git operations like clone, fetch, or submodule commands trigger SSH connections based on configuration entries

Environments that automatically clone or register submodules provided by external parties are particularly exposed.

Exploit preconditions

  • Attack surface: GitPython-powered workflows that clone repositories or create submodules, including CI/CD pipelines, automation scripts, web services, and developer tools.
  • Required access: Ability to control or influence submodule names or repository content processed by GitPython (for example, by hosting a repository with malicious submodule entries or providing parameters that become submodule names).
  • Trigger point: Execution of GitPython operations such as create_submodule or clone_from that write to .git/config, followed by Git commands (often via GitPython or other tooling) that use SSH for remote operations.
  • Why exploitation is possible: Submodule names are written into the git config without robust escaping or validation of the section name context, enabling crafted names to break out of the intended section and inject arbitrary configuration directives like core.sshCommand.

Why this happens

The core issue maps to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component (Injection).

GitPython treats submodule names as data but fails to neutralize special characters significant to git config syntax when emitting them into .git/config.

As a result, an attacker-controlled submodule name can manipulate the structure of the generated configuration, effectively injecting new keys or altering existing ones.

When these injected keys influence command execution—for example, by overriding core.sshCommand—subsequent Git operations execute attacker-controlled commands, leading to code execution.

Potential impact

  • Remote code execution when Git performs SSH operations using an injected core.sshCommand
  • Execution of arbitrary system commands under the privileges of the process running GitPython
  • Compromise of CI/CD runners, build agents, or deployment pipelines that automatically process untrusted repositories
  • Exfiltration of sensitive repository data or credentials via malicious SSH commands
  • Lateral movement within environments where Git-based automation has elevated permissions

General mitigation guidance

Effective mitigation focuses on neutralizing untrusted values before they are written into configuration and reducing the trust placed in configuration-driven command execution:

  • Treat submodule names and other identifiers that flow into .git/config as untrusted input and apply strict validation (e.g., allowlists of safe characters and formats).
  • Normalize and escape configuration section names and keys using dedicated encoding/escaping routines rather than raw string interpolation.
  • Avoid allowing external or user-controlled input to influence critical config directives such as core.sshCommand, protocol.*, or other command-related keys.
  • Run GitPython-based automation under least-privilege accounts with constrained execution environments (e.g., restricted PATH, no unnecessary tools installed).
  • Where feasible, isolate repository processing in sandboxed environments or containers that limit the impact of command execution.

How teams detect issues like this

Detection can focus on both code patterns and runtime artifacts:

  • Static analysis and code review:
  • Search for GitPython calls (create_submodule, clone_from, or direct config writes) that take user or network-derived input as submodule names or config values.
  • Flag patterns where values are concatenated into config text or section names without escaping or validation.
  • Review glue code that writes .git/config or other Git configuration files manually.
  • Configuration and runtime inspection:
  • Periodically scan .git/config files in automated environments for unexpected or high-risk keys like core.sshCommand, url.*.insteadOf, or protocol.* originating from external repositories.
  • Monitor CI/CD logs for anomalous SSH command lines or unexpected Git behavior triggered during fetch/clone operations.
  • Policy enforcement:
  • Enforce policies that disallow or alert on dangerous Git configuration keys within automated workflows.
  • Integrate security-focused linters or SAST tools that understand GitPython usage patterns into CI pipelines.

Sources

SourceLink
github.comgithub.com/gitpython-developers/GitPython/security/advisories/GHSA-3rp5-jjmw-4wv2
vulncheck.comvulncheck.com/advisories/gitpython-before-config-injection-via-submodule-names

Frequently asked

questions

Yes, in many setups it can be. If an application or CI pipeline automatically clones or processes repositories controlled by an attacker, and uses GitPython to handle submodules, the attacker can remotely deliver malicious submodule names that lead to configuration injection and eventual code execution.

The attacker needs the ability to influence the submodule names or repository metadata processed by GitPython—typically by hosting or supplying a repository that the victim system clones or interacts with. Direct shell access is not required; control over repository content or parameters is sufficient in many scenarios.

The safest pattern is to ensure that any value written into git configuration is strictly validated and safely encoded. This includes:

  • Enforcing rigid, allowlist-based validation on submodule names and related identifiers.
  • Using APIs or helpers that correctly escape git config section names and keys rather than constructing them manually.
  • Preventing untrusted inputs from influencing high-impact configuration keys like core.sshCommand.

  • Treat all data that may end up in configuration files as potentially hostile and apply input validation and output encoding appropriate to the target format.
  • Perform regular security reviews of tooling that bridges user input into configuration or command execution, including libraries like GitPython.
  • Add automated checks in CI for dangerous git config keys and for unsafe patterns in code that generates configuration.
  • Design systems so that configuration changes alone cannot trivially escalate to arbitrary command execution by limiting what configuration options are honored and by running automation with least privilege.
Find out what's already
exploitable in your codebase.