Executive brief
Dulwich is a Python library used to interact with Git repositories. A security flaw in the way it generates patch files allows a specially crafted Git commit to save files outside of the intended folder. This could allow an attacker to overwrite or create files in unexpected locations on a user's system if they process a malicious repository.
Technical details
A path traversal vulnerability exists in `dulwich.porcelain.format_patch` due to insufficient sanitization in the `get_summary` function. The function derives patch filenames from commit subject lines but fails to strip path separators (/, \), parent-directory components (..), or other hostile characters. An attacker can craft a commit with a malicious subject line to write patch files to arbitrary locations outside the specified output directory. This is exploitable when a user or service processes untrusted commits using the affected API. The issue is fixed in version 1.2.5 by implementing sanitization that mirrors Git's native behavior.
Affected products
- Jelmer Vernooij Dulwich >=0.24.0, <1.2.5
Timeline
- 2026-05-19: patched: Fix commit c2446e51b authored
- 2026-05-28: advisory: GitHub Security Advisory published
- 2026-06-10: disclosed: CVE-2026-47712 published to NVD