CVE-2026-114145: GitPython validates a submodule's ".git" path only after cloning into it (RCE)

Published Oct 21, 2026
·
Updated

Summary

createsubmodule(name, path, url) clones a submodule into the repo's own .git directory before it rejects the path. A path of ".git/hooks" is accepted by the pre-clone check, so the submodule is cloned straight into the live hooks directory, and a file named post-checkout in the submodule becomes an executable .git/hooks/post-checkout. On 3.2.0+ the later index check does raise ValueError, but only after the clone already wrote to disk, and it does not remove the planted hook; on 3.1.x there is no such check and the call succeeds silently. Either way the hook runs on the next git operation (e.g. checkout), giving code execution.

Details

The checkout path is validated too late, after the clone has already mutated disk. This breaks the "validate before mutation" invariant that commit 43a43cd8 ("Validate submodule checkout and metadata paths before mutation") set out to enforce.

Submodule.add() calls the permissive path check before cloning, and the strict check only reaches the ".git" alias at index time, after clonerepo has written to disk:

git/objects/submodule/base.py (Submodule.add) 599: path = cls.torelativepath(repo, path) # accepts ".git/hooks" 673: mrepo = cls.clonerepo(repo, url, path, name, ...) # clones into <worktree>/.git/hooks 714: index.add([sm], write=True) # strict check only triggers here

git/index/base.py (IndexFile.preprocessadditems) 732: validaterepopath(entry.path) # rejects ".git", too late

torelativepath only blocks ../absolute/out-of-tree paths; .git aliases are rejected only by validaterepopath, which was added in 3.2.0 (commit a75aedf3) and runs at the index boundary. The ValueError it raises at line 732 does not roll back what clonerepo already wrote.

Version-dependent behavior: - 3.2.0 .. tip bda18e08: validaterepopath raises ValueError at index.add, but the hook is already on disk and is not removed (incorrect order of validation vs. clone). - 3.1.x (e.g. 3.1.59): validaterepopath does not exist and torelativepath does not reject .git; createsubmodule(path=".git/hooks", ...) returns with no error at all and the hook is planted silently.

Proof of concept

Setup: evilsub/ : a git repo whose ROOT contains an executable file named post-checkout (the payload) victim/ : a git repo with at least 1 commit and a second branch, whose .git/hooks has NO sample hooks (the state of a minimal/CI checkout, or git init with an empty template dir, or GITTEMPLATEDIR/init.templateDir empty)

import git, os.path as osp try: git.Repo("victim").createsubmodule(name="x", path=".git/hooks", url=osp.abspath("evilsub")) except ValueError: pass # 3.2.0+: ".git" is rejected, but only AFTER the clone, so the plant already happened. # 3.1.x: no exception is raised at all; the call succeeds and still plants the hook.

victim/.git/hooks/post-checkout now exists, mode 0755, attacker-controlled, on every affected version. Any later checkout runs it: git -C victim checkout <other-branch> -> the hook runs -> code execution

Verified live: - tip bda18e08 (3.2.0 + 3 commits): createsubmodule raised ValueError from git/index/base.py:732, yet .git/hooks/post-checkout was present and executable, and git checkout executed it. - 3.1.59: createsubmodule returned with no error; .git/hooks/post-checkout was planted and executed by git checkout.

Impact

Arbitrary code execution. A library/app that creates a submodule from an attacker-influenced path ends up with an attacker-controlled executable in .git/hooks, which git runs on ordinary later operations. This affects any service that derives a submodule checkout path from untrusted data, e.g. one that ingests a submodule spec (name/path/url) from a user-supplied manifest or API request and feeds path into createsubmodule. On 3.2.0+ the library's own validation is the thing that fails: it correctly rejects the .git path, but only after the submodule has already been cloned into place, so an app that traps the ValueError reasonably believes the unsafe path was blocked.

Preconditions (hence AC:H): (1) the app passes an attacker-influenced submodule path; (2) the target hook name is free in .git/hooks, true for minimal/CI/container checkouts and whenever init.templateDir/GITTEMPLATEDIR is empty. With the default sample hooks present, git clone refuses the non-empty destination and no plant occurs.

Affected: all tested versions from 3.1.x (3.1.59) through the current tip bda18e08 (3.2.0 + 3 commits). 3.1.x plants silently; 3.2.0+ plants despite raising ValueError.

Other sources

