summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHitendra Prajapati <hprajapati@mvista.com>2025-07-09 14:35:35 +0530
committerSteve Sakoman <steve@sakoman.com>2025-07-21 09:07:21 -0700
commit6d2f2bd3f7bee907b616cd9ed4abc686155da72a (patch)
tree371f270e2797ef834599d2bc10f8041809d0962b
parentae2d52758fc2fcb0ed996aa234430464ebf4b310 (diff)
downloadpoky-6d2f2bd3f7bee907b616cd9ed4abc686155da72a.tar.gz
libxml2: fix CVE-2025-49794 & CVE-2025-49796
Upstream-Status: Backport from https://gitlab.gnome.org/GNOME/libxml2/-/commit/71e1e8af5ee46dad1b57bb96cfbf1c3ad21fbd7b (From OE-Core rev: bb20ddc599314161f3bcd6d5479e81478ceaaa3a) Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-core/libxml/libxml2/CVE-2025-49794-CVE-2025-49796.patch186
-rw-r--r--meta/recipes-core/libxml/libxml2_2.12.10.bb1
2 files changed, 187 insertions, 0 deletions
diff --git a/meta/recipes-core/libxml/libxml2/CVE-2025-49794-CVE-2025-49796.patch b/meta/recipes-core/libxml/libxml2/CVE-2025-49794-CVE-2025-49796.patch
new file mode 100644
index 0000000000..881cac7f03
--- /dev/null
+++ b/meta/recipes-core/libxml/libxml2/CVE-2025-49794-CVE-2025-49796.patch
@@ -0,0 +1,186 @@
1From 71e1e8af5ee46dad1b57bb96cfbf1c3ad21fbd7b Mon Sep 17 00:00:00 2001
2From: Nick Wellnhofer <wellnhofer@aevum.de>
3Date: Fri, 4 Jul 2025 14:28:26 +0200
4Subject: [PATCH] schematron: Fix memory safety issues in
5 xmlSchematronReportOutput
6
7Fix use-after-free (CVE-2025-49794) and type confusion (CVE-2025-49796)
8in xmlSchematronReportOutput.
9
10Fixes #931.
11Fixes #933.
12
13Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libxml2/-/commit/71e1e8af5ee46dad1b57bb96cfbf1c3ad21fbd7b]
14CVE: CVE-2025-49794 CVE-2025-49796
15Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
16---
17 result/schematron/cve-2025-49794_0.err | 2 ++
18 result/schematron/cve-2025-49796_0.err | 2 ++
19 schematron.c | 49 ++++++++++++++------------
20 test/schematron/cve-2025-49794.sct | 10 ++++++
21 test/schematron/cve-2025-49794_0.xml | 6 ++++
22 test/schematron/cve-2025-49796.sct | 9 +++++
23 test/schematron/cve-2025-49796_0.xml | 3 ++
24 7 files changed, 58 insertions(+), 23 deletions(-)
25 create mode 100644 result/schematron/cve-2025-49794_0.err
26 create mode 100644 result/schematron/cve-2025-49796_0.err
27 create mode 100644 test/schematron/cve-2025-49794.sct
28 create mode 100644 test/schematron/cve-2025-49794_0.xml
29 create mode 100644 test/schematron/cve-2025-49796.sct
30 create mode 100644 test/schematron/cve-2025-49796_0.xml
31
32diff --git a/result/schematron/cve-2025-49794_0.err b/result/schematron/cve-2025-49794_0.err
33new file mode 100644
34index 0000000..5775231
35--- /dev/null
36+++ b/result/schematron/cve-2025-49794_0.err
37@@ -0,0 +1,2 @@
38+./test/schematron/cve-2025-49794_0.xml:2: element boo0: schematron error : /librar0/boo0 line 2:
39+./test/schematron/cve-2025-49794_0.xml fails to validate
40diff --git a/result/schematron/cve-2025-49796_0.err b/result/schematron/cve-2025-49796_0.err
41new file mode 100644
42index 0000000..bf875ee
43--- /dev/null
44+++ b/result/schematron/cve-2025-49796_0.err
45@@ -0,0 +1,2 @@
46+./test/schematron/cve-2025-49796_0.xml:2: element boo0: schematron error : /librar0/boo0 line 2:
47+./test/schematron/cve-2025-49796_0.xml fails to validate
48diff --git a/schematron.c b/schematron.c
49index a825920..411a515 100644
50--- a/schematron.c
51+++ b/schematron.c
52@@ -1389,27 +1389,15 @@ exit:
53 * *
54 ************************************************************************/
55
56-static xmlNodePtr
57+static xmlXPathObjectPtr
58 xmlSchematronGetNode(xmlSchematronValidCtxtPtr ctxt,
59 xmlNodePtr cur, const xmlChar *xpath) {
60- xmlNodePtr node = NULL;
61- xmlXPathObjectPtr ret;
62-
63 if ((ctxt == NULL) || (cur == NULL) || (xpath == NULL))
64 return(NULL);
65
66 ctxt->xctxt->doc = cur->doc;
67 ctxt->xctxt->node = cur;
68- ret = xmlXPathEval(xpath, ctxt->xctxt);
69- if (ret == NULL)
70- return(NULL);
71-
72- if ((ret->type == XPATH_NODESET) &&
73- (ret->nodesetval != NULL) && (ret->nodesetval->nodeNr > 0))
74- node = ret->nodesetval->nodeTab[0];
75-
76- xmlXPathFreeObject(ret);
77- return(node);
78+ return(xmlXPathEval(xpath, ctxt->xctxt));
79 }
80
81 /**
82@@ -1455,25 +1443,40 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
83 (child->type == XML_CDATA_SECTION_NODE))
84 ret = xmlStrcat(ret, child->content);
85 else if (IS_SCHEMATRON(child, "name")) {
86+ xmlXPathObject *obj = NULL;
87 xmlChar *path;
88
89 path = xmlGetNoNsProp(child, BAD_CAST "path");
90
91 node = cur;
92 if (path != NULL) {
93- node = xmlSchematronGetNode(ctxt, cur, path);
94- if (node == NULL)
95- node = cur;
96+ obj = xmlSchematronGetNode(ctxt, cur, path);
97+ if ((obj != NULL) &&
98+ (obj->type == XPATH_NODESET) &&
99+ (obj->nodesetval != NULL) &&
100+ (obj->nodesetval->nodeNr > 0))
101+ node = obj->nodesetval->nodeTab[0];
102 xmlFree(path);
103 }
104
105- if ((node->ns == NULL) || (node->ns->prefix == NULL))
106- ret = xmlStrcat(ret, node->name);
107- else {
108- ret = xmlStrcat(ret, node->ns->prefix);
109- ret = xmlStrcat(ret, BAD_CAST ":");
110- ret = xmlStrcat(ret, node->name);
111+ switch (node->type) {
112+ case XML_ELEMENT_NODE:
113+ case XML_ATTRIBUTE_NODE:
114+ if ((node->ns == NULL) || (node->ns->prefix == NULL))
115+ ret = xmlStrcat(ret, node->name);
116+ else {
117+ ret = xmlStrcat(ret, node->ns->prefix);
118+ ret = xmlStrcat(ret, BAD_CAST ":");
119+ ret = xmlStrcat(ret, node->name);
120+ }
121+ break;
122+
123+ /* TODO: handle other node types */
124+ default:
125+ break;
126 }
127+
128+ xmlXPathFreeObject(obj);
129 } else if (IS_SCHEMATRON(child, "value-of")) {
130 xmlChar *select;
131 xmlXPathObjectPtr eval;
132diff --git a/test/schematron/cve-2025-49794.sct b/test/schematron/cve-2025-49794.sct
133new file mode 100644
134index 0000000..7fc9ee3
135--- /dev/null
136+++ b/test/schematron/cve-2025-49794.sct
137@@ -0,0 +1,10 @@
138+<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
139+ <sch:pattern id="">
140+ <sch:rule context="boo0">
141+ <sch:report test="not(0)">
142+ <sch:name path="&#9;e|namespace::*|e"/>
143+ </sch:report>
144+ <sch:report test="0"></sch:report>
145+ </sch:rule>
146+ </sch:pattern>
147+</sch:schema>
148diff --git a/test/schematron/cve-2025-49794_0.xml b/test/schematron/cve-2025-49794_0.xml
149new file mode 100644
150index 0000000..debc64b
151--- /dev/null
152+++ b/test/schematron/cve-2025-49794_0.xml
153@@ -0,0 +1,6 @@
154+<librar0>
155+ <boo0 t="">
156+ <author></author>
157+ </boo0>
158+ <ins></ins>
159+</librar0>
160diff --git a/test/schematron/cve-2025-49796.sct b/test/schematron/cve-2025-49796.sct
161new file mode 100644
162index 0000000..e9702d7
163--- /dev/null
164+++ b/test/schematron/cve-2025-49796.sct
165@@ -0,0 +1,9 @@
166+<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
167+ <sch:pattern id="">
168+ <sch:rule context="boo0">
169+ <sch:report test="not(0)">
170+ <sch:name path="/"/>
171+ </sch:report>
172+ </sch:rule>
173+ </sch:pattern>
174+</sch:schema>
175diff --git a/test/schematron/cve-2025-49796_0.xml b/test/schematron/cve-2025-49796_0.xml
176new file mode 100644
177index 0000000..be33c4e
178--- /dev/null
179+++ b/test/schematron/cve-2025-49796_0.xml
180@@ -0,0 +1,3 @@
181+<librar0>
182+ <boo0/>
183+</librar0>
184--
1852.49.0
186
diff --git a/meta/recipes-core/libxml/libxml2_2.12.10.bb b/meta/recipes-core/libxml/libxml2_2.12.10.bb
index 1ecac70b4c..488ace62e5 100644
--- a/meta/recipes-core/libxml/libxml2_2.12.10.bb
+++ b/meta/recipes-core/libxml/libxml2_2.12.10.bb
@@ -21,6 +21,7 @@ SRC_URI += "http://www.w3.org/XML/Test/xmlts20130923.tar;subdir=${BP};name=testt
21 file://CVE-2025-32414.patch \ 21 file://CVE-2025-32414.patch \
22 file://CVE-2025-32415.patch \ 22 file://CVE-2025-32415.patch \
23 file://CVE-2025-6021.patch \ 23 file://CVE-2025-6021.patch \
24 file://CVE-2025-49794-CVE-2025-49796.patch \
24 " 25 "
25 26
26SRC_URI[archive.sha256sum] = "c3d8c0c34aa39098f66576fe51969db12a5100b956233dc56506f7a8679be995" 27SRC_URI[archive.sha256sum] = "c3d8c0c34aa39098f66576fe51969db12a5100b956233dc56506f7a8679be995"