fix CVE-2025-32907 CVE-2025-32914

This commit is contained in:
zppzhangpan 2025-04-23 15:57:40 +08:00
parent 302f07fbdb
commit 5eaf0ca38c
3 changed files with 156 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From 446b2e0a97ac1c241e9c58545f1b0f5f962d98e2 Mon Sep 17 00:00:00 2001
From: Milan Crha <mcrha@redhat.com>
Date: Tue, 15 Apr 2025 12:17:39 +0200
Subject: [PATCH] soup-message-headers: Correct merge of ranges
It had been skipping every second range, which generated an array
of a lot of insane ranges, causing large memory usage by the server.
Closes #428
Conflict: The new test case community is still in discussion and it is recommended not to merge
Reference: https://gitlab.gnome.org/GNOME/libsoup/-/commit/446b2e0a97ac1c241e9c58545f1b0f5f962d98e2
---
libsoup/soup-message-headers.c | 1 +
1 files changed, 1 insertions(+)
diff --git a/libsoup/soup-message-headers.c b/libsoup/soup-message-headers.c
index ee7a3cb1..f101d4b4 100644
--- a/libsoup/soup-message-headers.c
+++ b/libsoup/soup-message-headers.c
@@ -1244,6 +1244,7 @@ soup_message_headers_get_ranges_internal (SoupMessageHeaders *hdrs,
if (cur->start <= prev->end) {
prev->end = MAX (prev->end, cur->end);
g_array_remove_index (array, i);
+ i--;
}
}
}
--
GitLab

View File

