ADVISORIES

CVE Program

CNA-CVE-2026-6879

Quadratic Behavior in xml.etree.ElementPath Index Predicates

Details

Element.findall() and fully-consumed Element.iterfind() exhibit O(n^2) time complexity when using XPath index predicates (e.g. [1], [last()], [last()-N]) on XML documents with many same-tag siblings. Element.find() is only affected when the first match is near the end  of the sibling list, such as with [last()] or [last()-N];  .//item[1] short-circuits after the first match.

Affected packages

EcosystemPackageAffected versions
Pythonpython
All versions before 3.10.21 (fixed in 3.10.21)
From 3.11.0 before 3.11.16 (fixed in 3.11.16)
From 3.12.0 before 3.12.14 (fixed in 3.12.14)
From 3.13.0 before 3.13.15 (fixed in 3.13.15)
From 3.14.0 before 3.14.7 (fixed in 3.14.7)
From 3.15.0a1 before 3.15.0rc1 (fixed in 3.15.0rc1)

References