CVE-2026-78676 Overview
CVE-2026-78676 is a critical remote code execution vulnerability in GitPython versions before 3.1.59. The library fails to safely re-serialize multi-line git-config values during write operations. This flaw corrupts dormant quoted values into injected directives such as core.hooksPath. Attackers can craft config files with embedded newlines that become live git directives after any unrelated GitPython config write. Successful exploitation enables arbitrary code execution through hook invocation. The issue is tracked under CWE-88: Argument Injection or Modification and disclosed in GitHub Security Advisory GHSA-284h-m62q-gf8w.
Critical Impact
Attackers can achieve remote code execution on hosts running GitPython by planting a malicious .gitconfig that activates after any subsequent config write.
Affected Products
- GitPython versions prior to 3.1.59
- Python applications and CI/CD pipelines that use GitPython to read or write git configuration
- Automated tooling that operates on untrusted repositories via GitPython
Discovery Timeline
- 2026-08-25 - CVE-2026-78676 published to NVD
- 2026-08-26 - Last updated in NVD database
Technical Details for CVE-2026-78676
Vulnerability Analysis
GitPython provides a Python interface to git repositories, including read and write access to git configuration files. The library uses a config parser that reads existing values, applies modifications, and re-serializes the full configuration back to disk. The re-serialization routine does not correctly escape or reject multi-line values containing embedded newline characters.
When a quoted value in an existing config contains a newline, GitPython preserves the value on read but writes it back without the surrounding quotes or escape handling. The written form places the payload after the newline on its own line, where the git config parser interprets it as a new directive. This transforms an inert quoted string into an active configuration entry such as core.hooksPath = /tmp/attacker.
Once core.hooksPath points to an attacker-controlled directory, subsequent git operations invoke hook scripts from that path. GitPython or the underlying git binary then executes attacker code in the context of the current user.
Root Cause
The root cause is unsafe re-serialization of git-config values in GitPython's config writer. The writer does not validate that values remain single-line after quote stripping. This mismatch between the parser's quote-aware read and the writer's naive output allows argument injection at write time.
Attack Vector
An attacker plants a crafted .gitconfig, .git/config, or included config file containing a quoted multi-line value. The value stays dormant until any process invokes GitPython to write to that configuration. On the next write, GitPython emits the payload as a live directive, enabling core.hooksPath hijacking and subsequent code execution during any git operation. Delivery vectors include malicious repositories cloned by CI runners, developer workstations, and shared build agents.
No verified exploit code is publicly available. See the VulnCheck advisory on GitPython config injection for further technical detail.
Detection Methods for CVE-2026-78676
Indicators of Compromise
- Unexpected core.hooksPath entries in .git/config, .gitconfig, or included config files
- Newly created hook scripts (pre-commit, post-checkout, post-merge) in non-standard directories
- GitPython process trees spawning shells or interpreters immediately after git operations
- Config files containing quoted values with embedded newline bytes (0x0A)
Detection Strategies
- Scan repositories and user home directories for git-config values that contain literal newlines inside quoted strings
- Alert on writes to .git/config or .gitconfig by Python processes importing git or GitPython
- Correlate GitPython execution with subsequent child processes launched from non-standard hook paths
- Compare pre- and post-write hashes of config files touched by GitPython-backed automation
Monitoring Recommendations
- Monitor CI/CD build agents for changes to hook directories and core.hooksPath settings
- Log all invocations of GitPython in security-sensitive automation with argument capture
- Track outbound network connections initiated by processes spawned from git hooks
How to Mitigate CVE-2026-78676
Immediate Actions Required
- Upgrade GitPython to version 3.1.59 or later across all environments
- Audit CI/CD runners, developer laptops, and shared build hosts for tampered .gitconfig files
- Reset core.hooksPath to a known-good value and remove unexpected hook scripts
- Restrict GitPython automation to trusted repositories and disable execution on untrusted input where feasible
Patch Information
The fix ships in GitPython 3.1.59. Refer to GitHub Security Advisory GHSA-284h-m62q-gf8w for the vendor advisory and patch commit references. Rebuild container images and pin the fixed version in requirements.txt, pyproject.toml, or equivalent dependency manifests.
Workarounds
- Avoid using GitPython's config write APIs on configuration files sourced from untrusted repositories
- Run GitPython automation under least-privilege service accounts with no interactive shell access
- Set GIT_CONFIG_NOSYSTEM=1 and use core.hooksPath overrides pointing to a read-only, vetted directory
- Validate repository config files for embedded newlines in quoted values before any GitPython write operation
# Configuration example
pip install --upgrade 'GitPython>=3.1.59'
pip show GitPython | grep -i version
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

