Skip to content

Commit 5c969e7

Browse files
[AUTO-CHERRYPICK] Patch libsoup for CVE-2025-32914 [HIGH] - branch main (#13589)
Co-authored-by: kgodara912 <kshigodara@outlook.com>
1 parent 31b698a commit 5c969e7

2 files changed

Lines changed: 117 additions & 6 deletions

File tree

SPECS/libsoup/CVE-2025-32914.patch

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
From 5bfcf8157597f2d327050114fb37ff600004dbcf Mon Sep 17 00:00:00 2001
2+
From: Milan Crha <mcrha@redhat.com>
3+
Date: Tue, 15 Apr 2025 09:03:00 +0200
4+
Subject: [PATCH] multipart: Fix read out of buffer bounds under
5+
soup_multipart_new_from_message()
6+
7+
This is CVE-2025-32914, special crafted input can cause read out of buffer bounds
8+
of the body argument.
9+
10+
Closes #436
11+
---
12+
libsoup/soup-multipart.c | 2 +-
13+
tests/multipart-test.c | 58 ++++++++++++++++++++++++++++++++++++++++
14+
2 files changed, 59 insertions(+), 1 deletion(-)
15+
16+
diff --git a/libsoup/soup-multipart.c b/libsoup/soup-multipart.c
17+
index 2421c91f8..102ce3722 100644
18+
--- a/libsoup/soup-multipart.c
19+
+++ b/libsoup/soup-multipart.c
20+
@@ -173,7 +173,7 @@ soup_multipart_new_from_message (SoupMessageHeaders *headers,
21+
return NULL;
22+
}
23+
24+
- split = strstr (start, "\r\n\r\n");
25+
+ split = g_strstr_len (start, body_end - start, "\r\n\r\n");
26+
if (!split || split > end) {
27+
soup_multipart_free (multipart);
28+
return NULL;
29+
diff --git a/tests/multipart-test.c b/tests/multipart-test.c
30+
index 2c0e7e969..f5b986889 100644
31+
--- a/tests/multipart-test.c
32+
+++ b/tests/multipart-test.c
33+
@@ -471,6 +471,62 @@ test_multipart (gconstpointer data)
34+
loop = NULL;
35+
}
36+
37+
+static void
38+
+test_multipart_bounds_good (void)
39+
+{
40+
+ #define TEXT "line1\r\nline2"
41+
+ SoupMultipart *multipart;
42+
+ SoupMessageHeaders *headers, *set_headers = NULL;
43+
+ GBytes *bytes, *set_bytes = NULL;
44+
+ const char *raw_data = "--123\r\nContent-Type: text/plain;\r\n\r\n" TEXT "\r\n--123--\r\n";
45+
+ gboolean success;
46+
+
47+
+ headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
48+
+ soup_message_headers_append (headers, "Content-Type", "multipart/mixed; boundary=\"123\"");
49+
+
50+
+ bytes = g_bytes_new (raw_data, strlen (raw_data));
51+
+
52+
+ multipart = soup_multipart_new_from_message (headers, bytes);
53+
+
54+
+ g_assert_nonnull (multipart);
55+
+ g_assert_cmpint (soup_multipart_get_length (multipart), ==, 1);
56+
+ success = soup_multipart_get_part (multipart, 0, &set_headers, &set_bytes);
57+
+ g_assert_true (success);
58+
+ g_assert_nonnull (set_headers);
59+
+ g_assert_nonnull (set_bytes);
60+
+ g_assert_cmpint (strlen (TEXT), ==, g_bytes_get_size (set_bytes));
61+
+ g_assert_cmpstr ("text/plain", ==, soup_message_headers_get_content_type (set_headers, NULL));
62+
+ g_assert_cmpmem (TEXT, strlen (TEXT), g_bytes_get_data (set_bytes, NULL), g_bytes_get_size (set_bytes));
63+
+
64+
+ soup_message_headers_unref (headers);
65+
+ g_bytes_unref (bytes);
66+
+
67+
+ soup_multipart_free (multipart);
68+
+
69+
+ #undef TEXT
70+
+}
71+
+
72+
+static void
73+
+test_multipart_bounds_bad (void)
74+
+{
75+
+ SoupMultipart *multipart;
76+
+ SoupMessageHeaders *headers;
77+
+ GBytes *bytes;
78+
+ const char *raw_data = "--123\r\nContent-Type: text/plain;\r\nline1\r\nline2\r\n--123--\r\n";
79+
+
80+
+ headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
81+
+ soup_message_headers_append (headers, "Content-Type", "multipart/mixed; boundary=\"123\"");
82+
+
83+
+ bytes = g_bytes_new (raw_data, strlen (raw_data));
84+
+
85+
+ /* it did read out of raw_data/bytes bounds */
86+
+ multipart = soup_multipart_new_from_message (headers, bytes);
87+
+ g_assert_null (multipart);
88+
+
89+
+ soup_message_headers_unref (headers);
90+
+ g_bytes_unref (bytes);
91+
+}
92+
+
93+
int
94+
main (int argc, char **argv)
95+
{
96+
@@ -498,6 +554,8 @@ main (int argc, char **argv)
97+
g_test_add_data_func ("/multipart/sync", GINT_TO_POINTER (SYNC_MULTIPART), test_multipart);
98+
g_test_add_data_func ("/multipart/async", GINT_TO_POINTER (ASYNC_MULTIPART), test_multipart);
99+
g_test_add_data_func ("/multipart/async-small-reads", GINT_TO_POINTER (ASYNC_MULTIPART_SMALL_READS), test_multipart);
100+
+ g_test_add_func ("/multipart/bounds-good", test_multipart_bounds_good);
101+
+ g_test_add_func ("/multipart/bounds-bad", test_multipart_bounds_bad);
102+
103+
ret = g_test_run ();
104+
105+
--
106+
GitLab
107+

SPECS/libsoup/libsoup.spec

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
Summary: libsoup HTTP client/server library
33
Name: libsoup
44
Version: %{BaseVersion}.4
5-
Release: 3%{?dist}
5+
Release: 4%{?dist}
66
License: GPLv2
77
Vendor: Microsoft Corporation
88
Distribution: Mariner
99
Group: System Environment/Development
1010
URL: https://wiki.gnome.org/LibSoup
1111
Source0: https://ftp.gnome.org/pub/GNOME/sources/libsoup/%{BaseVersion}/%{name}-%{version}.tar.xz
1212

13-
Patch: CVE-2024-52530.patch
14-
Patch: CVE-2024-52531.patch
15-
Patch: CVE-2024-52532.patch
13+
Patch0: CVE-2024-52530.patch
14+
Patch1: CVE-2024-52531.patch
15+
Patch2: CVE-2024-52532.patch
1616
# CVE-2025-32913 will be fixed in 3.6.2 by https://gitlab.gnome.org/GNOME/libsoup/-/commit/f4a761fb66512fff59798765e8ac5b9e57dceef0
17-
Patch: CVE-2025-32913.patch
17+
Patch3: CVE-2025-32913.patch
1818
# CVE-2025-32906 will be fixed in 3.6.5 by https://gitlab.gnome.org/GNOME/libsoup/-/commit/af5b9a4a3945c52b940d5ac181ef51bb12011f1f
19-
Patch: CVE-2025-32906.patch
19+
Patch4: CVE-2025-32906.patch
20+
Patch5: CVE-2025-32914.patch
2021

2122
BuildRequires: meson
2223
BuildRequires: autogen
@@ -128,6 +129,9 @@ find %{buildroot} -type f -name "*.la" -delete -print
128129
%defattr(-,root,root)
129130

130131
%changelog
132+
* Fri Apr 25 2025 Kshitiz Godara <kgodara@microsoft.com> - 3.0.4-4
133+
- Add patch for CVE-2025-32914
134+
131135
* Wed Apr 16 2025 Kevin Lockwood <v-klockwood@microsoft.com> - 3.0.4-3
132136
- Add patch for CVE-2025-32913
133137
- Add patch for CVE-2025-32906

0 commit comments

Comments
 (0)