/

CVE-2026-44244

Severity:

HIGH RISK

(7.8)

Code Injection via Configuration Manipulation

CVE-2026-44244

Analyzed

Vulnerability type

Category:

Code Injection via Configuration Manipulation

CWE:

CWE-94

Impact:

Arbitrary Code Execution via Malicious Git Hooks

Severity:

HIGH RISK

(7.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's GitConfigParser.set_value() method allowed unvalidated configuration values containing newlines to be written into Git config files in a way that altered Git's interpretation of the file structure.

An attacker who can influence these configuration values may inject a new core.hooksPath setting and cause Git to execute arbitrary hook scripts from an attacker-controlled location whenever Git operations trigger hooks.

Affected context

This vulnerability affects applications and tools that:

  • Use GitPython prior to version 3.1.49
  • Call GitConfigParser.set_value() with data that may be influenced by external or untrusted sources
  • Persist Git configuration using GitPython, which is later consumed by Git itself

The issue appears where newline-containing values are written into Git configuration files, allowing Git to treat indented, attacker-crafted sections (such as [core]) as legitimate configuration headers.

Exploit preconditions

  • Attack surface: Applications that programmatically manage Git configuration using GitPython
  • Required access: Ability to supply or manipulate values passed into GitConfigParser.set_value() (e.g., via user input, configuration sync, or remote configuration sources)
  • Trigger point: Git operations that read the crafted configuration and invoke hooks (e.g., git commit, git merge, git checkout, or equivalent operations initiated through GitPython or command-line Git)
  • Why exploitation is possible: GitPython does not sanitize or reject newline characters in configuration values, and its internal _write() method turns embedded newlines into indented continuation lines. Git still accepts indented section headers like [core] as valid, so attacker-controlled values can smuggle new configuration directives (such as core.hooksPath) into the Git config, causing Git to load and execute hooks from attacker-specified paths.

Why this happens

The root cause lies in unsafe handling of configuration data that crosses a trust boundary between GitPython and Git's configuration parser.

GitConfigParser.set_value() forwards values to Python's configparser without validating or rejecting embedded newline characters. When GitPython writes these values out, its _write() implementation transforms newlines into indented continuation lines, but does not prevent them from being interpreted by Git as new section headers when they contain constructs like [core]. This effectively enables configuration injection, allowing the insertion of new Git configuration directives rather than just updating a single key.

Conceptually, this maps to CWE-94: Improper Control of Generation of Code ('Code Injection') because the attacker-controlled configuration influences which executable hook scripts Git loads and runs, turning injected configuration into a vehicle for arbitrary code execution.

Potential impact

  • Execution of arbitrary Git hook scripts from an attacker-controlled directory
  • Compromise of developer workstations or CI/CD runners that operate on repositories using the poisoned configuration
  • Unauthorized modification or exfiltration of source code during Git operations
  • Introduction of malicious behavior into build and release pipelines that rely on Git hooks
  • Lateral movement in environments where Git operations are automated and run under elevated privileges

General mitigation guidance

Effective mitigation centers on tightening how configuration values are accepted, normalized, and persisted:

  • Treat all configuration values that can influence executable paths (e.g., hooks, external tools) as high risk and avoid passing raw, unvalidated strings into GitConfigParser.set_value().
  • Normalize and sanitize configuration values by rejecting or escaping control characters such as newlines, carriage returns, and bracketed section headers within values.
  • Enforce strict separation between configuration keys and values, treating any attempt to inject "section-like" constructs (e.g., "[core]" or "key = value") within values as invalid.
  • Restrict or hard-code critical Git configuration fields (such as core.hooksPath) in security-sensitive contexts instead of deriving them from user-controllable input.
  • Run Git operations and hook execution under least-privilege accounts, and where possible, disable or tightly control custom hook locations in automated environments.
  • Introduce defense-in-depth input validation layers at the application boundary, ensuring that untrusted data is normalized before it ever reaches GitPython's configuration APIs.

How teams detect issues like this

Detection approaches can focus both on source-level patterns and runtime behavior:

  • Static analysis and code review:
  • Flag any calls to GitConfigParser.set_value() that accept direct user input or externally sourced values without validation or normalization.
  • Look for handling of configuration values that do not sanitize control characters (e.g., "\n", "\r", "[" or "]" sequences) before writing to Git configuration files.
  • Add review checklists that explicitly question whether configuration values can alter executable paths or hook locations.
  • Configuration auditing:
  • Periodically scan Git configuration files (system, global, and repository-local) for unexpected core.hooksPath settings, especially those pointing to unusual or user-writable directories.
  • Monitor for configuration entries containing suspicious continuation lines or malformed/indented section headers.
  • Runtime monitoring:
  • Log and monitor the locations from which Git hooks are executed in CI/CD and other automated environments, raising alerts on atypical directories.
  • Use host-based monitoring to detect new or modified hook scripts in non-standard paths.
  • Automated tooling:
  • Integrate security linters or custom static checks into CI pipelines to prevent unsafe configuration writing patterns from being merged.

Sources

SourceLink
github.comgithub.com/gitpython-developers/GitPython/releases/tag/3.1.49
github.comgithub.com/gitpython-developers/GitPython/security/advisories/GHSA-v87r-6q3f-2j67

Frequently asked

questions

It can be, depending on how GitPython is integrated. If an application exposes Git configuration operations to remote users or consumes remote data that flows into GitConfigParser.set_value(), an attacker may trigger configuration injection remotely. In purely local tooling where only trusted input is used, the practical risk is lower.

The attacker needs the ability to influence or control values passed into GitConfigParser.set_value(). This may be through direct user input, configuration synchronization mechanisms, or other external data sources that the application treats as trusted.

The safest pattern is to treat configuration as structured, non-executable data and strictly enforce that values cannot alter the structure of the configuration file. This includes disallowing newline and section-like constructs in values, constraining sensitive keys (such as core.hooksPath) to vetted, fixed values, and centralizing configuration writing through a well-reviewed, sanitizing API.

Preventing similar issues requires designing configuration handling with clear trust boundaries: validate and normalize all user-controllable configuration data, prohibit control characters and structural markers in values, avoid letting untrusted input influence paths used for code or script execution, and use automated checks and code review practices that treat configuration-writing logic as security-sensitive.

Find out what's already
exploitable in your codebase.