Closed
Description
Crash report
What happened?
Similar to #126033, the following crashes:
import xml.etree.ElementTree as ET
class EvilTag(str):
def __eq__(self, other):
base.clear()
return False
base = ET.Element('a')
base.append(ET.Element(EvilTag('x')))
base.find('a')
Attacked code:
cpython/Modules/_elementtree.c
Lines 1264 to 1275 in dc76a4a
The findall
and findtext
methods also suffer from the same vulnerability. I haven't tried to attack Element.iterfind
yet since it delegates to the Python function ElementPath.iterfind
instead.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Output from running 'python -VV' on the command line:
No response
Linked PRs
- gh-126037: fix UAF in
xml.etree.ElementTree.Element.find*
when concurrent mutations happen #127964 - [3.13] gh-126037: fix UAF in
xml.etree.ElementTree.Element.find*
when current mutations happen (#127964) #131931 - [3.12] gh-126037: fix UAF in
xml.etree.ElementTree.Element.find*
when concurrent mutations happen (#127964) #131932