Skip to content

Commit adaaf9b

Browse files
authored
[Medium] Patch libxml2 for CVE-2025-32414 and CVE-2025-32415 (#13497)
Signed-off-by: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
1 parent 63c72aa commit adaaf9b

7 files changed

Lines changed: 126 additions & 13 deletions

File tree

SPECS/libxml2/CVE-2025-32414.patch

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
From df738c6288e9f48f299569016cf4e2716543ecea Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Fri, 18 Apr 2025 17:44:25 -0500
4+
Subject: [PATCH] Address CVE-2025-32414
5+
Upstream Patch Reference: https://gitlab.gnome.org/GNOME/libxml2/-/commit/8d415b8911be26b12b85497f7cc57143b5321787.patch
6+
7+
---
8+
python/libxml.c | 28 ++++++++++++++++++----------
9+
1 file changed, 18 insertions(+), 10 deletions(-)
10+
11+
diff --git a/python/libxml.c b/python/libxml.c
12+
index fb14c7a..ebd51ef 100644
13+
--- a/python/libxml.c
14+
+++ b/python/libxml.c
15+
@@ -266,7 +266,9 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) {
16+
#endif
17+
file = (PyObject *) context;
18+
if (file == NULL) return(-1);
19+
- ret = PyObject_CallMethod(file, (char *) "read", (char *) "(i)", len);
20+
+ /* When read() returns a string, the length is in characters not bytes, so
21+
+ request at most len / 4 characters to leave space for UTF-8 encoding. */
22+
+ ret = PyObject_CallMethod(file, (char *) "read", (char *) "(i)", len / 4);
23+
if (ret == NULL) {
24+
printf("xmlPythonFileReadRaw: result is NULL\n");
25+
return(-1);
26+
@@ -301,10 +303,12 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) {
27+
Py_DECREF(ret);
28+
return(-1);
29+
}
30+
- if (lenread > len)
31+
- memcpy(buffer, data, len);
32+
- else
33+
- memcpy(buffer, data, lenread);
34+
+ if (lenread < 0 || lenread > len) {
35+
+ printf("xmlPythonFileReadRaw: invalid lenread\n");
36+
+ Py_DECREF(ret);
37+
+ return(-1);
38+
+ }
39+
+ memcpy(buffer, data, lenread);
40+
Py_DECREF(ret);
41+
return(lenread);
42+
}
43+
@@ -331,7 +335,9 @@ xmlPythonFileRead (void * context, char * buffer, int len) {
44+
#endif
45+
file = (PyObject *) context;
46+
if (file == NULL) return(-1);
47+
- ret = PyObject_CallMethod(file, (char *) "io_read", (char *) "(i)", len);
48+
+ /* When read() returns a string, the length is in characters not bytes, so
49+
+ request at most len / 4 characters to leave space for UTF-8 encoding. */
50+
+ ret = PyObject_CallMethod(file, (char *) "io_read", (char *) "(i)", len / 4);
51+
if (ret == NULL) {
52+
printf("xmlPythonFileRead: result is NULL\n");
53+
return(-1);
54+
@@ -366,10 +372,12 @@ xmlPythonFileRead (void * context, char * buffer, int len) {
55+
Py_DECREF(ret);
56+
return(-1);
57+
}
58+
- if (lenread > len)
59+
- memcpy(buffer, data, len);
60+
- else
61+
- memcpy(buffer, data, lenread);
62+
+ if (lenread < 0 || lenread > len) {
63+
+ printf("xmlPythonFileRead: invalid lenread\n");
64+
+ Py_DECREF(ret);
65+
+ return(-1);
66+
+ }
67+
+ memcpy(buffer, data, lenread);
68+
Py_DECREF(ret);
69+
return(lenread);
70+
}
71+
--
72+
2.45.2
73+

SPECS/libxml2/CVE-2025-32415.patch

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
From 1237c9a36a0037553574b80641e653e46022b737 Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Mon, 5 May 2025 11:35:22 -0500
4+
Subject: [PATCH] Address CVE-2025-32415
5+
Upstream Patch Reference: https://gitlab.gnome.org/GNOME/libxml2/-/commit/487ee1d8711c6415218b373ef455fcd969d12399
6+
7+
---
8+
xmlschemas.c | 4 ++--
9+
1 file changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/xmlschemas.c b/xmlschemas.c
12+
index 8a89e2a..40536bc 100644
13+
--- a/xmlschemas.c
14+
+++ b/xmlschemas.c
15+
@@ -23632,7 +23632,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
16+
j++;
17+
} while (j < nbDupls);
18+
}
19+
- if (nbNodeTable) {
20+
+ if (bind->nbNodes) {
21+
j = 0;
22+
do {
23+
if (nbFields == 1) {
24+
@@ -23683,7 +23683,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
25+
26+
next_node_table_entry:
27+
j++;
28+
- } while (j < nbNodeTable);
29+
+ } while (j < bind->nbNodes);
30+
}
31+
/*
32+
* If everything is fine, then add the IDC target-node to
33+
--
34+
2.45.2
35+

SPECS/libxml2/libxml2.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Libxml2
22
Name: libxml2
33
Version: 2.11.5
4-
Release: 4%{?dist}
4+
Release: 5%{?dist}
55
License: MIT
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -15,6 +15,8 @@ Patch3: CVE-2024-56171.patch
1515
Patch4: CVE-2025-24928.patch
1616
Patch5: CVE-2024-25062.patch
1717
Patch6: CVE-2025-27113.patch
18+
Patch7: CVE-2025-32414.patch
19+
Patch8: CVE-2025-32415.patch
1820
BuildRequires: python3-devel
1921
BuildRequires: python3-xml
2022
Provides: %{name}-tools = %{version}-%{release}
@@ -85,6 +87,9 @@ find %{buildroot} -type f -name "*.la" -delete -print
8587
%{_libdir}/cmake/libxml2/libxml2-config.cmake
8688

8789
%changelog
90+
* Mon May 05 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 2.11.5-5
91+
- Patch CVE-2025-32414 and CVE-2025-32415
92+
8893
* Sat Feb 22 2025 Kanishk Bansal <kanbansal@microsoft.com> - 2.11.5-4
8994
- Patch CVE-2025-24928, CVE-2024-56171, CVE-2024-25062, CVE-2025-27113
9095

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ curl-8.11.1-3.azl3.aarch64.rpm
203203
curl-devel-8.11.1-3.azl3.aarch64.rpm
204204
curl-libs-8.11.1-3.azl3.aarch64.rpm
205205
createrepo_c-1.0.3-1.azl3.aarch64.rpm
206-
libxml2-2.11.5-4.azl3.aarch64.rpm
207-
libxml2-devel-2.11.5-4.azl3.aarch64.rpm
206+
libxml2-2.11.5-5.azl3.aarch64.rpm
207+
libxml2-devel-2.11.5-5.azl3.aarch64.rpm
208208
docbook-dtd-xml-4.5-11.azl3.noarch.rpm
209209
docbook-style-xsl-1.79.1-14.azl3.noarch.rpm
210210
libsepol-3.6-2.azl3.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ curl-8.11.1-3.azl3.x86_64.rpm
203203
curl-devel-8.11.1-3.azl3.x86_64.rpm
204204
curl-libs-8.11.1-3.azl3.x86_64.rpm
205205
createrepo_c-1.0.3-1.azl3.x86_64.rpm
206-
libxml2-2.11.5-4.azl3.x86_64.rpm
207-
libxml2-devel-2.11.5-4.azl3.x86_64.rpm
206+
libxml2-2.11.5-5.azl3.x86_64.rpm
207+
libxml2-devel-2.11.5-5.azl3.x86_64.rpm
208208
docbook-dtd-xml-4.5-11.azl3.noarch.rpm
209209
docbook-style-xsl-1.79.1-14.azl3.noarch.rpm
210210
libsepol-3.6-2.azl3.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ libtool-debuginfo-2.4.7-1.azl3.aarch64.rpm
242242
libxcrypt-4.4.36-2.azl3.aarch64.rpm
243243
libxcrypt-debuginfo-4.4.36-2.azl3.aarch64.rpm
244244
libxcrypt-devel-4.4.36-2.azl3.aarch64.rpm
245-
libxml2-2.11.5-4.azl3.aarch64.rpm
246-
libxml2-debuginfo-2.11.5-4.azl3.aarch64.rpm
247-
libxml2-devel-2.11.5-4.azl3.aarch64.rpm
245+
libxml2-2.11.5-5.azl3.aarch64.rpm
246+
libxml2-debuginfo-2.11.5-5.azl3.aarch64.rpm
247+
libxml2-devel-2.11.5-5.azl3.aarch64.rpm
248248
libxslt-1.1.43-1.azl3.aarch64.rpm
249249
libxslt-debuginfo-1.1.43-1.azl3.aarch64.rpm
250250
libxslt-devel-1.1.43-1.azl3.aarch64.rpm
@@ -543,7 +543,7 @@ python3-gpg-1.23.2-2.azl3.aarch64.rpm
543543
python3-jinja2-3.1.2-3.azl3.noarch.rpm
544544
python3-libcap-ng-0.8.4-1.azl3.aarch64.rpm
545545
python3-libs-3.12.9-1.azl3.aarch64.rpm
546-
python3-libxml2-2.11.5-4.azl3.aarch64.rpm
546+
python3-libxml2-2.11.5-5.azl3.aarch64.rpm
547547
python3-lxml-4.9.3-1.azl3.aarch64.rpm
548548
python3-magic-5.45-1.azl3.noarch.rpm
549549
python3-markupsafe-2.1.3-1.azl3.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ libtasn1-debuginfo-4.19.0-2.azl3.x86_64.rpm
247247
libtasn1-devel-4.19.0-2.azl3.x86_64.rpm
248248
libtool-2.4.7-1.azl3.x86_64.rpm
249249
libtool-debuginfo-2.4.7-1.azl3.x86_64.rpm
250-
libxml2-2.11.5-4.azl3.x86_64.rpm
251-
libxml2-debuginfo-2.11.5-4.azl3.x86_64.rpm
252-
libxml2-devel-2.11.5-4.azl3.x86_64.rpm
250+
libxml2-2.11.5-5.azl3.x86_64.rpm
251+
libxml2-debuginfo-2.11.5-5.azl3.x86_64.rpm
252+
libxml2-devel-2.11.5-5.azl3.x86_64.rpm
253253
libxcrypt-4.4.36-2.azl3.x86_64.rpm
254254
libxcrypt-debuginfo-4.4.36-2.azl3.x86_64.rpm
255255
libxcrypt-devel-4.4.36-2.azl3.x86_64.rpm
@@ -551,7 +551,7 @@ python3-gpg-1.23.2-2.azl3.x86_64.rpm
551551
python3-jinja2-3.1.2-3.azl3.noarch.rpm
552552
python3-libcap-ng-0.8.4-1.azl3.x86_64.rpm
553553
python3-libs-3.12.9-1.azl3.x86_64.rpm
554-
python3-libxml2-2.11.5-4.azl3.x86_64.rpm
554+
python3-libxml2-2.11.5-5.azl3.x86_64.rpm
555555
python3-lxml-4.9.3-1.azl3.x86_64.rpm
556556
python3-magic-5.45-1.azl3.noarch.rpm
557557
python3-markupsafe-2.1.3-1.azl3.x86_64.rpm

0 commit comments

Comments
 (0)