{"id":"CVE-2026-76219","aliases":["CVE-2026-76219","GHSA-4gmw-gg2m-w46p","PYSEC-2026-3838"],"related":[],"kind":"vulnerability","state":"published","title":"GitPython before 3.1.58 Arbitrary File Overwrite via read-tree","summary":"GitPython versions before 3.1.58 contain an arbitrary file overwrite vulnerability in IndexFile.from_tree, IndexFile.reset, and IndexFile.merge_tree methods that append caller-influenced treeish strings to git read-tree without option validation or argument separation. Attackers can inject the --index-output option to overwrite arbitrary files with a valid git-index blob, destroying existing file content at attacker-controlled writable paths.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"GitPython versions before 3.1.58 contain an arbitrary file overwrite vulnerability in IndexFile.from_tree, IndexFile.reset, and IndexFile.merge_tree methods that append caller-influenced treeish strings to git read-tree without option validation or argument separation. Attackers can inject the --index-output option to overwrite arbitrary files with a valid git-index blob, destroying existing file content at attacker-controlled writable paths.","source":"cvelist"},{"lang":"en","text":"## Summary\n`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).\n\n## Root Cause\n`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.\n\n## Impact\nArbitrary 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.\n\n## Proof of Concept\n```python\nIndexFile.from_tree(repo, \"--index-output=/home/victim/.bashrc\")\n# target overwritten with a valid git-index blob (DIRC...)\n```\n\n## Attack Chain\n1. Entry: app calls `IndexFile.from_tree(repo, treeish)` / `reset(commit=…)` / `merge_tree(base=…, rhs=…)` with attacker `treeish=\"--index-output=/home/victim/.bashrc\"`.\n2. Check: NONE — the methods have no `allow_unsafe_options` and never call `check_unsafe_options`.\n3. Sink: `repo.git.read_tree(*arg_list)` — no `--`. argv (from_tree, observed): `['git','read-tree','--index-output=<tmp>','--index-output=/…/victim']` (last-wins).\n4. Impact: target path created/overwritten with a valid git-index blob; existing content destroyed.\n\n## Bypass Evidence\nIndependently 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.\n\n## Affected Versions\n`GitPython <= 3.1.57` (sinks present verbatim on the latest release tag).\n\n## Suggested Fix\nAdd 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.","format":"markdown","source":"ghsa"}],"published":"2026-08-07T15:33:57.000Z","modified":"2026-10-08T15:25:01.192Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N","score":7.2,"rating":"HIGH"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N","score":7.2,"rating":"HIGH"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H","score":8.1,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H","score":8.1,"rating":"HIGH"}],"cwes":["CWE-88"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"3.1.58","status":"affected"},{"type":"semver","version":"3.1.58","status":"unaffected"}],"vendor":"gitpython-developers","product":"GitPython","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.1.58"}],"ecosystem":"PyPI","package":"gitpython","purl":"pkg:pypi/gitpython","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.1.58"}],"vendor":"gitpython_project","product":"gitpython","cpe":"cpe:2.3:a:gitpython_project:gitpython:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.1.58"}],"ecosystem":"PyPI","package":"gitpython","purl":"pkg:pypi/gitpython","source":"pysec"}],"references":[{"url":"https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-4gmw-gg2m-w46p","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://www.vulncheck.com/advisories/gitpython-before-arbitrary-file-overwrite-via-read-tree","tags":["third-party-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-76219","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/gitpython-developers/GitPython/pull/2204","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/gitpython-developers/GitPython/commit/9b5dcaf85da5946dbf69dcd53f9edba08f760b32","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/gitpython-developers/GitPython","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://github.com/gitpython-developers/GitPython/releases/tag/3.1.58","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/gitpython","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-4gmw-gg2m-w46p","tags":["advisory"],"sources":["pysec"]}],"credits":["manus-use","bhaswanthc"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-08-20T13:47:26.740Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-76219","url":"https://www.cve.org/CVERecord?id=CVE-2026-76219","licence":"CVE Terms of Use","modified":"2026-10-08T15:25:01.192Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-4gmw-gg2m-w46p","url":"https://github.com/advisories/GHSA-4gmw-gg2m-w46p","licence":"CC-BY-4.0","modified":"2026-09-10T12:25:42.767Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-76219","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-76219","licence":"Public domain","modified":"2026-09-03T15:03:51.950Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-3838","url":"https://osv.dev/vulnerability/PYSEC-2026-3838","licence":"CC-BY-4.0","modified":"2026-09-10T12:15:06.247Z"}],"updatedAt":"2026-11-25T22:59:33.935Z","epss":{"score":0.00543,"percentile":0.39246,"date":"2026-11-30T12:00:22.000Z"}}