llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · gitpython

GHSA-4GMW-GG2M-W46P

GitPython: Unguarded git read-tree option forwarding in IndexFile.from_tree/reset/merge_tree enables arbitrary file overwrite

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche a -3 d de la divulgación
Exposición104 dDesde la divulgación, 7 ago 2026, 10:33 a. m.
Detección101 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Modificada
Explotación
Remediación
Parche 3.1.58
Monitoreo
Detectada
4 ago 26
7 ago 26
10 sept 26
17 nov 26
19 nov 26
4 ago 26
31 ago 26
27 sept 26
24 oct 26
19 nov 26
FechaFaseEventoDetalle
Remediación Parche 3.1.58 gitpython · -3 d desde divulgación
Divulgación Publicada GHSA-4GMW-GG2M-W46P divulgada
Divulgación Modificada Última actualización del registro
Monitoreo Detectada Ingresó al índice
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

## Summary
`IndexFile.from_tree`, `IndexFile.reset` (→ from_tree) and `IndexFile.merge_tree` append caller-influenced treeish strings positionally to `git read-tree` with no unsafe-option guard, no `allow_unsafe_options` parameter, and no `--` separator. `git read-tree --index-output=<file>` writes the resulting index to an arbitrary path, and last-occurrence-wins lets an injected `--index-output` override the method's internal temp path — clobbering an arbitrary file with a valid git-index blob. This is a distinct, never-guarded sink: commit `3af0c251` (GHSA-3f7w-8rr8-f37f) guarded only `checkout_index` and `tag`; `read_tree` was left unprotected (it is among the acknowledged unguarded call sites in that advisory's sweep but was never reported or fixed).

## Root Cause
`from_tree` (index/base.py:388), `reset` (delegates to from_tree), and `merge_tree` (index/base.py:291) call `repo.git.read_tree(*arg_list)` with no `check_unsafe_options` and no `--`. The treeish is caller-influenced and positional.

## Impact
Arbitrary file overwrite / destruction at the privileges of the host process. Content is constrained to a git-index blob (not attacker-chosen, so not RCE), but the target path is fully attacker-controlled — corrupting/truncating configs or destroying files at attacker-chosen writable locations = I:H + A:H (per the skill's "overwrite-any-path = I:H" rule). Pure VALUE control (positional treeish). Default configuration.

Proof of Concept

IndexFile.from_tree(repo, "--index-output=/home/victim/.bashrc")
# target overwritten with a valid git-index blob (DIRC...)

## Attack Chain
1. Entry: app calls `IndexFile.from_tree(repo, treeish)` / `reset(commit=…)` / `merge_tree(base=…, rhs=…)` with attacker `treeish="--index-output=/home/victim/.bashrc"`.
2. Check: NONE — the methods have no `allow_unsafe_options` and never call `check_unsafe_options`.
3. Sink: `repo.git.read_tree(*arg_list)` — no `--`. argv (from_tree, observed): `['git','read-tree','--index-output=<tmp>','--index-output=/…/victim']` (last-wins).
4. Impact: target path created/overwritten with a valid git-index blob; existing content destroyed.

## Bypass Evidence
Independently reproduced (gate harness): `IndexFile.from_tree(repo,'--index-output=<victim>')` → victim overwritten; before=`IMPORTANT ORIGINAL CONTENT`, after starts `DIRC\x00\x00\x00\x02…` (destructive clobber, valid index blob). `reset(commit=…)` and both `merge_tree` positionals verified. Fix-commit read: `3af0c251` touched only `checkout_index`+`tag`; `read_tree` untouched on HEAD.

## Affected Versions
`GitPython <= 3.1.57` (sinks present verbatim on the latest release tag).

## Suggested Fix
Add a `check_unsafe_options` guard (with an `allow_unsafe_options` parameter) to `from_tree`/`reset`/`merge_tree`, and/or place a `--` separator before the positional treeish arguments; block `--index-output` (a path-taking option) on this sink.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida Última
gitpython< 3.1.58
3.1.58
3.2.1
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypigitpython
Corregida 3.1.58 -3 d 3.2.1 no afectada
Versiones corregidas3.1.58
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2026-76219
Otrahttps://github.com/gitpython-developers/GitPython/security/advisories/GHSA-4gmw-gg2m-w46p
Otrahttps://github.com/gitpython-developers/GitPython/pull/2204
Otrahttps://github.com/gitpython-developers/GitPython/commit/9b5dcaf85da5946dbf69dcd53f9edba08f760b32
Otrahttps://github.com/gitpython-developers/GitPython
Otrahttps://github.com/gitpython-developers/GitPython/releases/tag/3.1.58
Otrahttps://www.vulncheck.com/advisories/gitpython-before-arbitrary-file-overwrite-via-read-tree

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.