dulwich
Affected
- introduced
0.24.0, fixed1.2.5(ecosystem)
Fixed versions
1.2.5
Fix
- Fixed version
1.2.5pip install --upgrade dulwich==1.2.5
Advisory
Also known as: CVE-2026-47712, GHSA-555p-6grf-mh7f
Dulwich doesn't sanitize commit subjects in porcelain.format_patch
Impact
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. Reduced examples:
Related issues from the same root cause:
Anyone calling porcelain.format_patch (or the dulwich format-patch CLI) against untrusted commits - for example, a service that runs format-patch over user-supplied repositories or pull requests - could have patch files written to attacker-chosen locations within the process's write permissions.
Patches
Fixed in Dulwich 1.2.5. Users should upgrade.
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.
Workarounds
Until upgrading, callers that pass untrusted commits to porcelain.format_patch can:
Resources
Low Basis: CVSS v3 score 3.3, vector CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N
0.24.0, fixed 1.2.5 (ecosystem)1.2.5
1.2.5pip install --upgrade dulwich==1.2.5Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: PyPA Advisory Database · CC BY 4.0