Skip to content
Thursday, October 22, 2026AboutContactRSS
GitPython Hook Injection Allows Code Execution in Submodule Clones
Vulnerabilities

GitPython Hook Injection Allows Code Execution in Submodule Clones

A high-severity flaw in GitPython lets attackers plant executable hooks in .git directories during submodule creation, bypassing path validation checks.

Key points

  • CVE-2026-114145 affects GitPython versions up to and including 3.2.0.
  • The vulnerability allows arbitrary code execution via injected git hooks.
  • Version 3.2.1 patches the issue by validating paths before disk mutation.

GitPython versions through 3.2.0 contain a high-severity hook injection vulnerability, tracked as CVE-2026-114145. The flaw allows an attacker to plant executable scripts in a repository's `.git/hooks` directory by manipulating the `path` argument during submodule creation. This bypasses standard safety checks because the library clones the submodule before verifying that the destination path is safe.

Root cause

The core issue stems from a failure to validate checkout paths before mutating the filesystem. GitPython’s `create_submodule` function accepts a `.git/hooks` path during its initial permissive check. It then proceeds to clone the submodule directly into that live hooks directory. Only after the clone writes files to disk does a stricter validation step run, which raises a `ValueError` but fails to remove the planted hook or roll back the changes.

Attack path

An attacker supplies a malicious `url` and sets the `path` parameter to `.git/hooks`. The library clones the repository into the target’s `.git/hooks` folder. If the cloned repository contains a file named `post-checkout`, it becomes an executable git hook. The next time the victim performs a git operation like a checkout, the injected script runs with the privileges of the user executing the command, leading to arbitrary code execution.

Affected versions

  • GitPython versions prior to 3.2.1 are vulnerable.
  • Versions 3.1.x accept the malicious path silently and complete the operation without error.
  • Version 3.2.0 raises an error after the damage is done, leaving the hook on disk.
  • GitPython 3.2.1 is the first patched version that prevents this behavior.

Mitigation

  • Upgrade GitPython to version 3.2.1 or later immediately.
  • Avoid passing untrusted path arguments to `create_submodule` or `Submodule.add`.
  • Validate all user-supplied inputs before invoking git submodule operations.
  • Monitor repositories for unexpected files in the `.git/hooks` directory.

Signals worth monitoring

Teams usually detect this activity by monitoring for unexpected file creations within `.git/hooks` directories during automated builds or CI/CD pipelines. Security operations centers should look for git commands executing scripts from non-standard locations. Check whether any recent submodule additions resulted in new executable files in the hooks folder. Containment moves typically involve isolating affected repositories and removing unauthorized hook scripts before they trigger further execution during routine git operations.

What to do and how to stay safe: GitPython

  • Audit your Python environments for installed versions of GitPython below 3.2.1.
  • Review recent git submodule additions for suspicious paths or unexpected hook files.
  • Implement strict input validation for any code handling submodule creation parameters.
  • Once the vendor provides an update, test it in a staging environment before deployment.

Step-by-step guide: Attack Surface Management: 6 Common Misreadings and Correct Views

General security guidance from the NetSec Observer newsroom. It is not confirmed advice from the organisations named in this story.

Frequently asked questions

Does this vulnerability allow remote code execution?

Yes, if an attacker can control the submodule URL and path arguments, they can execute arbitrary code on the victim's machine.

Is there a patch available for this issue?

Yes, upgrading to GitPython version 3.2.1 fixes the vulnerability by validating paths before cloning.

Which versions of GitPython are affected?

All versions up to and including 3.2.0 are affected by CVE-2026-114145.

Sources

  1. GitHub Advisory Database
GitPythonCVE-2026-114145PythonSecurity VulnerabilityHook Injection

Related stories

GraphQL-core Comment Padding Bypasses Token Limits in High Severity Flaw

A high severity vulnerability in graphql-core allows attackers to bypass token limits using comments, causing memory exhaustion in vulnerable versions.