---
schema_version: '1.0'
id: security-20261023-be7d9b
title: 'CVE-2026-114145: GitPython validates a submodule''s ".git" path only after
  cloning into it (RCE)'
url: https://osv.dev/vulnerability/GHSA-83vg-56qc-22m7
url_hash: be7d9b60540ce1e76a4801f091d0141b8886b980e7b9929f80d48def0ac064c1
canonical_url: https://osv.dev/vulnerability/GHSA-83vg-56qc-22m7
source: osv:ghsa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- CVE-2026-114145
- GHSA-83vg-56qc-22m7
- severity:CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
- gitpython
- PyPI
lang: en
published_at: '2026-10-22T16:41:14Z'
fetched_at: '2026-10-23T11:56:13.957440Z'
updated_at: '2026-10-26T12:10:37.141898Z'
status: published
content_hash: 56d7694025e1781c78d64fc7cb47672fcd0fab18cdf6bb9f07c4f7d376cff9ee
content_changed_at: null
license_note: full
summary: GitPython validates a submodule's ".git" path only after cloning into it
  (RCE)
summary_source: rss
summary_en: GitPython validates a submodule's ".git" path only after cloning into
  it (RCE)
summary_omitted_reason: null
redistribution: true
keywords_en:
- after
- cloning
- cve
- CVE-2026-114145
- GHSA-83vg-56qc-22m7
- Git
- gitpython
- into
- library vulnerability
- only
- path
- PyPI
- RCE
- severity:CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
- Shay McVeigh
- software security
- submodule
- validates
entities_en:
- name: Git
  type: tool
- name: Shay McVeigh
  type: person
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: Shay McVeigh
  type: person
- name: Git
  type: tool
key_facts: []
related: []
related_auto:
- name: Excel
  type: tool
  weight: 7.9
- name: Grammarly
  type: tool
  weight: 5.9
- name: Bristol Crown Court
  type: organization
  weight: 1.0
- name: Bristol Magistrates Court
  type: organization
  weight: 1.0
computed_at: '2026-10-23T13:34:21Z'
---

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

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

## Key Points
- cve / CVE-2026-114145 / GHSA-83vg-56qc-22m7 / severity:CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H / gitpython / PyPI

## Details
**Severity:** CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
**Advisory:** GHSA-83vg-56qc-22m7 (CVE-2026-114145)

**Details:**
### Summary


`create_submodule(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 _clone_repo has written to disk:

git/objects/submodule/base.py (Submodule.add)
  599: path = cls._to_relative_path(repo, path)           # accepts ".git/hooks"
  673: mrepo = cls._clone_repo(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._preprocess_add_items)
  732: _validate_repo_path(entry.path)                     # rejects ".git", too late

_to_relative_path only blocks `..`/absolute/out-of-tree paths; `.git` aliases are
rejected only by _validate_repo_path, 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 _clone_repo already wrote.

Version-dependent behavior:
- 3.2.0 .. tip bda18e08: _validate_repo_path 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): _validate_repo_path does not exist and _to_relative_path does
  not reject `.git`; create_submodule(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 GIT_TEMPLATE_DIR/init.templateDir empty)

import git, os.path as osp
try:
    git.Repo("victim").create_submodule(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): create_submodule 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: create_submodule 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 create_submodule. 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/GIT_TEMPLATE_DIR 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.

**References:**
- https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-83vg-56qc-22m7
- https://nvd.nist.gov/vuln/detail/CVE-2026-114145
- https://github.com/gitpython-developers/GitPython/pull/2264
- https://github.com/gitpython-developers/GitPython/commit/97eadb888d2f99567e3113f4e455be4ca128f697
- https://github.com/gitpython-developers/GitPython
- https://github.com/gitpython-developers/GitPython/releases/tag/3.2.1

_Data: OSV.dev (upstream: ghsa) — https://osv.dev/vulnerability/GHSA-83vg-56qc-22m7_

## Source
元記事: [CVE-2026-114145: GitPython validates a submodule's ".git" path only after cloning into it (RCE)](https://osv.dev/vulnerability/GHSA-83vg-56qc-22m7) — published 2026-10-22T16:41:14Z
