Dulwich doesn't sanitize commit subjects in `porcelain.format_patch`
Key facts
- Attack vector
- Local
- Privileges required
- None
- User interaction
- Required
- Attack complexity
- Low
- Impact type
- —
- Confidentiality · integrity · availability
- None · Low · None
- Fix status
- Partial Red Hat: 6 without a fix
Attack profile from CVSS 3.1 · CNA. Fix status from CNA, GitHub and Red Hat.
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.porcelain.format_patch(outdir=...) derives each patch filename from the commit's subject line. Prior to this fix, get_summary only replaced spaces with dashes - path separators (/, \), parent-directory components (..), and other filename-hostile characters (e.g. :) were preserved verbatim and passed straight into os.path.join(outdir, f"{i:04d}-{summary}.patch"). A malicious commit subject could therefore direct the generated patch file outside the requested outdir. This is fixed in Dulwich 1.2.5. Users should upgrade to 1.2.5 or later. dulwich.patch.get_summary now mirrors git's format_sanitized_subject: only `[A-Za-z0-9._]` are kept, runs of other characters collapse to a single -, consecutive . collapse to a single ., trailing ./- are stripped, and the result is length-limited. This makes the returned string safe to embed as a filename component, so format_patch can no longer be steered out of outdir via the commit subject. Until upgrading, callers that pass untrusted commits to porcelain.format_patch can use stdout=True and write the patch to a destination they control, rather than letting format_patch choose the filename; validate the chosen path before opening - e.g. compare os.path.realpath(returned_path) against os.path.realpath(outdir) and reject any patch whose resolved path is not inside outdir; and/or pre-screen commits and refuse to format any whose subject's first line contains /, \, .., or other characters that are not safe on the target filesystem.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| jelmer | dulwich | 0.24.0 to before 1.2.5 | 1.2.5 | Patch available | CNA |
| — | dulwich (PyPI) | 0.24.0 to before 1.2.5 | 1.2.5 | Patch available | GHSA-555p-6grf-mh7f |
- dulwich Vendorjelmer Affected 0.24.0 to before 1.2.5 Fixed in 1.2.5 Patch available CNA
- dulwich (PyPI) Vendor— Affected 0.24.0 to before 1.2.5 Fixed in 1.2.5 Patch available GHSA-555p-6grf-mh7f
Remediation
- Fix · CNA dulwich (jelmer) Fixed in 1.2.5
- Fix · GHSA-555p-6grf-mh7f dulwich (PyPI) Fixed in 1.2.5 Advisory →
Vendor assessments
Red Hat
Red Hat rating: Low. Red Hat's page for this CVE →
| Product | Status | Plan or fix |
|---|---|---|
| Red Hat Ansible Automation Platform 2 | Affected | No fix yet: Fix deferred |
| Red Hat Enterprise Linux 7 | Affected | No fix yet: Fix deferred |
| Red Hat Enterprise Linux 8 | Affected | No fix yet: Fix deferred |
| Red Hat OpenShift AI (RHOAI) | Affected | No fix yet: Fix deferred |
| Red Hat OpenShift Container Platform 4 | Affected | No fix yet: Fix deferred |
| Red Hat Satellite 6 | Affected | No fix yet: Fix deferred |
Timeline
- 2026-10-02 Threatist record created from CVE-2026-47712
- 2026-10-03 Alias added: GHSA-555p-6grf-mh7f
References
More jelmer vulnerabilities
- TI-2026-78707 Path traversal in Dulwich lets attackers write files on Windows CVSS 4.0HIGH 8.7
- TI-2026-37846 Path traversal in jelmer dulwich CVSS 3.1HIGH 7.5
- TI-2026-30843 Dulwich Vulnerable to Command Injection via Merge Driver Path CVSS 4.0HIGH 7.7
- TI-2026-78709 Symlink following in Dulwich checkout allows arbitrary file writes CVSS 4.0HIGH 7.3
- TI-2026-30613 Dulwich has an arbitrary file write via NTFS-hostile tree entries on Windows CVSS 3.1HIGH 8.8
- TI-2026-85266 Dulwich commit parser picks the wrong tree from duplicate headers CVSS 4.0HIGH 8.6
Sources
- CVE-2026-47712 · CVE Program
- CVE-2026-47712 · NVD
- FIRST EPSS
- GHSA-555p-6grf-mh7f · GitHub Advisory Database · CC BY 4.0
- CVE-2026-47712 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences