Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libsoup2 for openSUSE:Factory checked in at 2026-11-24 12:23:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libsoup2 (Old) and /work/SRC/openSUSE:Factory/.libsoup2.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libsoup2" Tue Nov 24 12:23:31 2026 rev:30 rq:1399954 version:2.74.3 Changes: -------- --- /work/SRC/openSUSE:Factory/libsoup2/libsoup2.changes 2026-10-14 18:34:26.606154404 +0200 +++ /work/SRC/openSUSE:Factory/.libsoup2.new.1340718/libsoup2.changes 2026-11-24 12:25:59.687343646 +0100 @@ -1,0 +2,15 @@ +Fri Nov 20 19:57:36 UTC 2026 - Michael Gorse <[email protected]> + +- Add libsoup2-CVE-2026-66339-2.patch: Pass cached proxy + credentials only within the same origin (bsc#1273156 + CVE-2026-66339). +- CVE-2026-66337: heap buffer overread via integer underflow in + `soup_filter_input_stream_read_until()` (bsc#1273158) + * libsoup2-CVE-2026-66337.patch +- CVE-2026-3099: failure to track issued nonces or enforce the + incrementing nonce-count attribute required by the Digest Auth + standard can lead to authentication bypass and replay attacks + (bsc#1258781) + * libsoup2-CVE-2026-3099.patch + +------------------------------------------------------------------- New: ---- libsoup2-CVE-2026-3099.patch libsoup2-CVE-2026-66337.patch libsoup2-CVE-2026-66339-2.patch ----------(New B)---------- New: (bsc#1258781) * libsoup2-CVE-2026-3099.patch New: `soup_filter_input_stream_read_until()` (bsc#1273158) * libsoup2-CVE-2026-66337.patch - CVE-2026-3099: failure to track issued nonces or enforce the New: - Add libsoup2-CVE-2026-66339-2.patch: Pass cached proxy credentials only within the same origin (bsc#1273156 ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libsoup2.spec ++++++ --- /var/tmp/diff_new_pack.IxCffp/_old 2026-11-24 12:26:04.283538217 +0100 +++ /var/tmp/diff_new_pack.IxCffp/_new 2026-11-24 12:26:04.289538471 +0100 @@ -132,6 +132,12 @@ Patch52: libsoup2-CVE-2026-15713.patch # PATCH-FIX-UPSTREAM libsoup2-CVE-2026-103399.patch bsc#1283831 [email protected] -- server: Close the connection after an early response to Expect: 100-continue. Patch53: libsoup2-CVE-2026-103399.patch +# PATCH-FIX-UPSTREAM libsoup2-CVE-2026-66339-2.patch bsc#1273156 [email protected] -- auth-manager: Pass cached proxy credentials only within the same origin. +Patch54: libsoup2-CVE-2026-66339-2.patch +# PATCH-FIX-UPSTREAM libsoup2-CVE-2026-66337.patch bsc#1273158 [email protected] -- filter-input-stream: Fix underflow when less data than the boundary is buffered. +Patch55: libsoup2-CVE-2026-66337.patch +# PATCH-FIX-UPSTREAM libsoup2-CVE-2026-3099.patch bsc#1258781 [email protected] -- auth-domain-digest: Check nonce validity. +Patch56: libsoup2-CVE-2026-3099.patch BuildRequires: glib-networking BuildRequires: meson >= 0.50 ++++++ _scmsync.obsinfo ++++++ --- /var/tmp/diff_new_pack.IxCffp/_old 2026-11-24 12:26:04.515548039 +0100 +++ /var/tmp/diff_new_pack.IxCffp/_new 2026-11-24 12:26:04.533548801 +0100 @@ -1,7 +1,7 @@ -mtime: 1791834825 -commit: 3b7bb3e063cd6a5b12ee6854a3ad47139f45b742cdb479111a09dc01a32a8b7d +mtime: 1795212692 +commit: 07c0d34ca08eaf18ba05ba6d2f0397cb9440d04832bd3be3a85d0c266255cd8a url: https://src.opensuse.org/GNOME/libsoup2 -revision: 3b7bb3e063cd6a5b12ee6854a3ad47139f45b742cdb479111a09dc01a32a8b7d +revision: 07c0d34ca08eaf18ba05ba6d2f0397cb9440d04832bd3be3a85d0c266255cd8a trackingbranch: factory projectscmsync: https://src.opensuse.org/GNOME/_ObsPrj ++++++ build.specials.obscpio ++++++ ++++++ build.specials.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/.gitignore 2026-11-20 23:11:32.000000000 +0100 @@ -0,0 +1,4 @@ +*.obscpio +*.osc +_build.* +.pbuild ++++++ libsoup2-CVE-2026-3099.patch ++++++ >From 437c5d45daba48aa23b408dc9ac16d8b9ffdd64f Mon Sep 17 00:00:00 2001 From: Milan Crha <[email protected]> Date: Mon, 21 Sep 2026 15:59:06 +0200 Subject: [PATCH] auth-domain-digest: Check nonce validity Let the Digest authentication check the `nonce` validity, to prevent message reply. This is CVE-2026-3099. Closes https://gitlab.gnome.org/GNOME/libsoup/-/work_items/495 --- libsoup/server/soup-auth-domain-digest.c | 79 ++++++++++++- tests/digest-nonce-replay-test.c | 139 +++++++++++++++++++++++ tests/meson.build | 1 + 3 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 tests/digest-nonce-replay-test.c Index: libsoup-2.74.3/tests/digest-nonce-replay-test.c =================================================================== --- /dev/null +++ libsoup-2.74.3/tests/digest-nonce-replay-test.c @@ -0,0 +1,138 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +#include "test-utils.h" +#include "libsoup/soup-auth-digest.h" + +#define REALM "digest-replay-test" + +static void +server_cb (SoupServer *server, + SoupMessage *msg, + const char *path, + GHashTable *query, + SoupClientContext *context, + gpointer user_data) +{ + soup_message_set_status (msg, SOUP_STATUS_OK); + soup_message_set_response (msg, "text/plain", SOUP_MEMORY_STATIC, "ok", 2); +} + +static char * +auth_callback (SoupAuthDomain *domain, + SoupMessage *msg, + const char *username, + gpointer user_data) +{ + if (strcmp (username, "user") != 0) + return NULL; + + return soup_auth_domain_digest_encode_password ("user", REALM, "password"); +} + +static SoupMessage * +send_with_authorization (SoupSession *session, + const char *url, + const char *authorization) +{ + SoupMessage *msg; + GError *error = NULL; + + msg = soup_message_new (SOUP_METHOD_GET, url); + if (authorization) { + soup_message_headers_replace (msg->request_headers, + "Authorization", authorization); + } + soup_session_send_message (session, msg); + g_assert_no_error (error); + + return msg; +} + +static void +do_digest_nonce_replay_test (void) +{ + SoupServer *server; + SoupAuthDomain *auth_domain; + SoupSession *session; + SoupMessage *msg; + SoupURI *base_uri; + char *base_str, *url; + const char *www_authenticate; + GHashTable *challenge_params; + const char *nonce; + char hex_urp[33], response[33]; + char *authorization; + + server = soup_test_server_new (SOUP_TEST_SERVER_IN_THREAD); + soup_server_add_handler (server, NULL, server_cb, NULL, NULL); + + auth_domain = soup_auth_domain_digest_new ( + "realm", REALM, + "auth-callback", auth_callback, + NULL); + soup_auth_domain_add_path (auth_domain, "/"); + soup_server_add_auth_domain (server, auth_domain); + g_object_unref (auth_domain); + + base_uri = soup_test_server_get_uri (server, "http", "127.0.0.1"); + base_str = soup_uri_to_string (base_uri, FALSE); + url = g_strconcat (base_str, "protected", NULL); + + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); + + /* Get challenged, and extract the nonce the server issued. */ + msg = send_with_authorization (session, url, NULL); + soup_test_assert_message_status (msg, SOUP_STATUS_UNAUTHORIZED); + www_authenticate = soup_message_headers_get_one (msg->response_headers, "WWW-Authenticate"); + g_assert_nonnull (www_authenticate); + g_assert_true (g_str_has_prefix (www_authenticate, "Digest ")); + challenge_params = soup_header_parse_param_list (www_authenticate + strlen ("Digest ")); + nonce = g_hash_table_lookup (challenge_params, "nonce"); + g_assert_nonnull (nonce); + g_object_unref (msg); + + /* Hand-compute a valid Authorization header for that nonce. */ + soup_auth_digest_compute_hex_urp ("user", REALM, "password", hex_urp); + soup_auth_digest_compute_response ("GET", "/protected", hex_urp, + SOUP_AUTH_DIGEST_QOP_AUTH, + nonce, "clientnonce", 1, response); + authorization = g_strdup_printf ( + "Digest username=\"user\", realm=\"%s\", nonce=\"%s\", uri=\"/protected\", " + "qop=auth, nc=00000001, cnonce=\"clientnonce\", response=\"%s\"", + REALM, nonce, response); + + /* The first use of this Authorization header must succeed. */ + msg = send_with_authorization (session, url, authorization); + soup_test_assert_message_status (msg, SOUP_STATUS_OK); + g_object_unref (msg); + + /* Replaying the exact same header -- same nonce, same nc, same + * cnonce, same response -- must be rejected. + */ + msg = send_with_authorization (session, url, authorization); + soup_test_assert_message_status (msg, SOUP_STATUS_UNAUTHORIZED); + g_object_unref (msg); + + g_free (authorization); + soup_header_free_param_list (challenge_params); + soup_test_session_abort_unref (session); + g_free (base_str); + g_free (url); + soup_uri_free (base_uri); + soup_test_server_quit_unref (server); +} + +int +main (int argc, char **argv) +{ + int ret; + + test_init (argc, argv, NULL); + + g_test_add_func ("/digest-nonce-replay/rejected", do_digest_nonce_replay_test); + + ret = g_test_run (); + + test_cleanup (); + return ret; +} Index: libsoup-2.74.3/tests/meson.build =================================================================== --- libsoup-2.74.3.orig/tests/meson.build +++ libsoup-2.74.3/tests/meson.build @@ -42,6 +42,7 @@ tests = [ ['continue', true, []], ['cookies', true, []], ['date', true, []], + ['digest-nonce-replay', true, []], ['forms', true, []], ['header-parsing', true, []], ['hsts', true, []], @@ -180,7 +181,7 @@ foreach test: tests ) endif - test_deps = [ libsoup_dep ] + test[2] + test_deps = [ libsoup_static_dep ] + test[2] test_target = executable(test_name, sources : [ test_name + '.c', test_resources ], link_with : test_utils, Index: libsoup-2.74.3/libsoup/soup-auth-domain-digest.c =================================================================== --- libsoup-2.74.3.orig/libsoup/soup-auth-domain-digest.c +++ libsoup-2.74.3/libsoup/soup-auth-domain-digest.c @@ -34,10 +34,19 @@ enum { }; typedef struct { + gint64 issue_time; + guint64 max_nc; +} SoupDigestNonceInfo; + +#define SOUP_DIGEST_NONCE_LIFETIME (300 * G_USEC_PER_SEC) + +typedef struct { SoupAuthDomainDigestAuthCallback auth_callback; gpointer auth_data; GDestroyNotify auth_dnotify; + GMutex nonce_lock; + GHashTable *nonces; } SoupAuthDomainDigestPrivate; G_DEFINE_TYPE_WITH_PRIVATE (SoupAuthDomainDigest, soup_auth_domain_digest, SOUP_TYPE_AUTH_DOMAIN) @@ -45,6 +54,11 @@ G_DEFINE_TYPE_WITH_PRIVATE (SoupAuthDoma static void soup_auth_domain_digest_init (SoupAuthDomainDigest *digest) { + SoupAuthDomainDigestPrivate *priv = + soup_auth_domain_digest_get_instance_private (digest); + + g_mutex_init (&priv->nonce_lock); + priv->nonces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); } static void @@ -56,6 +70,9 @@ soup_auth_domain_digest_finalize (GObjec if (priv->auth_dnotify) priv->auth_dnotify (priv->auth_data); + g_hash_table_destroy (priv->nonces); + g_mutex_clear (&priv->nonce_lock); + G_OBJECT_CLASS (soup_auth_domain_digest_parent_class)->finalize (object); } @@ -191,11 +208,15 @@ check_hex_urp (SoupAuthDomain *domain, S GHashTable *params, const char *username, const char *hex_urp) { + SoupAuthDomainDigestPrivate *priv = + soup_auth_domain_digest_get_instance_private (SOUP_AUTH_DOMAIN_DIGEST (domain)); const char *uri, *qop, *realm, *msg_username; const char *nonce, *nc, *cnonce, *response; char hex_a1[33], computed_response[33]; int nonce_count; SoupURI *dig_uri, *req_uri; + SoupDigestNonceInfo *nonce_info; + gboolean accept; msg_username = g_hash_table_lookup (params, "username"); if (!msg_username || strcmp (msg_username, username) != 0) @@ -256,6 +277,16 @@ check_hex_urp (SoupAuthDomain *domain, S if (!response) return FALSE; + g_mutex_lock (&priv->nonce_lock); + + nonce_info = g_hash_table_lookup (priv->nonces, nonce); + if (!nonce_info || + g_get_monotonic_time () - nonce_info->issue_time > SOUP_DIGEST_NONCE_LIFETIME || + (guint64) nonce_count <= nonce_info->max_nc) { + g_mutex_unlock (&priv->nonce_lock); + return FALSE; + } + soup_auth_digest_compute_hex_a1 (hex_urp, SOUP_AUTH_DIGEST_ALGORITHM_MD5, nonce, cnonce, hex_a1); @@ -264,7 +295,14 @@ check_hex_urp (SoupAuthDomain *domain, S SOUP_AUTH_DIGEST_QOP_AUTH, nonce, cnonce, nonce_count, computed_response); - return strcmp (response, computed_response) == 0; + + accept = strcmp (response, computed_response) == 0; + if (accept) + nonce_info->max_nc = nonce_count; + + g_mutex_unlock (&priv->nonce_lock); + + return accept; } static char * @@ -312,19 +350,52 @@ soup_auth_domain_digest_accepts (SoupAut return ret_user; } +static void +prune_expired_nonces (SoupAuthDomainDigestPrivate *priv, + gint64 now) +{ + GHashTableIter iter; + gpointer key, value; + SoupDigestNonceInfo *nonce_info; + + g_hash_table_iter_init (&iter, priv->nonces); + while (g_hash_table_iter_next (&iter, &key, &value)) { + nonce_info = value; + if (now - nonce_info->issue_time > SOUP_DIGEST_NONCE_LIFETIME) + g_hash_table_iter_remove (&iter); + } +} + static char * soup_auth_domain_digest_challenge (SoupAuthDomain *domain, SoupMessage *msg) { + SoupAuthDomainDigestPrivate *priv = + soup_auth_domain_digest_get_instance_private (SOUP_AUTH_DOMAIN_DIGEST (domain)); GString *str; + char *nonce; + SoupDigestNonceInfo *nonce_info; + gint64 now; + + now = g_get_monotonic_time (); + nonce = g_strdup_printf ("%lu%" G_GINT64_FORMAT, (unsigned long) msg, now); + + nonce_info = g_new (SoupDigestNonceInfo, 1); + nonce_info->issue_time = now; + nonce_info->max_nc = 0; + + g_mutex_lock (&priv->nonce_lock); + prune_expired_nonces (priv, now); + g_hash_table_replace (priv->nonces, g_strdup (nonce), nonce_info); + g_mutex_unlock (&priv->nonce_lock); str = g_string_new ("Digest "); soup_header_g_string_append_param_quoted (str, "realm", soup_auth_domain_get_realm (domain)); - g_string_append_printf (str, ", nonce=\"%lu%lu\"", - (unsigned long) msg, - (unsigned long) time (0)); + g_string_append_printf (str, ", nonce=\"%s\"", nonce); g_string_append_printf (str, ", qop=\"auth\""); g_string_append_printf (str, ", algorithm=MD5"); + g_free (nonce); + return g_string_free (str, FALSE); } Index: libsoup-2.74.3/libsoup/meson.build =================================================================== --- libsoup-2.74.3.orig/libsoup/meson.build +++ libsoup-2.74.3/libsoup/meson.build @@ -265,6 +265,16 @@ libsoup = library('soup-@0@'.format(apiv install : true, dependencies : deps) +libsoup_static = static_library('soup-@0@-static'.format(apiversion), + sources : [ + soup_sources, + soup_enums, + ], + c_args : libsoup_c_args, + include_directories : configinc, + dependencies : deps, +) + pkg.generate(libsoup, libraries : glib_deps, name : meson.project_name(), @@ -278,6 +288,12 @@ libsoup_dep = declare_dependency(link_wi sources : soup_enum_h, dependencies : [ platform_deps, gssapi_dep, glib_deps ]) +libsoup_static_dep = declare_dependency(link_with : libsoup_static, + include_directories : configinc, + sources : soup_enum_h, + dependencies : [ platform_deps, gssapi_dep, glib_deps ] +) + if meson.version().version_compare('>=0.54.0') meson.override_dependency('libsoup-2.4', libsoup_dep) endif ++++++ libsoup2-CVE-2026-66337.patch ++++++ >From f973bd140d5c9742a8db573b950c43cf5166ac1c Mon Sep 17 00:00:00 2001 From: Patrick Griffis <[email protected]> Date: Fri, 4 Sep 2026 14:26:44 -0500 Subject: [PATCH] filter-input-stream: Fix underflow when less data than the boundary is buffered soup_filter_input_stream_read_until() computed the end of the scan range as buf->len - boundary_length. Both are unsigned, so when fewer bytes than the boundary length had been buffered the subtraction wrapped, the MIN() against the requested length no longer bounded it, and the scan loop read past the buffered data. A server could trigger this against SoupMultipartInputStream by using a long boundary and sending a part body shorter than it. Skip the scan entirely when the buffer cannot contain the boundary yet. Fixes #532 (CVE-2026-66337) --- libsoup/soup-filter-input-stream.c | 11 ++++-- tests/multipart-test.c | 54 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) Index: libsoup-2.74.3/libsoup/soup-filter-input-stream.c =================================================================== --- libsoup-2.74.3.orig/libsoup/soup-filter-input-stream.c +++ libsoup-2.74.3/libsoup/soup-filter-input-stream.c @@ -251,12 +251,17 @@ soup_filter_input_stream_read_until (Sou } else buf = fstream->priv->buf->data; - /* Scan for the boundary within the range we can possibly return. */ - if (include_boundary) + /* Scan for the boundary within the range we can possibly return. + * If we have fewer bytes than the boundary is long there is nothing + * to scan yet; the subtractions below would underflow otherwise. + */ + if (fstream->priv->buf->len < boundary_length) + end = NULL; + else if (include_boundary) end = buf + MIN (fstream->priv->buf->len, length) - boundary_length; else end = buf + MIN (fstream->priv->buf->len - boundary_length, length); - for (p = buf; p <= end; p++) { + for (p = buf; end && p <= end; p++) { if (*p == *(guint8*)boundary && !memcmp (p, boundary, boundary_length)) { if (include_boundary) Index: libsoup-2.74.3/tests/multipart-test.c =================================================================== --- libsoup-2.74.3.orig/tests/multipart-test.c +++ libsoup-2.74.3/tests/multipart-test.c @@ -446,6 +446,59 @@ test_multipart_bounds_bad_4 (void) g_free (boundary); } +/* A part body shorter than the boundary. soup_filter_input_stream_read_until() + * used to compute buf->len - boundary_length unsigned, wrapping and scanning + * far past the buffered data. Only detectable under ASan/valgrind. + */ +static void +test_multipart_short_body (void) +{ + SoupMessage *msg; + SoupMessageHeaders *headers; + GInputStream *in; + GInputStream *part; + SoupMultipartInputStream *multipart; + GError *error = NULL; + char boundary[61]; + char *content_type; + char *raw_data; + char buffer[4096]; + gssize nread; + + memset (boundary, 'A', sizeof (boundary) - 1); + boundary[sizeof (boundary) - 1] = '\0'; + + msg = soup_message_new (SOUP_METHOD_GET, "http://foo/multipart"); + headers = msg->response_headers; + content_type = g_strconcat ("multipart/x-mixed-replace; boundary=", boundary, NULL); + soup_message_headers_replace (headers, "Content-Type", content_type); + + /* One part whose body is a single byte, then EOF without a closing boundary */ + raw_data = g_strconcat ("--", boundary, "\r\nContent-Type: text/plain\r\n\r\nX", NULL); + in = g_memory_input_stream_new_from_data (raw_data, strlen (raw_data), NULL); + multipart = soup_multipart_input_stream_new (msg, in); + g_object_unref (in); + + part = soup_multipart_input_stream_next_part (multipart, NULL, &error); + g_assert_no_error (error); + g_assert_nonnull (part); + + nread = g_input_stream_read (part, buffer, sizeof (buffer), NULL, &error); + g_assert_no_error (error); + g_assert_cmpint (nread, ==, 1); + g_assert_cmpint (buffer[0], ==, 'X'); + + nread = g_input_stream_read (part, buffer, sizeof (buffer), NULL, &error); + g_assert_no_error (error); + g_assert_cmpint (nread, ==, 0); + + g_object_unref (part); + g_object_unref (multipart); + g_object_unref (msg); + g_free (raw_data); + g_free (content_type); +} + static void test_multipart (gconstpointer data) { @@ -543,6 +596,7 @@ main (int argc, char **argv) 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-bad-4", test_multipart_bounds_bad_4); + g_test_add_func ("/multipart/short-body", test_multipart_short_body); ret = g_test_run (); ++++++ libsoup2-CVE-2026-66339-2.patch ++++++ >From 4b1a4d3e705b6946cae75f95c40099228c960bfb Mon Sep 17 00:00:00 2001 From: Milan Crha <[email protected]> Date: Mon, 21 Sep 2026 14:52:12 +0200 Subject: [PATCH] auth-manager: Pass cached proxy credentials only within the same origin When proxy redirects to a different origin the proxy credentials could be included in the redirected message. Include the credentials only if the message origin matches the proxy origin. It's a follow-up for #489, #506, #534. Found by AISLE in partnership with Red Hat. --- libsoup/auth/soup-auth-manager.c | 6 +- tests/proxy-auth-cache-test.c | 187 +++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+), 2 deletions(-) Index: libsoup-2.74.3/tests/proxy-auth-cache-test.c =================================================================== --- libsoup-2.74.3.orig/tests/proxy-auth-cache-test.c +++ libsoup-2.74.3/tests/proxy-auth-cache-test.c @@ -147,6 +147,188 @@ do_proxy_switch_no_credential_leak (void soup_test_server_quit_unref (second); } +/* A cross-origin redirect to a host reached directly must not carry the + * proxy's Proxy-Authorization credentials to that host. + */ + +static gboolean direct_target_saw_authorization; +static gboolean direct_target_hit; +static char *redirect_location; + +static void +proxy_with_redirect_cb (SoupServer *server, + SoupMessage *msg, + const char *path, + GHashTable *query, + SoupClientContext *context, + gpointer user_data) +{ + SoupMessageHeaders *req = msg->request_headers; + + if (!soup_message_headers_get_one (req, "Proxy-Authorization")) { + soup_message_set_status (msg, SOUP_STATUS_PROXY_UNAUTHORIZED); + soup_message_headers_append (msg->response_headers, + "Proxy-Authenticate", "Basic realm=\"proxy\""); + return; + } + + soup_message_set_status (msg, SOUP_STATUS_MOVED_TEMPORARILY); + soup_message_headers_append (msg->response_headers, + "Location", redirect_location); +} + +static void +direct_target_cb (SoupServer *server, + SoupMessage *msg, + const char *path, + GHashTable *query, + SoupClientContext *context, + gpointer user_data) +{ + SoupMessageHeaders *req = msg->request_headers; + + direct_target_hit = TRUE; + if (soup_message_headers_get_one (req, "Proxy-Authorization")) + direct_target_saw_authorization = TRUE; + + soup_message_set_status (msg, SOUP_STATUS_OK); + soup_message_set_response (msg, "text/plain", SOUP_MEMORY_STATIC, "ok", 2); +} + +static void +do_proxy_redirect_to_direct_no_credential_leak (void) +{ + SoupServer *proxy, *direct_target; + SoupURI *proxy_uri, *direct_uri; + char *proxy_str, *direct_str, *direct_authority; + GProxyResolver *resolver; + SoupSession *session; + SoupMessage *msg; + GError *error = NULL; + const char *ignore_hosts[2]; + + proxy = soup_test_server_new (SOUP_TEST_SERVER_IN_THREAD); + soup_server_add_handler (proxy, NULL, proxy_with_redirect_cb, NULL, NULL); + proxy_uri = soup_test_server_get_uri (proxy, "http", "127.0.0.1"); + proxy_str = soup_uri_to_string (proxy_uri, FALSE); + + direct_target = soup_test_server_new (SOUP_TEST_SERVER_IN_THREAD); + soup_server_add_handler (direct_target, NULL, direct_target_cb, NULL, NULL); + direct_uri = soup_test_server_get_uri (direct_target, "http", "127.0.0.1"); + direct_str = soup_uri_to_string (direct_uri, FALSE); + redirect_location = g_strconcat (direct_str, "target", NULL); + + direct_authority = g_strdup_printf ("127.0.0.1:%d", soup_uri_get_port (direct_uri)); + ignore_hosts[0] = direct_authority; + ignore_hosts[1] = NULL; + + /* Only the redirect target is reached directly; the initial + * cross-origin request still goes through the proxy. + */ + resolver = g_simple_proxy_resolver_new (proxy_str, (char **) ignore_hosts); + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, "proxy-resolver", resolver, NULL); + + msg = soup_message_new (SOUP_METHOD_GET, "http://origin.test/start"); + g_signal_connect (session, "authenticate", G_CALLBACK (authenticate_cb), NULL); + soup_session_send_message (session, msg); + + g_assert_no_error (error); + soup_test_assert_message_status (msg, SOUP_STATUS_OK); + + g_assert_true (direct_target_hit); + g_assert_false (direct_target_saw_authorization); + + g_object_unref (msg); + soup_test_session_abort_unref (session); + g_object_unref (resolver); + g_free (proxy_str); + g_free (direct_str); + g_free (direct_authority); + g_free (redirect_location); + soup_uri_free (proxy_uri); + soup_uri_free (direct_uri); + soup_test_server_quit_unref (proxy); + soup_test_server_quit_unref (direct_target); +} + +/* A redirect that stays behind the same proxy must still carry + * Proxy-Authorization to it. + */ + +static gboolean same_proxy_target_saw_authorization; +static gboolean same_proxy_target_hit; + +static void +proxy_with_redirect_same_proxy_cb (SoupServer *server, + SoupMessage *msg, + const char *path, + GHashTable *query, + SoupClientContext *context, + gpointer user_data) +{ + SoupMessageHeaders *req = msg->request_headers; + + if (!soup_message_headers_get_one (req, "Proxy-Authorization")) { + soup_message_set_status (msg, SOUP_STATUS_PROXY_UNAUTHORIZED); + soup_message_headers_append (msg->response_headers, + "Proxy-Authenticate", "Basic realm=\"proxy\""); + return; + } + + if (!g_strcmp0 (path, "/target")) { + same_proxy_target_hit = TRUE; + if (soup_message_headers_get_one (req, "Proxy-Authorization")) + same_proxy_target_saw_authorization = TRUE; + soup_message_set_status (msg, SOUP_STATUS_OK); + soup_message_set_response (msg, "text/plain", SOUP_MEMORY_STATIC, "ok", 2); + return; + } + + soup_message_set_status (msg, SOUP_STATUS_MOVED_TEMPORARILY); + soup_message_headers_append (msg->response_headers, + "Location", "http://other.test/target"); +} + +static void +do_proxy_redirect_same_proxy_keeps_credentials (void) +{ + SoupServer *proxy; + SoupURI *proxy_uri; + char *proxy_str; + GProxyResolver *resolver; + SoupSession *session; + SoupMessage *msg; + GError *error = NULL; + + proxy = soup_test_server_new (SOUP_TEST_SERVER_IN_THREAD); + soup_server_add_handler (proxy, NULL, proxy_with_redirect_same_proxy_cb, NULL, NULL); + proxy_uri = soup_test_server_get_uri (proxy, "http", "127.0.0.1"); + proxy_str = soup_uri_to_string (proxy_uri, FALSE); + + /* No ignore_hosts: origin.test and the redirect target other.test are + * both reached through this same proxy. + */ + resolver = g_simple_proxy_resolver_new (proxy_str, NULL); + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, "proxy-resolver", resolver, NULL); + + msg = soup_message_new (SOUP_METHOD_GET, "http://origin.test/start"); + g_signal_connect (session, "authenticate", G_CALLBACK (authenticate_cb), NULL); + soup_session_send_message (session, msg); + + g_assert_no_error (error); + soup_test_assert_message_status (msg, SOUP_STATUS_OK); + + g_assert_true (same_proxy_target_hit); + g_assert_true (same_proxy_target_saw_authorization); + + g_object_unref (msg); + soup_test_session_abort_unref (session); + g_object_unref (resolver); + g_free (proxy_str); + soup_uri_free (proxy_uri); + soup_test_server_quit_unref (proxy); +} + int main (int argc, char **argv) { @@ -156,6 +338,10 @@ main (int argc, char **argv) g_test_add_func ("/proxy-auth-cache/switch-no-credential-leak", do_proxy_switch_no_credential_leak); + g_test_add_func ("/proxy-auth-cache/redirect-to-direct-no-credential-leak", + do_proxy_redirect_to_direct_no_credential_leak); + g_test_add_func ("/proxy-auth-cache/redirect-same-proxy-keeps-credentials", + do_proxy_redirect_same_proxy_keeps_credentials); ret = g_test_run (); Index: libsoup-2.74.3/libsoup/soup-auth-manager.c =================================================================== --- libsoup-2.74.3.orig/libsoup/soup-auth-manager.c +++ libsoup-2.74.3/libsoup/soup-auth-manager.c @@ -535,9 +535,11 @@ lookup_proxy_auth (SoupAuthManagerPrivat { SoupAuth *auth; - /* If the message already has a ready auth, use that instead */ + /* If the message already has a ready auth, use that instead, but only + * if it is still for the proxy this connection actually goes through. + */ auth = soup_message_get_proxy_auth (msg); - if (auth && soup_auth_is_ready (auth, msg)) + if (auth && soup_auth_is_ready (auth, msg) && proxy_auth_matches_msg (priv, msg)) return auth; if (soup_message_get_flags (msg) & SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE)
