diff options
author | Hitendra Prajapati <hprajapati@mvista.com> | 2025-07-09 14:35:35 +0530 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2025-07-21 09:07:21 -0700 |
commit | 6d2f2bd3f7bee907b616cd9ed4abc686155da72a (patch) | |
tree | 371f270e2797ef834599d2bc10f8041809d0962b | |
parent | ae2d52758fc2fcb0ed996aa234430464ebf4b310 (diff) | |
download | poky-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.patch | 186 | ||||
-rw-r--r-- | meta/recipes-core/libxml/libxml2_2.12.10.bb | 1 |
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 @@ | |||
1 | From 71e1e8af5ee46dad1b57bb96cfbf1c3ad21fbd7b Mon Sep 17 00:00:00 2001 | ||
2 | From: Nick Wellnhofer <wellnhofer@aevum.de> | ||
3 | Date: Fri, 4 Jul 2025 14:28:26 +0200 | ||
4 | Subject: [PATCH] schematron: Fix memory safety issues in | ||
5 | xmlSchematronReportOutput | ||
6 | |||
7 | Fix use-after-free (CVE-2025-49794) and type confusion (CVE-2025-49796) | ||
8 | in xmlSchematronReportOutput. | ||
9 | |||
10 | Fixes #931. | ||
11 | Fixes #933. | ||
12 | |||
13 | Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libxml2/-/commit/71e1e8af5ee46dad1b57bb96cfbf1c3ad21fbd7b] | ||
14 | CVE: CVE-2025-49794 CVE-2025-49796 | ||
15 | Signed-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 | |||
32 | diff --git a/result/schematron/cve-2025-49794_0.err b/result/schematron/cve-2025-49794_0.err | ||
33 | new file mode 100644 | ||
34 | index 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 | ||
40 | diff --git a/result/schematron/cve-2025-49796_0.err b/result/schematron/cve-2025-49796_0.err | ||
41 | new file mode 100644 | ||
42 | index 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 | ||
48 | diff --git a/schematron.c b/schematron.c | ||
49 | index 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; | ||
132 | diff --git a/test/schematron/cve-2025-49794.sct b/test/schematron/cve-2025-49794.sct | ||
133 | new file mode 100644 | ||
134 | index 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="	e|namespace::*|e"/> | ||
143 | + </sch:report> | ||
144 | + <sch:report test="0"></sch:report> | ||
145 | + </sch:rule> | ||
146 | + </sch:pattern> | ||
147 | +</sch:schema> | ||
148 | diff --git a/test/schematron/cve-2025-49794_0.xml b/test/schematron/cve-2025-49794_0.xml | ||
149 | new file mode 100644 | ||
150 | index 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> | ||
160 | diff --git a/test/schematron/cve-2025-49796.sct b/test/schematron/cve-2025-49796.sct | ||
161 | new file mode 100644 | ||
162 | index 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> | ||
175 | diff --git a/test/schematron/cve-2025-49796_0.xml b/test/schematron/cve-2025-49796_0.xml | ||
176 | new file mode 100644 | ||
177 | index 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 | -- | ||
185 | 2.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 | ||
26 | SRC_URI[archive.sha256sum] = "c3d8c0c34aa39098f66576fe51969db12a5100b956233dc56506f7a8679be995" | 27 | SRC_URI[archive.sha256sum] = "c3d8c0c34aa39098f66576fe51969db12a5100b956233dc56506f7a8679be995" |