# CVE-2026-78676: GitPython config parser multi-line value injection in write

Source: https://junglewise.ai/threats/cve-2026-78676-gitpython-config-parser-multi-line-value-injection-in-write  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-08-25. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2026-78676 · Severity: critical · CVSS 9.8 · Published 2026-08-25

GitPython's configuration file parser incorrectly re-serializes multi-line git config values when writing back to disk, converting legitimately-encoded dormant values into active configuration directives. An attacker can pre-position a malicious value in a repository's git config file (or via the standard git include mechanism) that becomes a live `core.hooksPath` directive after any unrelated GitPython write operation, leading to arbitrary code execution when git invokes hooks during commit, checkout, or other operations.

Technologies: [Gitpython Project Gitpython](https://junglewise.ai/threats/technologies/gitpython), [gitpython (PyPI)](https://junglewise.ai/threats/technologies/pypi-gitpython). Vendors: [Gitpython Project](https://junglewise.ai/threats/vendors/gitpython-project), [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2026-78676 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-78676 being exploited in the wild.

**How severe is CVE-2026-78676?** Critical severity, with a CVSS score of 9.8, published 25 August 2026.

**Which products and versions are affected?** gitpython (PyPI) ECOSYSTEM:introduced=0,fixed=3.1.59.

**Is there a fix for CVE-2026-78676?** Yes. gitpython (PyPI): upgrade to 3.1.59 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-78676 attacked?** It is attacked over the network or with local access, in a software library.

**Am I affected by CVE-2026-78676?** Check whether you run Gitpython Project Gitpython or gitpython (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- gitpython (PyPI): upgrade to 3.1.59 or later

  ```sh
  pip install "gitpython>=3.1.59"
  ```


## Technical details

The vulnerability is a read-then-corrupt-on-rewrite defect in git/config.py's GitConfigParser class. When reading config files, GitConfigParser._read() correctly decodes standard git multi-line syntax (backslash-continuation with escaped newlines) via string_decode() (line 460), converting escape sequences like `\n` into real embedded newlines in memory—this is legitimate and mirrors git's own behavior. However, when flushing the parser via _write()/write_section() (lines 694–712), the code uses the unsafe _value_to_string() path (not _value_to_string_safe()) and "handles" embedded newlines with a bare `.replace("\n", "\n\t")`, emitting an unquoted real newline followed by a tab. Real git does not recognize indentation-only continuation; a value only continues across lines if the prior line ends in a literal backslash. Thus, when GitPython re-serializes a multi-line value this way, the second "line" becomes an independent config entry on re-parse. If that dormant value contains `<anything>\nhooksPath = <attacker-path>`, it becomes a live core.hooksPath directive after one write, executing arbitrary hooks. The root cause is asymmetric: earlier fixes (c417af46, PR #2176) added UNSAFE_CONFIG_CHARS_RE guards to all setter-argument entry points but explicitly did not address values already resident in _sections via _read(). Exploitation requires only an attacker-influenced config file plus one ordinary config write—no unsafe caller argument is needed. Attack vector is network/local depending on how the config file is obtained; preconditions include read-write access to the parser and a dormant payload in the file.

## Affected products

- GitPython Developers GitPython <= 3.1.58

## Identifiers

- CVE-2026-78676
- GHSA-284h-m62q-gf8w
- PYSEC-2026-3786

## Timeline

- 2026-08-10: disclosed
- 2026-09-08: advisory
- 2026-09-08: kev added

## References

- [https://api.github.com/users/Pig-Tail](https://api.github.com/users/Pig-Tail)
- [https://github.com/Pig-Tail](https://github.com/Pig-Tail)
- [https://api.github.com/users/Pig-Tail/gists%7B/gist_id%7D](https://api.github.com/users/Pig-Tail/gists%7B/gist_id%7D)
- [https://api.github.com/users/Pig-Tail/repos](https://api.github.com/users/Pig-Tail/repos)
- [https://avatars.githubusercontent.com/u/15832659?v=4](https://avatars.githubusercontent.com/u/15832659?v=4)
- [https://api.github.com/users/Pig-Tail/events%7B/privacy%7D](https://api.github.com/users/Pig-Tail/events%7B/privacy%7D)

## Related threats

- [GitPython command wrappers omit unsafe protocol and option checks](https://junglewise.ai/threats/cve-2026-110857-gitpython-command-wrappers-omit-unsafe-protocol-and-option)
- [GitPython submodule path traversal to arbitrary hook execution](https://junglewise.ai/threats/cve-2026-114145-gitpython-is-a-python-library-used-to-interact-with-git)
- [GitPython symlink following in Submodule.move()](https://junglewise.ai/threats/cve-2026-110860-gitpython-from-3-1-62-before-3-2-0-contains-a-symlink-following)
- [GitPython argument injection in Head.checkout()](https://junglewise.ai/threats/cve-2026-110859-gitpython-before-3-2-0-contains-an-argument-injection)
- [GitPython remote code execution in Remote.pull() refspec argument](https://junglewise.ai/threats/cve-2026-110858-gitpython-from-3-1-30-before-3-2-0-contains-a-remote-code)
