]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
libsoup-2.4: Fix CVE-2025-32914
authorVijay Anusuri <vanusuri@mvista.com>
Thu, 22 May 2025 10:00:28 +0000 (15:30 +0530)
committerSteve Sakoman <steve@sakoman.com>
Fri, 23 May 2025 15:25:40 +0000 (08:25 -0700)
import patch from debian to fix
 CVE-2025-32914

Upstream-Status: Backport [import from debian https://salsa.debian.org/gnome-team/libsoup/-/tree/debian/bullseye/debian/patches?ref_type=heads
Upstream commit https://gitlab.gnome.org/GNOME/libsoup/-/commit/5bfcf8157597f2d327050114fb37ff600004dbcf]

Reference:
https://gitlab.gnome.org/GNOME/libsoup/-/merge_requests/450
https://security-tracker.debian.org/tracker/CVE-2025-32914

Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/recipes-support/libsoup/libsoup-2.4/CVE-2025-32914.patch [new file with mode: 0644]
meta/recipes-support/libsoup/libsoup-2.4_2.74.2.bb

diff --git a/meta/recipes-support/libsoup/libsoup-2.4/CVE-2025-32914.patch b/meta/recipes-support/libsoup/libsoup-2.4/CVE-2025-32914.patch
new file mode 100644 (file)
index 0000000..e6d4607
--- /dev/null
@@ -0,0 +1,137 @@
+From: Milan Crha <mcrha@redhat.com>
+Date: Tue, 15 Apr 2025 09:03:00 +0200
+Subject: 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
+
+(cherry picked from commit 5bfcf8157597f2d327050114fb37ff600004dbcf)
+
+Upstream-Status: Backport [import from debian https://salsa.debian.org/gnome-team/libsoup/-/blob/debian/bullseye/debian/patches/CVE-2025-32914.patch?ref_type=heads
+Upstream commit https://gitlab.gnome.org/GNOME/libsoup/-/commit/5bfcf8157597f2d327050114fb37ff600004dbcf]
+CVE: CVE-2025-32914
+Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
+---
+ libsoup/soup-multipart.c |  2 +-
+ tests/multipart-test.c   | 85 ++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 86 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..834b181 100644
+--- a/tests/multipart-test.c
++++ b/tests/multipart-test.c
+@@ -479,6 +479,89 @@ 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;
++      //GBytes *bytes, *set_bytes = NULL;
++      GBytes *bytes;
++      const char *raw_data = "--123\r\nContent-Type: text/plain;\r\n\r\n" TEXT "\r\n--123--\r\n";
++      gboolean success;
++      SoupMessageBody *body = soup_message_body_new ();
++      SoupBuffer *set_buffer = NULL;
++      gconstpointer data;
++      gsize size;
++
++      headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
++      soup_message_headers_append (headers, "Content-Type", "multipart/mixed; boundary=\"123\"");
++
++      bytes = g_bytes_new (raw_data, strlen (raw_data));
++
++      data = g_bytes_get_data(bytes, NULL);
++      size = g_bytes_get_size(bytes);
++
++      soup_message_body_append(body, SOUP_MEMORY_STATIC, data, size);
++
++      //multipart = soup_multipart_new_from_message (headers, bytes);
++      multipart = soup_multipart_new_from_message (headers, body);
++
++      soup_message_body_free (body);
++
++      g_assert_nonnull (multipart);
++      g_assert_cmpint (soup_multipart_get_length (multipart), ==, 1);
++      success = soup_multipart_get_part (multipart, 0, &set_headers, &set_buffer);
++      g_assert_true (success);
++      g_assert_nonnull (set_headers);
++      //g_assert_nonnull (set_bytes);
++      g_assert_nonnull (set_buffer);
++      //g_assert_cmpint (strlen (TEXT), ==, g_bytes_get_size (set_bytes));
++      g_assert_cmpint (strlen (TEXT), ==, set_buffer->length);
++      g_assert_cmpstr ("text/plain", ==, soup_message_headers_get_content_type (set_headers, NULL));
++      //g_assert_cmpmem (TEXT, strlen (TEXT), g_bytes_get_data (set_bytes, NULL), g_bytes_get_size (set_bytes));
++      g_assert_cmpmem(TEXT, strlen(TEXT), set_buffer->data, set_buffer->length);
++
++      soup_message_headers_free (headers);
++      g_bytes_unref (bytes);
++
++      soup_multipart_free (multipart);
++
++      #undef TEXT
++}
++
++static void
++test_multipart_bounds_bad (void)
++{
++      SoupMultipart *multipart;
++      SoupMessageHeaders *headers;
++      GBytes *bytes;
++      const char *raw_data = "--123\r\nContent-Type: text/plain;\r\nline1\r\nline2\r\n--123--\r\n";
++      SoupMessageBody *body = soup_message_body_new ();
++      gconstpointer data;
++      gsize size;
++
++      headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
++      soup_message_headers_append (headers, "Content-Type", "multipart/mixed; boundary=\"123\"");
++
++      bytes = g_bytes_new (raw_data, strlen (raw_data));
++
++      data = g_bytes_get_data(bytes, NULL);
++      size = g_bytes_get_size(bytes);
++
++      soup_message_body_append(body, SOUP_MEMORY_STATIC, data, size);
++
++      /* it did read out of raw_data/bytes bounds */
++      //multipart = soup_multipart_new_from_message (headers, bytes);
++      multipart = soup_multipart_new_from_message (headers, body);
++      g_assert_null (multipart);
++
++      soup_message_body_free (body);
++
++      soup_message_headers_free (headers);
++      g_bytes_unref (bytes);
++}
++
+ int
+ main (int argc, char **argv)
+ {
+@@ -508,6 +591,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 ();
index 848ea6eb54ac48e6fd8fdafeff61570c7cfaff5b..46b9e10ac5c0a5e40c9b7652203ca0a26567b38f 100644 (file)
@@ -30,6 +30,7 @@ SRC_URI = "${GNOME_MIRROR}/libsoup/${SHRT_VER}/libsoup-${PV}.tar.xz \
            file://CVE-2025-32911_CVE-2025-32913-2.patch \
            file://CVE-2025-32912-1.patch \
            file://CVE-2025-32912-2.patch \
+           file://CVE-2025-32914.patch \
           "
 SRC_URI[sha256sum] = "f0a427656e5fe19e1df71c107e88dfa1b2e673c25c547b7823b6018b40d01159"