dulwich.porcelain.submodule_update, and by extension porcelain.clone(..., recurse_submodules=True), materializes attacker-controlled submodule paths from a crafted upstream repository without path validation. A malicious .gitmodules plus a matching tree gitlink whose path is .git/hooks (or any other directory inside the parent repository's .git directory) causes the attacker's submodule tree contents to be written directly into the victim's .git/hooks/ directory, preserving executable mode bits. The dropped executables are then run by any subsequent git or dulwich command that invokes the matching hook, resulting in arbitrary code execution.
This is the dulwich equivalent of the upstream Git fixes for CVE-2024-32002 / CVE-2024-32004, which were never propagated into dulwich's separately implemented submodule porcelain.
dulwich (PyPI)>=0.23.2, <1.2.5.git/hooks rather than a case- or short-name-aliased form.Affected entry points:
dulwich.porcelain.submodule_update(repo, init=True, recursive=True)dulwich.porcelain.clone(source, target, recurse_submodules=True)dulwich submodule update CLI / dulwich clone --recurse-submodules CLIThe submodule path from the tree's gitlink entry (and matching .gitmodules) is consumed without validation in dulwich/porcelain/submodule.py.
The attacker-controlled path enters the loop from iter_cached_submodules (submodule.py#L154-L168):
for path, target_sha in submodules_to_update:...
0.23.20.24.00.24.10.24.100.24.20.24.30.24.40.24.50.24.60.24.7+12 more1.2.5Exploitability
AV:NAC:LPR:NUI:NScope
S:UImpact
C:NI:NA:HCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H