{"id":"CVE-2026-42563","aliases":["CVE-2026-42563","GHSA-9277-mp7x-85jf","PYSEC-2026-2464"],"related":[],"kind":"vulnerability","state":"published","title":"Dulwich Vulnerable to Command Injection via Merge Driver Path","summary":"Dulwich is a pure-Python implementation of the Git file formats and protocols. Starting in version 0.24.0 and prior to version 1.2.5, Dulwich's `ProcessMergeDriver` substitutes the file path (from the git tree, controllable by an attacker via a malicious branch) into the merge driver command via the `%P` placeholder and executes it with `subprocess.run(..., shell=True)`. An attacker who can cause a victim to merge an untrusted branch can achieve arbitrary command execution by crafting malicious file paths. Version 1.2.5 fixes the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Dulwich is a pure-Python implementation of the Git file formats and protocols. Starting in version 0.24.0 and prior to version 1.2.5, Dulwich's `ProcessMergeDriver` substitutes the file path (from the git tree, controllable by an attacker via a malicious branch) into the merge driver command via the `%P` placeholder and executes it with `subprocess.run(..., shell=True)`. An attacker who can cause a victim to merge an untrusted branch can achieve arbitrary command execution by crafting malicious file paths. Version 1.2.5 fixes the issue.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nDulwich's `ProcessMergeDriver` substitutes the file path (from the git tree, controllable by an attacker via a malicious branch) into the merge driver command via the `%P` placeholder and executes it with `subprocess.run(..., shell=True)`. An attacker who can cause a victim to merge an untrusted branch can achieve arbitrary command execution by crafting malicious file paths.\n\n## Description\n\n- **Type:** Command Injection\n- **Source:** `merge.py` line 195 — path from merge tree (from repository content when merging untrusted branch)\n- **Sink:** `merge_drivers.py` lines 124–127 — `subprocess.run(cmd, shell=True)` where `cmd` includes path via `%P` placeholder\n- **Impact:** Arbitrary code execution when merging from a malicious repository. Requires the user to have a merge driver configured that uses the `%P` placeholder.\n\n## Resources\n\n- Repository: https://github.com/dulwich/dulwich\n- Vulnerable file: `dulwich/merge_drivers.py` (lines 119–129)\n\n## Proof of Concept\n\n```python\nfrom dulwich.attrs import GitAttributes, Pattern\nfrom dulwich.config import ConfigDict\nfrom dulwich.merge import merge_blobs\nfrom dulwich.objects import Blob\n\n# Merge driver with %P (path) - typical for custom merge tools\nconfig = ConfigDict()\nconfig.set((b\"merge\", b\"injectable\"), b\"driver\", b\"echo %P > %A\")\n\npatterns = [(Pattern(b\"*\"), {b\"merge\": b\"injectable\"})]\ngitattributes = GitAttributes(patterns)\n\nbase = Blob.from_string(b\"base\")\nours = Blob.from_string(b\"ours\")\ntheirs = Blob.from_string(b\"theirs\")\n\n# Malicious path from attacker-controlled git tree: injects \"touch /tmp/pwned\"\nmalicious_path = b\"x; touch /tmp/pwned #\"\n\nmerge_blobs(base, ours, theirs, path=malicious_path,\n            gitattributes=gitattributes, config=config)\n# => Executes: echo x; touch /tmp/pwned #\n# => Shell runs: echo x, then touch /tmp/pwned\n```\n\n## Fix\n[merge_drivers_shell_escape.patch](https://github.com/user-attachments/files/27016503/merge_drivers_shell_escape.patch)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Dulwich es una implementación pura de Python de los formatos y protocolos de archivo de Git. A partir de la versión 0.24.0 y antes de la versión 1.2.5, el 'ProcessMergeDriver' de Dulwich sustituye la ruta del archivo (del árbol de Git, controlable por un atacante a través de una rama maliciosa) en el comando del controlador de fusión a través del marcador de posición '%P' y lo ejecuta con 'subprocess.run(..., shell=True)'. Un atacante que puede hacer que una víctima fusione una rama no confiable puede lograr la ejecución arbitraria de comandos al crear rutas de archivo maliciosas. La versión 1.2.5 corrige el problema.","source":"nvd"}],"published":"2026-05-28T22:29:22.000Z","modified":"2026-09-10T03:51:05.165Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":7.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":7.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"}],"cwes":["CWE-78"],"affected":[{"ranges":[{"version":">= 0.24.0, < 1.2.5","status":"affected"}],"vendor":"jelmer","product":"dulwich","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0.24.0","status":"affected","fixed":"1.2.5"}],"ecosystem":"PyPI","package":"dulwich","purl":"pkg:pypi/dulwich","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0.24.0","status":"affected","fixed":"1.2.5"}],"ecosystem":"PyPI","package":"dulwich","purl":"pkg:pypi/dulwich","source":"pysec"}],"references":[{"url":"https://github.com/jelmer/dulwich/security/advisories/GHSA-9277-mp7x-85jf","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/jelmer/dulwich/commit/e3331b3b3a122fc313460182f928f59723580b7b","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/jelmer/dulwich/releases/tag/dulwich-1.2.5","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42563","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/jelmer/dulwich","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/dulwich","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-9277-mp7x-85jf","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-06-11T00:00:00.000Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-42563","url":"https://www.cve.org/CVERecord?id=CVE-2026-42563","licence":"CVE Terms of Use","modified":"2026-06-12T03:55:30.892Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9277-mp7x-85jf","url":"https://github.com/advisories/GHSA-9277-mp7x-85jf","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:05.165Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-42563","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42563","licence":"Public domain","modified":"2026-07-21T19:10:00.107Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2464","url":"https://osv.dev/vulnerability/PYSEC-2026-2464","licence":"CC-BY-4.0","modified":"2026-07-13T16:31:45.602Z"}],"updatedAt":"2026-11-25T22:59:24.391Z","epss":{"score":0.00555,"percentile":0.47686,"date":"2026-12-01T12:00:22.000Z"}}