# CVE-2026-47712: Dulwich doesn't sanitize commit subjects in `porcelain.format_patch`

- Severity: Low 3.3 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.14%, higher than 3% of CVEs (2026-12-01)
- Published: 2026-06-08T23:04:48.000Z
- Modified: 2026-07-21T19:10:00.107Z
- Also known as: GHSA-555p-6grf-mh7f, PYSEC-2026-2462
- Weaknesses: CWE-22
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: GitHub_M

## Description

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.

(As written by CVE List.)

## Affected

- jelmer dulwich: >= 0.24.0, < 1.2.5
- dulwich (PyPI): from 0.24.0 before 1.2.5

## Every score

- GitHub_M: CVSS:3.1 3.3 Low `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N`
- GitHub: CVSS:3.1 3.3 Low `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N`
- PyPA Advisory Database: CVSS:3.1 3.3 Low `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N`

## References

- <https://github.com/jelmer/dulwich/security/advisories/GHSA-555p-6grf-mh7f> (web)
- <https://github.com/jelmer/dulwich/commit/c2446e51b> (web)
- <https://github.com/jelmer/dulwich/releases/tag/dulwich-1.2.5> (web)
- <https://nvd.nist.gov/vuln/detail/CVE-2026-47712> (advisory)
- <https://github.com/jelmer/dulwich> (package)
- <https://pypi.org/project/dulwich> (package)
- <https://github.com/advisories/GHSA-555p-6grf-mh7f> (advisory)

## Sources

- CVE List: [CVE-2026-47712](https://www.cve.org/CVERecord?id=CVE-2026-47712), CVE Terms of Use, modified 2026-06-11
- GitHub Advisory Database: [GHSA-555p-6grf-mh7f](https://github.com/advisories/GHSA-555p-6grf-mh7f), CC-BY-4.0, modified 2026-07-13
- NVD: [CVE-2026-47712](https://nvd.nist.gov/vuln/detail/CVE-2026-47712), Public domain, modified 2026-07-21
- PyPA Advisory Database: [PYSEC-2026-2462](https://osv.dev/vulnerability/PYSEC-2026-2462), CC-BY-4.0, modified 2026-07-13

---

Page: https://cve.day/CVE-2026-47712 · Whole record: https://cve.day/CVE-2026-47712.json · Rebuilt by cve.day 2026-11-25T22:59:24.400Z
