VAITP Dataset

← Back to the dataset

CVE-2026-67326

GitPython 3.1.50+ allows newline injection in config_writer(), enabling malicious [core] sections for RCE.

  • CVSS 7.3
  • CWE-20
  • Input Validation and Sanitization
  • Local

GitPython before 3.1.50 fails to validate newline characters in the section parameter of config_writer(), allowing attackers to inject arbitrary section headers into .git/config. Attackers can inject newlines to create a forged [core] section with hooksPath pointing to attacker-controlled directories, achieving remote code execution when git hooks are triggered.

CVSS base score
7.3
Published
2026-08-01
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Local
Impact
Arbitrary Code Execution
Affected component
GitPython
Fixed by upgrading
Yes

Solution

Upgrade GitPython to 3.1.50 or newer.

Vulnerable code sample

import git
from git.repo import Repo

def write_git_config(repo_path: str, section: str, key: str, value: str) -> None:
    """
    Write a configuration entry into the repository's .git/config.
    """
    repo = Repo(repo_path)
    # VULNERABLE: accepts newline in section, allowing injection of arbitrary headers
    with repo.config_writer() as cw:
        cw.set_section(section)
        cw.set(key, value)

Patched code sample

import git
from git.repo import Repo

def write_git_config(repo_path: str, section: str, key: str, value: str) -> None:
    """
    Write a configuration entry into the repository's .git/config.
    """
    repo = Repo(repo_path)
    # FIX: strip newline characters from section to prevent header injection
    sanitized_section = section.replace("\n", "").replace("\r", "")
    with repo.config_writer() as cw:
        cw.set_section(sanitized_section)
        cw.set(key, value)

Cite this entry

@misc{vaitp:cve202667326,
  title        = {{GitPython 3.1.50+ allows newline injection in config_writer(), enabling malicious [core] sections for RCE.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-67326},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-67326/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.