Skip to content

Commit 26492a0

Browse files
[AUTO-CHERRYPICK] Patch libsoup for CVE-2025-32908, CVE-2025-32914 [HIGH] - branch 3.0-dev (#13594)
Co-authored-by: kgodara912 <kshigodara@outlook.com>
1 parent a3ae661 commit 26492a0

3 files changed

Lines changed: 197 additions & 1 deletion

File tree

SPECS/libsoup/CVE-2025-32908.patch

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
From a792b23ab87cacbf4dd9462bf7b675fa678efbae Mon Sep 17 00:00:00 2001
2+
From: Milan Crha <mcrha@redhat.com>
3+
Date: Tue, 15 Apr 2025 09:59:05 +0200
4+
Subject: [PATCH] soup-server-http2: Check validity of the constructed
5+
connection URI
6+
7+
The HTTP/2 pseudo-headers can contain invalid values, which the GUri rejects
8+
and returns NULL, but the soup-server did not check the validity and could
9+
abort the server itself later in the code.
10+
11+
Closes #429
12+
---
13+
.../http2/soup-server-message-io-http2.c | 4 +++
14+
tests/http2-test.c | 28 +++++++++++++++++++
15+
2 files changed, 32 insertions(+)
16+
17+
diff --git a/libsoup/server/http2/soup-server-message-io-http2.c b/libsoup/server/http2/soup-server-message-io-http2.c
18+
index 943ecfd3..f1fe2d5c 100644
19+
--- a/libsoup/server/http2/soup-server-message-io-http2.c
20+
+++ b/libsoup/server/http2/soup-server-message-io-http2.c
21+
@@ -771,9 +771,13 @@ on_frame_recv_callback (nghttp2_session *session,
22+
char *uri_string;
23+
GUri *uri;
24+
25+
+ if (msg_io->scheme == NULL || msg_io->authority == NULL || msg_io->path == NULL)
26+
+ return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
27+
uri_string = g_strdup_printf ("%s://%s%s", msg_io->scheme, msg_io->authority, msg_io->path);
28+
uri = g_uri_parse (uri_string, SOUP_HTTP_URI_FLAGS, NULL);
29+
g_free (uri_string);
30+
+ if (uri == NULL)
31+
+ return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
32+
soup_server_message_set_uri (msg_io->msg, uri);
33+
g_uri_unref (uri);
34+
35+
diff --git a/tests/http2-test.c b/tests/http2-test.c
36+
index 5b6da5e4..ec7972fe 100644
37+
--- a/tests/http2-test.c
38+
+++ b/tests/http2-test.c
39+
@@ -1341,6 +1341,30 @@ do_connection_closed_test (Test *test, gconstpointer data)
40+
g_uri_unref (uri);
41+
}
42+
43+
+static void
44+
+do_broken_pseudo_header_test (Test *test, gconstpointer data)
45+
+{
46+
+ char *path;
47+
+ SoupMessage *msg;
48+
+ GUri *uri;
49+
+ GBytes *body = NULL;
50+
+ GError *error = NULL;
51+
+
52+
+ uri = g_uri_parse_relative (base_uri, "/ag", SOUP_HTTP_URI_FLAGS, NULL);
53+
+
54+
+ /* an ugly cheat to construct a broken URI, which can be sent from other libs */
55+
+ path = (char *) g_uri_get_path (uri);
56+
+ path[1] = '%';
57+
+
58+
+ msg = soup_message_new_from_uri (SOUP_METHOD_GET, uri);
59+
+ body = soup_test_session_async_send (test->session, msg, NULL, &error);
60+
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PARTIAL_INPUT);
61+
+ g_assert_null (body);
62+
+ g_clear_error (&error);
63+
+ g_object_unref (msg);
64+
+ g_uri_unref (uri);
65+
+}
66+
+
67+
static gboolean
68+
unpause_message (SoupServerMessage *msg)
69+
{
70+
@@ -1662,6 +1686,10 @@ main (int argc, char **argv)
71+
setup_session,
72+
do_connection_closed_test,
73+
teardown_session);
74+
+ g_test_add ("/http2/broken-pseudo-header", Test, NULL,
75+
+ setup_session,
76+
+ do_broken_pseudo_header_test,
77+
+ teardown_session);
78+
79+
ret = g_test_run ();
80+
81+
--
82+
GitLab
83+

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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary: libsoup HTTP client/server library
55
Name: libsoup
66
Version: 3.4.4
7-
Release: 3%{?dist}
7+
Release: 4%{?dist}
88
License: GPLv2
99
Vendor: Microsoft Corporation
1010
Distribution: Azure Linux
@@ -54,6 +54,8 @@ Patch5: CVE-2025-32909.patch
5454
Patch6: CVE-2025-32910.patch
5555
# CVE-2025-32912 will be fixed in 3.6.5 by https://gitlab.gnome.org/GNOME/libsoup/-/commit/cd077513f267e43ce4b659eb18a1734d8a369992
5656
Patch7: CVE-2025-32912.patch
57+
Patch8: CVE-2025-32908.patch
58+
Patch9: CVE-2025-32914.patch
5759

5860
%description
5961
libsoup is HTTP client/server library for GNOME
@@ -121,6 +123,10 @@ find %{buildroot} -type f -name "*.la" -delete -print
121123
%defattr(-,root,root)
122124

123125
%changelog
126+
* Fri Apr 25 2025 Kshitiz Godara <kgodara@microsoft.com> - 3.4.4-4
127+
- Add patch for CVE-2025-32908
128+
- Add patch for CVE-2025-32914
129+
124130
* Wed Apr 16 2025 Kevin Lockwood <v-klockwood@microsoft.com> - 3.4.4-3
125131
- Add patch for CVE-2025-32913
126132
- Add patch for CVE-2025-32906

0 commit comments

Comments
 (0)