Technical impact
Dulwich, a pure‑Python implementation of Git, parses commit objects by examining the tree header section. In versions older than 1.2.20 the parser incorrectly selects the last of any duplicate tree headers rather than the first, diverging from core Git’s behavior. An attacker can craft a commit that contains two tree headers: the first points to a benign tree that normal Git tools display, while the second points to a malicious tree that includes build scripts such as setup.py. When the vulnerable Dulwich instance is used – for example, by Poetry during dependency installation – the second tree is checked out and the embedded scripts execute, giving the attacker arbitrary code execution on the build or install host.
Affected Systems
All installations of Dulwich from vendor jelmer that are older than version 1.2.20 are affected. Poetry 2.5.1 ships this version and uses Dulwich by default for Git dependency installation. Earlier Poetry versions may also bundle the vulnerable Dulwich code, but that is inferred from the description and not explicitly confirmed.
Risk and Exploitability
The issue carries a CVSS score of 8.6, indicating high severity, and is not listed in the CISA KEV catalog. The EPSS score is not available. Because Poetry automatically invokes Dulwich, an attacker who can supply or manipulate the contents of a repository can exploit this flaw from either a remote or local context – the likely attack vector is the delivery of a malicious repository that contains a crafted commit with duplicate tree headers. Successful exploitation results in unreviewed execution of arbitrary code on the host performing the Poetry install, potentially compromising the entire system.