{"id":"CVE-2026-76218","aliases":["CVE-2026-76218","GHSA-9rj7-rf2p-w77r","PYSEC-2026-3840"],"related":[],"kind":"vulnerability","state":"published","title":"GitPython before 3.1.58 Remote Code Execution via Repo.init","summary":"GitPython before 3.1.58 contains a remote code execution vulnerability in Repo.init that forwards unsafe git options without validation. Attackers can supply a template parameter pointing to a directory with malicious git hooks that execute arbitrary code when git operations are performed on the initialized repository.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"GitPython before 3.1.58 contains a remote code execution vulnerability in Repo.init that forwards unsafe git options without validation. Attackers can supply a template parameter pointing to a directory with malicious git hooks that execute arbitrary code when git operations are performed on the initialized repository.","source":"cvelist"},{"lang":"en","text":"## Summary\n`Repo.init()` forwards `**kwargs` verbatim to `git init` with no unsafe-option guard and no `allow_unsafe_options` parameter. `git init --template=<dir>` copies `<dir>/hooks/*` into the new repo's `.git/hooks`, so an attacker-controlled `template` kwarg plants a hook that executes on the next git operation → arbitrary code execution. `--template` is already recognized as unsafe for clone (it is on `unsafe_git_clone_options`, and GHSA-6p8h-3wgx-97gf covers the clone path), but `Repo.init` is a distinct method that never received a guard and needs an independent fix.\n\n## Root Cause\n`Repo.init(path, mkdir, odbt, expand_vars, **kwargs)` is a bare `git.init(**kwargs)` (git/repo/base.py:1435) with no `check_unsafe_options` and no `allow_unsafe_options`.\n\n## Impact\nArbitrary code execution (hook fires on next git op) at the privileges of the host process. Two preconditions raise attack complexity (AC:H): the app must forward a `template=` kwarg (KEY control) AND the attacker must stage an executable hook directory at a known path — the same profile GHSA-6p8h-3wgx-97gf accepted as HIGH for the clone path. Default `allow_unsafe_options` is irrelevant here because `Repo.init` has no guard at all.\n\n## Proof of Concept\n```python\n# attacker stages /evil/hooks/post-commit (executable)\nfrom git import Repo\nRepo.init(path, template=\"/evil\")\n# next commit runs /evil/hooks/post-commit -> ACE\n```\n\n## Attack Chain\n1. Entry: attacker stages `/evil/hooks/post-commit` (executable) and gets the app to call `Repo.init(path, template='/evil')`.\n2. Check: NONE on `Repo.init`. Bypass proof: base.py:1435 is a bare `git.init(**kwargs)`. argv (observed): `['git','init','--template=/evil']`.\n3. Sink: git copies `/evil/hooks/post-commit` → `<repo>/.git/hooks/post-commit`.\n4. Impact: next commit runs the hook → arbitrary code execution.\n\n## Bypass Evidence\nIndependently reproduced (gate harness): `Repo.init(dst, template='<evil>')` → argv `['git','init','--template=<evil>']` unguarded; hook copied into `.git/hooks/post-commit`; after `git commit` the `INIT_ACE` marker was created. `--separate-git-dir=<path>` is a parallel arbitrary-redirect vector through the same unguarded sink (value control only).\n\n## Affected Versions\n`GitPython <= 3.1.57` (unguarded `git.init(**kwargs)` present verbatim on the latest release tag).\n\n## Suggested Fix\nAdd a `check_unsafe_options` guard (with an `allow_unsafe_options` parameter) to `Repo.init`, consulting a denylist that includes `--template` and `--separate-git-dir` (path-taking / hook-installing options).\n\n---\nReported by **zx (Jace)** — GitHub: @manus-use","format":"markdown","source":"ghsa"}],"published":"2026-08-07T15:36:43.000Z","modified":"2026-10-08T15:25:00.661Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":7.7,"rating":"HIGH"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":7.7,"rating":"HIGH"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-88","CWE-94"],"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-9rj7-rf2p-w77r","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://www.vulncheck.com/advisories/gitpython-before-remote-code-execution-via-repo-init","tags":["third-party-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-76218","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/d9ddb55bdc66","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-9rj7-rf2p-w77r","tags":["advisory"],"sources":["pysec"]}],"credits":["manus-use","BarakSrour"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-08-20T03:56:19.629Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-76218","url":"https://www.cve.org/CVERecord?id=CVE-2026-76218","licence":"CVE Terms of Use","modified":"2026-10-08T15:25:00.661Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9rj7-rf2p-w77r","url":"https://github.com/advisories/GHSA-9rj7-rf2p-w77r","licence":"CC-BY-4.0","modified":"2026-09-10T12:25:55.324Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-76218","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-76218","licence":"Public domain","modified":"2026-09-03T15:03:14.043Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-3840","url":"https://osv.dev/vulnerability/PYSEC-2026-3840","licence":"CC-BY-4.0","modified":"2026-09-10T12:15:03.992Z"}],"updatedAt":"2026-11-25T22:59:33.934Z","epss":{"score":0.00825,"percentile":0.54592,"date":"2026-11-30T12:00:22.000Z"}}