@ -0,0 +1,115 @@
From 5bfcf8157597f2d327050114fb37ff600004dbcf Mon Sep 17 00:00:00 2001
From: Milan Crha <mcrha@redhat.com>
Date: Tue, 15 Apr 2025 09:03:00 +0200
Subject: [PATCH] multipart: Fix read out of buffer bounds under
soup_multipart_new_from_message()
This is CVE-2025-32914, special crafted input can cause read out of buffer bounds
of the body argument.
Closes #436
Conflict: Context Adaptation and Test Case Adaptation
Reference: https://gitlab.gnome.org/GNOME/libsoup/-/commit/5bfcf8157597f2d327050114fb37ff600004dbcf
---
libsoup/soup-multipart.c | 2 +-
tests/multipart-test.c | 62 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/libsoup/soup-multipart.c b/libsoup/soup-multipart.c
index a7e550f..dd93973 100644
--- a/libsoup/soup-multipart.c
+++ b/libsoup/soup-multipart.c
@@ -181,7 +181,7 @@ soup_multipart_new_from_message (SoupMessageHeaders *headers,
return NULL;
}
- split = strstr (start, "\r\n\r\n");
+ split = g_strstr_len (start, body_end - start, "\r\n\r\n");
if (!split || split > end) {
soup_multipart_free (multipart);
soup_buffer_free (flattened);
diff --git a/tests/multipart-test.c b/tests/multipart-test.c
index 64a5ebf..79c2190 100644
--- a/tests/multipart-test.c
+++ b/tests/multipart-test.c
@@ -479,6 +479,66 @@ test_multipart (gconstpointer data)
g_main_loop_unref (loop);
}
+static void
+test_multipart_bounds_good (void)
+{
+ #define TEXT "line1\r\nline2"
+ SoupMultipart *multipart;
+ SoupMessageHeaders *headers, *set_headers = NULL;
+ SoupBuffer *set_bytes = NULL;
+ const char *raw_data = "--123\r\nContent-Type: text/plain;\r\n\r\n" TEXT "\r\n--123--\r\n";
+ gboolean success;
+
+ headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
+ soup_message_headers_append (headers, "Content-Type", "multipart/mixed; boundary=\"123\"");
+
+
+ SoupMessageBody *message_body = soup_message_body_new ();
+ SoupBuffer *part_body = soup_buffer_new (SOUP_MEMORY_COPY, raw_data, strlen(raw_data));
+ soup_message_body_append_buffer (message_body, part_body);
+ multipart = soup_multipart_new_from_message (headers, message_body);
+
+ g_assert_nonnull (multipart);
+ g_assert_cmpint (soup_multipart_get_length (multipart), ==, 1);
+ success = soup_multipart_get_part (multipart, 0, &set_headers, &set_bytes);
+ g_assert_true (success);
+ g_assert_nonnull (set_headers);
+ g_assert_nonnull (set_bytes);
+ g_assert_cmpint (strlen (TEXT), ==, set_bytes->length);
+ g_assert_cmpstr ("text/plain", ==, soup_message_headers_get_content_type (set_headers, NULL));
+ g_assert_cmpmem (TEXT, strlen (TEXT), set_bytes->data, set_bytes->length);
+
+ soup_message_headers_free (headers);
+ soup_message_body_free (message_body);
+ soup_buffer_free (part_body);
+ soup_multipart_free (multipart);
+
+ #undef TEXT
+}
+
+static void
+test_multipart_bounds_bad (void)
+{
+ SoupMultipart *multipart;
+ SoupMessageHeaders *headers;
+ const char *raw_data = "--123\r\nContent-Type: text/plain;\r\nline1\r\nline2\r\n--123--\r\n";
+
+ headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
+ soup_message_headers_append (headers, "Content-Type", "multipart/mixed; boundary=\"123\"");
+
+ SoupMessageBody *message_body = soup_message_body_new ();
+ SoupBuffer *part_body = soup_buffer_new (SOUP_MEMORY_COPY, raw_data, strlen(raw_data));
+ soup_message_body_append_buffer (message_body, part_body);
+ /* it did read out of raw_data/bytes bounds */
+ multipart = soup_multipart_new_from_message (headers, message_body);
+
+ g_assert_null (multipart);
+
+ soup_message_headers_free (headers);
+ soup_message_body_free (message_body);
+ soup_buffer_free (part_body);
+}
+
int
main (int argc, char **argv)
{
@@ -508,6 +568,8 @@ main (int argc, char **argv)
g_test_add_data_func ("/multipart/sync", GINT_TO_POINTER (SYNC_MULTIPART), test_multipart);
g_test_add_data_func ("/multipart/async", GINT_TO_POINTER (ASYNC_MULTIPART), test_multipart);
g_test_add_data_func ("/multipart/async-small-reads", GINT_TO_POINTER (ASYNC_MULTIPART_SMALL_READS), test_multipart);
+ g_test_add_func ("/multipart/bounds-good", test_multipart_bounds_good);
+ g_test_add_func ("/multipart/bounds-bad", test_multipart_bounds_bad);
ret = g_test_run ();
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: libsoup
Version: 2.74.3
Release: 7
Release: 8
Summary: An HTTP library implementation
License: LGPLv2
URL: https://wiki.gnome.org/Projects/libsoup
@ -36,6 +36,8 @@ Patch6021: backport-0006-CVE-2025-32912.patch
Patch6022: backport-Handle-sniffing-bytes-with-0-size.patch
Patch6023: backport-content-sniffer-empty-resources-should-be-considered-text-plain.patch
Patch6024: backport-CVE-2025-32909.patch
Patch6025: backport-CVE-2025-32914.patch
Patch6026: backport-CVE-2025-32907.patch
%description
libsoup is an HTTP client/server library for GNOME. It uses GObjects and the glib main loop,
@ -87,6 +89,12 @@ sed -i 's/idm[0-9]\{5,32\}/idm12345678912345/g' %{buildroot}%{_datadir}/gtk-doc/
%{_datadir}/gtk-doc/html/libsoup-2.4/*
%changelog
* Wed Apr 23 2025 zhangpan <zhangpan103@h-partners.com> - 2.74.3-8
- Type:cves
- ID:CVE-2025-32907 CVE-2025-32914
- SUG:NA
- DESC:fix CVE-2025-32907 CVE-2025-32914
* Mon Apr 21 2025 zhangpan <zhangpan103@h-partners.com> - 2.74.3-7
- Type:cves
- ID:CVE-2025-32906 CVE-2025-32909 CVE-2025-32910 CVE-2025-32911 CVE-2025-32912 CVE-2025-32913