Skip to content

Commit 52fdb01

Browse files
CBL-Mariner-Botazurelinux-securityKanishk-Bansaljslobodzian
authored
[AUTO-CHERRYPICK] [AutoPR- Security] Patch glib for CVE-2025-13601 [HIGH] - branch 3.0-dev (#15191)
Co-authored-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com> Co-authored-by: jslobodzian <joslobo@microsoft.com>
1 parent c2b6667 commit 52fdb01

File tree

6 files changed

+153
-14
lines changed

6 files changed

+153
-14
lines changed

SPECS/glib/CVE-2025-13601.patch

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
From 6952e891aa6fa1bcac5ccba7cebc29e76e453c02 Mon Sep 17 00:00:00 2001
2+
From: Philip Withnall <pwithnall@gnome.org>
3+
Date: Thu, 13 Nov 2025 18:27:22 +0000
4+
Subject: [PATCH] gconvert: Error out if g_escape_uri_string() would overflow
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
If the string to escape contains a very large number of unacceptable
10+
characters (which would need escaping), the calculation of the length of
11+
the escaped string could overflow, leading to a potential write off the
12+
end of the newly allocated string.
13+
14+
In addition to that, the number of unacceptable characters was counted
15+
in a signed integer, which would overflow to become negative, making it
16+
easier for an attacker to craft an input string which would cause an
17+
out-of-bounds write.
18+
19+
Fix that by validating the allocation length, and using an unsigned
20+
integer to count the number of unacceptable characters.
21+
22+
Spotted by treeplus. Thanks to the Sovereign Tech Resilience programme
23+
from the Sovereign Tech Agency. ID: #YWH-PGM9867-134
24+
25+
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
26+
27+
Fixes: #3827
28+
29+
Backport 2.86: Changed the translatable error message to re-use an
30+
existing translatable string, to avoid adding new translatable strings
31+
to a stable branch. The re-used string doesn’t perfectly match the
32+
error, but it’s good enough given that no users will ever see it.
33+
34+
Signed-off-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com>
35+
Upstream-reference: https://gitlab.gnome.org/GNOME/glib/-/commit/9bcd65ba5fa1b92ff0fb8380faea335ccef56253.patch
36+
---
37+
glib/gconvert.c | 36 +++++++++++++++++++++++++-----------
38+
1 file changed, 25 insertions(+), 11 deletions(-)
39+
40+
diff --git a/glib/gconvert.c b/glib/gconvert.c
41+
index 69bcc2f..d43631c 100644
42+
--- a/glib/gconvert.c
43+
+++ b/glib/gconvert.c
44+
@@ -1428,8 +1428,9 @@ static const gchar hex[] = "0123456789ABCDEF";
45+
/* Note: This escape function works on file: URIs, but if you want to
46+
* escape something else, please read RFC-2396 */
47+
static gchar *
48+
-g_escape_uri_string (const gchar *string,
49+
- UnsafeCharacterSet mask)
50+
+g_escape_uri_string (const gchar *string,
51+
+ UnsafeCharacterSet mask,
52+
+ GError **error)
53+
{
54+
#define ACCEPTABLE(a) ((a)>=32 && (a)<128 && (acceptable[(a)-32] & use_mask))
55+
56+
@@ -1437,7 +1438,7 @@ g_escape_uri_string (const gchar *string,
57+
gchar *q;
58+
gchar *result;
59+
int c;
60+
- gint unacceptable;
61+
+ size_t unacceptable;
62+
UnsafeCharacterSet use_mask;
63+
64+
g_return_val_if_fail (mask == UNSAFE_ALL
65+
@@ -1454,7 +1455,14 @@ g_escape_uri_string (const gchar *string,
66+
if (!ACCEPTABLE (c))
67+
unacceptable++;
68+
}
69+
-
70+
+
71+
+ if (unacceptable >= (G_MAXSIZE - (p - string)) / 2)
72+
+ {
73+
+ g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_BAD_URI,
74+
+ _("Invalid hostname"));
75+
+ return NULL;
76+
+ }
77+
+
78+
result = g_malloc (p - string + unacceptable * 2 + 1);
79+
80+
use_mask = mask;
81+
@@ -1479,12 +1487,13 @@ g_escape_uri_string (const gchar *string,
82+
83+
84+
static gchar *
85+
-g_escape_file_uri (const gchar *hostname,
86+
- const gchar *pathname)
87+
+g_escape_file_uri (const gchar *hostname,
88+
+ const gchar *pathname,
89+
+ GError **error)
90+
{
91+
char *escaped_hostname = NULL;
92+
- char *escaped_path;
93+
- char *res;
94+
+ char *escaped_path = NULL;
95+
+ char *res = NULL;
96+
97+
#ifdef G_OS_WIN32
98+
char *p, *backslash;
99+
@@ -1505,10 +1514,14 @@ g_escape_file_uri (const gchar *hostname,
100+
101+
if (hostname && *hostname != '\0')
102+
{
103+
- escaped_hostname = g_escape_uri_string (hostname, UNSAFE_HOST);
104+
+ escaped_hostname = g_escape_uri_string (hostname, UNSAFE_HOST, error);
105+
+ if (escaped_hostname == NULL)
106+
+ goto out;
107+
}
108+
109+
- escaped_path = g_escape_uri_string (pathname, UNSAFE_PATH);
110+
+ escaped_path = g_escape_uri_string (pathname, UNSAFE_PATH, error);
111+
+ if (escaped_path == NULL)
112+
+ goto out;
113+
114+
res = g_strconcat ("file://",
115+
(escaped_hostname) ? escaped_hostname : "",
116+
@@ -1516,6 +1529,7 @@ g_escape_file_uri (const gchar *hostname,
117+
escaped_path,
118+
NULL);
119+
120+
+out:
121+
#ifdef G_OS_WIN32
122+
g_free ((char *) pathname);
123+
#endif
124+
@@ -1849,7 +1863,7 @@ g_filename_to_uri (const gchar *filename,
125+
hostname = NULL;
126+
#endif
127+
128+
- escaped_uri = g_escape_file_uri (hostname, filename);
129+
+ escaped_uri = g_escape_file_uri (hostname, filename, error);
130+
131+
return escaped_uri;
132+
}
133+
--
134+
2.45.4
135+

SPECS/glib/glib.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Summary: Low-level libraries useful for providing data structure handling for C.
33
Name: glib
44
Version: 2.78.6
5-
Release: 4%{?dist}
5+
Release: 5%{?dist}
66
License: LGPLv2+
77
Vendor: Microsoft Corporation
88
Distribution: Azure Linux
@@ -14,6 +14,7 @@ Patch1: CVE-2025-3360.patch
1414
Patch2: CVE-2025-4373.patch
1515
Patch3: CVE-2025-6052.patch
1616
Patch4: CVE-2025-7039.patch
17+
Patch5: CVE-2025-13601.patch
1718
BuildRequires: cmake
1819
BuildRequires: gtk-doc
1920
BuildRequires: libffi-devel
@@ -126,6 +127,9 @@ touch %{buildroot}%{_libdir}/gio/modules/giomodule.cache
126127
%doc %{_datadir}/gtk-doc/html/*
127128

128129
%changelog
130+
* Sat Nov 29 2025 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 2.78.6-5
131+
- Patch for CVE-2025-13601
132+
129133
* Mon Sep 08 2025 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 2.78.6-4
130134
- Patch for CVE-2025-7039
131135

@@ -171,7 +175,7 @@ touch %{buildroot}%{_libdir}/gio/modules/giomodule.cache
171175
* Wed May 19 2021 Thomas Crain <thcrain@microsoft.com> - 2.60.1-4
172176
- Require schemas subpackage from devel subpackage
173177

174-
* Fri Apr 27 2021 Thomas Crain <thcrain@microsoft.com> - 2.60.1-3
178+
* Tue Apr 27 2021 Thomas Crain <thcrain@microsoft.com> - 2.60.1-3
175179
- Remove CVE-2019-13012 patch (already in the this version)
176180
- Exclude doubly-packaged files from devel subpackage
177181
- Merge the following releases from 1.0 to dev branch

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ libxml2-devel-2.11.5-7.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
211-
glib-2.78.6-4.azl3.aarch64.rpm
211+
glib-2.78.6-5.azl3.aarch64.rpm
212212
libltdl-2.4.7-1.azl3.aarch64.rpm
213213
libltdl-devel-2.4.7-1.azl3.aarch64.rpm
214214
lua-5.4.6-1.azl3.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ libxml2-devel-2.11.5-7.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
211-
glib-2.78.6-4.azl3.x86_64.rpm
211+
glib-2.78.6-5.azl3.x86_64.rpm
212212
libltdl-2.4.7-1.azl3.x86_64.rpm
213213
libltdl-devel-2.4.7-1.azl3.x86_64.rpm
214214
lua-5.4.6-1.azl3.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ gdbm-lang-1.23-1.azl3.aarch64.rpm
122122
gettext-0.22-1.azl3.aarch64.rpm
123123
gettext-debuginfo-0.22-1.azl3.aarch64.rpm
124124
gfortran-13.2.0-7.azl3.aarch64.rpm
125-
glib-2.78.6-4.azl3.aarch64.rpm
126-
glib-debuginfo-2.78.6-4.azl3.aarch64.rpm
127-
glib-devel-2.78.6-4.azl3.aarch64.rpm
128-
glib-doc-2.78.6-4.azl3.noarch.rpm
129-
glib-schemas-2.78.6-4.azl3.aarch64.rpm
125+
glib-2.78.6-5.azl3.aarch64.rpm
126+
glib-debuginfo-2.78.6-5.azl3.aarch64.rpm
127+
glib-devel-2.78.6-5.azl3.aarch64.rpm
128+
glib-doc-2.78.6-5.azl3.noarch.rpm
129+
glib-schemas-2.78.6-5.azl3.aarch64.rpm
130130
glibc-2.38-16.azl3.aarch64.rpm
131131
glibc-debuginfo-2.38-16.azl3.aarch64.rpm
132132
glibc-devel-2.38-16.azl3.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ gdbm-lang-1.23-1.azl3.x86_64.rpm
129129
gettext-0.22-1.azl3.x86_64.rpm
130130
gettext-debuginfo-0.22-1.azl3.x86_64.rpm
131131
gfortran-13.2.0-7.azl3.x86_64.rpm
132-
glib-2.78.6-4.azl3.x86_64.rpm
133-
glib-debuginfo-2.78.6-4.azl3.x86_64.rpm
134-
glib-devel-2.78.6-4.azl3.x86_64.rpm
135-
glib-doc-2.78.6-4.azl3.noarch.rpm
136-
glib-schemas-2.78.6-4.azl3.x86_64.rpm
132+
glib-2.78.6-5.azl3.x86_64.rpm
133+
glib-debuginfo-2.78.6-5.azl3.x86_64.rpm
134+
glib-devel-2.78.6-5.azl3.x86_64.rpm
135+
glib-doc-2.78.6-5.azl3.noarch.rpm
136+
glib-schemas-2.78.6-5.azl3.x86_64.rpm
137137
glibc-2.38-16.azl3.x86_64.rpm
138138
glibc-debuginfo-2.38-16.azl3.x86_64.rpm
139139
glibc-devel-2.38-16.azl3.x86_64.rpm

0 commit comments

Comments
 (0)