summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2026-01-26 00:56:27 +0100
committerPaul Barker <paul@pbarker.dev>2026-02-27 15:54:01 +0000
commite7b549ecaa945a5b9f755316b80d515312d0bf2b (patch)
tree2781fb9fbb6fbbfe266aff26668d6dabdc678141
parent4ad238e9c1bda40c67f86dbeb24483d7deef9ae1 (diff)
downloadpoky-e7b549ecaa945a5b9f755316b80d515312d0bf2b.tar.gz
python3: patch CVE-2025-12084
Pick patch for this CVE merged into 3.10 branch. (From OE-Core rev: 8888cd14eb102574d530b6c683ce5beaad1aaa39) Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Paul Barker <paul@pbarker.dev>
-rw-r--r--meta/recipes-devtools/python/python3/CVE-2025-12084.patch171
-rw-r--r--meta/recipes-devtools/python/python3_3.10.19.bb1
2 files changed, 172 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3/CVE-2025-12084.patch b/meta/recipes-devtools/python/python3/CVE-2025-12084.patch
new file mode 100644
index 0000000000..0c9bb435ed
--- /dev/null
+++ b/meta/recipes-devtools/python/python3/CVE-2025-12084.patch
@@ -0,0 +1,171 @@
1From c97e87593063d84a2bd9fe7068b30eb44de23dc0 Mon Sep 17 00:00:00 2001
2From: "Miss Islington (bot)"
3 <31488909+miss-islington@users.noreply.github.com>
4Date: Sun, 25 Jan 2026 18:10:49 +0100
5Subject: [PATCH] [3.10] gh-142145: Remove quadratic behavior in node ID cache
6 clearing (GH-142146) (#142213)
7
8* gh-142145: Remove quadratic behavior in node ID cache clearing (GH-142146)
9
10* Remove quadratic behavior in node ID cache clearing
11
12Co-authored-by: Jacob Walls <38668450+jacobtylerwalls@users.noreply.github.com>
13
14* Add news fragment
15
16CVE: CVE-2025-12084
17Upstream-Status: Backport [https://github.com/python/cpython/commit/c97e87593063d84a2bd9fe7068b30eb44de23dc0]
18Signed-off-by: Peter Marko <peter.marko@siemens.com>
19---------
20(cherry picked from commit 08d8e18ad81cd45bc4a27d6da478b51ea49486e4)
21
22Co-authored-by: Seth Michael Larson <seth@python.org>
23Co-authored-by: Jacob Walls <38668450+jacobtylerwalls@users.noreply.github.com>
24
25* [3.14] gh-142754: Ensure that Element & Attr instances have the ownerDocument attribute (GH-142794) (#142818)
26
27gh-142754: Ensure that Element & Attr instances have the ownerDocument attribute (GH-142794)
28(cherry picked from commit 1cc7551b3f9f71efbc88d96dce90f82de98b2454)
29
30Co-authored-by: Petr Viktorin <encukou@gmail.com>
31Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
32
33* gh-142145: relax the no-longer-quadratic test timing (GH-143030)
34
35* gh-142145: relax the no-longer-quadratic test timing
36
37* require cpu resource
38(cherry picked from commit 8d2d7bb2e754f8649a68ce4116271a4932f76907)
39
40Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
41
42* merge NEWS entries into one
43
44---------
45
46Co-authored-by: Seth Michael Larson <seth@python.org>
47Co-authored-by: Jacob Walls <38668450+jacobtylerwalls@users.noreply.github.com>
48Co-authored-by: Petr Viktorin <encukou@gmail.com>
49Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
50Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
51Co-authored-by: Gregory P. Smith <greg@krypto.org>
52---
53 Lib/test/test_minidom.py | 33 ++++++++++++++++++-
54 Lib/xml/dom/minidom.py | 11 ++-----
55 ...-12-01-09-36-45.gh-issue-142145.tcAUhg.rst | 6 ++++
56 3 files changed, 41 insertions(+), 9 deletions(-)
57 create mode 100644 Misc/NEWS.d/next/Security/2025-12-01-09-36-45.gh-issue-142145.tcAUhg.rst
58
59diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
60index ef38c36210..c68bd990f7 100644
61--- a/Lib/test/test_minidom.py
62+++ b/Lib/test/test_minidom.py
63@@ -2,6 +2,7 @@
64
65 import copy
66 import pickle
67+import time
68 import io
69 from test import support
70 import unittest
71@@ -9,7 +10,7 @@ import unittest
72 import pyexpat
73 import xml.dom.minidom
74
75-from xml.dom.minidom import parse, Attr, Node, Document, parseString
76+from xml.dom.minidom import parse, Attr, Node, Document, Element, parseString
77 from xml.dom.minidom import getDOMImplementation
78 from xml.parsers.expat import ExpatError
79
80@@ -177,6 +178,36 @@ class MinidomTest(unittest.TestCase):
81 self.confirm(dom.documentElement.childNodes[-1].data == "Hello")
82 dom.unlink()
83
84+ @support.requires_resource('cpu')
85+ def testAppendChildNoQuadraticComplexity(self):
86+ impl = getDOMImplementation()
87+
88+ newdoc = impl.createDocument(None, "some_tag", None)
89+ top_element = newdoc.documentElement
90+ children = [newdoc.createElement(f"child-{i}") for i in range(1, 2 ** 15 + 1)]
91+ element = top_element
92+
93+ start = time.monotonic()
94+ for child in children:
95+ element.appendChild(child)
96+ element = child
97+ end = time.monotonic()
98+
99+ # This example used to take at least 30 seconds.
100+ # Conservative assertion due to the wide variety of systems and
101+ # build configs timing based tests wind up run under.
102+ # A --with-address-sanitizer --with-pydebug build on a rpi5 still
103+ # completes this loop in <0.5 seconds.
104+ self.assertLess(end - start, 4)
105+
106+ def testSetAttributeNodeWithoutOwnerDocument(self):
107+ # regression test for gh-142754
108+ elem = Element("test")
109+ attr = Attr("id")
110+ attr.value = "test-id"
111+ elem.setAttributeNode(attr)
112+ self.assertEqual(elem.getAttribute("id"), "test-id")
113+
114 def testAppendChildFragment(self):
115 dom, orig, c1, c2, c3, frag = self._create_fragment_test_nodes()
116 dom.documentElement.appendChild(frag)
117diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
118index ef8a159833..cada981f39 100644
119--- a/Lib/xml/dom/minidom.py
120+++ b/Lib/xml/dom/minidom.py
121@@ -292,13 +292,6 @@ def _append_child(self, node):
122 childNodes.append(node)
123 node.parentNode = self
124
125-def _in_document(node):
126- # return True iff node is part of a document tree
127- while node is not None:
128- if node.nodeType == Node.DOCUMENT_NODE:
129- return True
130- node = node.parentNode
131- return False
132
133 def _write_data(writer, data):
134 "Writes datachars to writer."
135@@ -355,6 +348,7 @@ class Attr(Node):
136 def __init__(self, qName, namespaceURI=EMPTY_NAMESPACE, localName=None,
137 prefix=None):
138 self.ownerElement = None
139+ self.ownerDocument = None
140 self._name = qName
141 self.namespaceURI = namespaceURI
142 self._prefix = prefix
143@@ -680,6 +674,7 @@ class Element(Node):
144
145 def __init__(self, tagName, namespaceURI=EMPTY_NAMESPACE, prefix=None,
146 localName=None):
147+ self.ownerDocument = None
148 self.parentNode = None
149 self.tagName = self.nodeName = tagName
150 self.prefix = prefix
151@@ -1539,7 +1534,7 @@ def _clear_id_cache(node):
152 if node.nodeType == Node.DOCUMENT_NODE:
153 node._id_cache.clear()
154 node._id_search_stack = None
155- elif _in_document(node):
156+ elif node.ownerDocument:
157 node.ownerDocument._id_cache.clear()
158 node.ownerDocument._id_search_stack= None
159
160diff --git a/Misc/NEWS.d/next/Security/2025-12-01-09-36-45.gh-issue-142145.tcAUhg.rst b/Misc/NEWS.d/next/Security/2025-12-01-09-36-45.gh-issue-142145.tcAUhg.rst
161new file mode 100644
162index 0000000000..05c7df35d1
163--- /dev/null
164+++ b/Misc/NEWS.d/next/Security/2025-12-01-09-36-45.gh-issue-142145.tcAUhg.rst
165@@ -0,0 +1,6 @@
166+Remove quadratic behavior in ``xml.minidom`` node ID cache clearing. In order
167+to do this without breaking existing users, we also add the *ownerDocument*
168+attribute to :mod:`xml.dom.minidom` elements and attributes created by directly
169+instantiating the ``Element`` or ``Attr`` class. Note that this way of creating
170+nodes is not supported; creator functions like
171+:py:meth:`xml.dom.Document.documentElement` should be used instead.
diff --git a/meta/recipes-devtools/python/python3_3.10.19.bb b/meta/recipes-devtools/python/python3_3.10.19.bb
index b87fc8d9ef..fbb2f80886 100644
--- a/meta/recipes-devtools/python/python3_3.10.19.bb
+++ b/meta/recipes-devtools/python/python3_3.10.19.bb
@@ -40,6 +40,7 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
40 file://CVE-2025-6075.patch \ 40 file://CVE-2025-6075.patch \
41 file://CVE-2025-13836.patch \ 41 file://CVE-2025-13836.patch \
42 file://CVE-2025-13837.patch \ 42 file://CVE-2025-13837.patch \
43 file://CVE-2025-12084.patch \
43 " 44 "
44 45
45SRC_URI:append:class-native = " \ 46SRC_URI:append:class-native = " \