GitPython is a python library used to interact with Git repositories. Prior to 3.2.1, createsubmodule() in git/objects/submodule/base.py accepts an attacker-influenced submodule path such as .git/hooks and invokes clonerepo() before safely rejecting the destination. In 3.1.x, validaterepopath() does not exist and the call succeeds silently, while in 3.2.0 and later affected revisions the check in git/index/base.py raises ValueError only after the clone has written to disk and does not remove the planted file. An attacker-controlled submodule can therefore place an executable post-checkout hook that a later Git operation executes. Exploitation requires an application to accept an untrusted submodule path and a clone destination such as .git/hooks that is empty enough for Git to clone into it, which commonly means that default sample hooks are absent. This issue is fixed in version 3.2.1.

— Ubuntu

GitPython validates a submodule's ".git" path only after cloning into it (RCE)

— Microsoft

Affected Software

17 affected componentsFixes available
pypi/GitPython<3.2.1
pip/gitpython<=3.2.0
3.2.1
debian/python-git<3.1.30-1+deb12u3
3.1.30-1+deb12u3
debian/python-git<3.1.44-1+deb13u1
3.1.44-1+deb13u1
debian/python-git<3.2.1-1
3.2.1-1
All of the following
azurelinux/gitpython<0:3.2.1-6.azl4
0:3.2.1-6.azl4
Microsoft Azure Linux=4.0
debian/python-git<=3.1.30-1+deb12u2
3.1.30-1+deb12u33.1.44-1+deb13u13.2.1-1
ubuntu/python-git*
ubuntu/python-git*
ubuntu/python-git*
ubuntu/python-git*
ubuntu/python-git*
ubuntu/python-git*
ubuntu/python-git*
ubuntu/python-git*
IBM Process Mining<=2.0.0 - 2.2.1 IF001

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/Gitpython to a version that resolves this vulnerability.

    Fixed in 3.2.1
  2. Upgrade

    Upgrade debian/python-git to a version that resolves this vulnerability.

    Fixed in 3.1.30-1+deb12u3
  3. Upgrade

    Upgrade debian/python-git to a version that resolves this vulnerability.

    Fixed in 3.1.44-1+deb13u1
  4. Upgrade

    Upgrade debian/python-git to a version that resolves this vulnerability.

    Fixed in 3.2.1-1
  5. Upgrade

    Upgrade debian/python-git to a version that resolves this vulnerability.

    Fixed in 3.1.30-1+deb12u3Fixed in 3.1.44-1+deb13u1Fixed in 3.2.1-1
  6. Upgrade

    Upgrade azurelinux/GitPython to a version that resolves this vulnerability.

    Fixed in 0:3.2.1-6.azl4
  7. Upgrade

    Upgrade GitPython to a version that resolves this vulnerability.

    Fixed in 3.2.1

Event History

Oct 21, 2026
CVE Published
via Ubuntu·12:00 AM
Data Sourced
via Ubuntu·12:00 AM
RemedyDescriptionSeverityAffected Software
CVE Published
via MITRE·08:35 PM
Data Sourced
via MITRE·08:35 PM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·08:51 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·09:17 PM
DescriptionSeverityWeakness
Oct 22, 2026
Advisory Published
via GitHub·04:41 PM
Data Sourced
via GitHub·04:41 PM
DescriptionSeverityWeaknessAffected Software
Oct 28, 2026
Data Sourced
via OSV·08:17 PM
Affected Software
Oct 31, 2026
Updated
via OSV·02:00 PM
Affected Software
Nov 17, 2026
Data Sourced
via Microsoft·06:39 AM
DescriptionSeverityWeaknessAffected Software
Nov 30, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Peer vulnerabilities

Found alongside the following vulnerabilities.

Frequently Asked Questions

1

Which deployments are realistically exposed?

Deployments using GitPython before 3.2.1 are exposed if they call create_submodule() with an attacker-influenced submodule path. Exploitation also depends on the clone destination, such as .git/hooks, being empty enough for Git to clone into it; default sample hooks commonly prevent that condition.

2

Does an attacker need credentials or direct server access?

No privileges are required, but user interaction is required according to the supplied severity vector. The attacker must be able to influence a submodule path accepted by the application and cause it to target a suitable destination such as .git/hooks.

3

What is the impact of the delayed validation behavior?

A malicious submodule can place an executable post-checkout hook in the repository metadata directory. A later Git operation may execute that hook, resulting in remote code execution.

4

Are versions that raise ValueError still affected?

Yes. In affected 3.2.0 and later revisions, the validation occurs after cloning has already written files to disk, and the raised ValueError does not remove a planted file. In 3.1.x, the relevant validation does not exist and the operation succeeds silently.

5

What is the remediation?

Upgrade GitPython to version 3.2.1, which fixes the issue. Until upgrading, do not pass untrusted submodule paths to create_submodule(), and inspect repository .git/hooks directories for unexpected files if untrusted paths may already have been processed.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203