]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
openssl: don't leak the SRP credentials in redirects either
authorDaniel Stenberg <daniel@haxx.se>
Mon, 25 Apr 2022 15:59:15 +0000 (17:59 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 25 Apr 2022 20:34:40 +0000 (22:34 +0200)
Follow-up to 620ea21410030

Reported-by: Harry Sintonen
Closes #8751

lib/http.c
lib/http.h
lib/vtls/openssl.c

index f0476f3b9272d08246368f6de5f228e864366cf9..0d5c449bc72a2ebcea091e0325c6523ace6b640f 100644 (file)
@@ -776,10 +776,10 @@ output_auth_headers(struct Curl_easy *data,
 }
 
 /*
- * allow_auth_to_host() tells if autentication, cookies or other "sensitive
- * data" can (still) be sent to this host.
+ * Curl_allow_auth_to_host() tells if authentication, cookies or other
+ * "sensitive data" can (still) be sent to this host.
  */
-static bool allow_auth_to_host(struct Curl_easy *data)
+bool Curl_allow_auth_to_host(struct Curl_easy *data)
 {
   struct connectdata *conn = data->conn;
   return (!data->state.this_is_a_follow ||
@@ -864,7 +864,7 @@ Curl_http_output_auth(struct Curl_easy *data,
 
   /* To prevent the user+password to get sent to other than the original host
      due to a location-follow */
-  if(allow_auth_to_host(data)
+  if(Curl_allow_auth_to_host(data)
 #ifndef CURL_DISABLE_NETRC
      || conn->bits.netrc
 #endif
@@ -1917,7 +1917,7 @@ CURLcode Curl_add_custom_headers(struct Curl_easy *data,
                    checkprefix("Cookie:", compare)) &&
                   /* be careful of sending this potentially sensitive header to
                      other hosts */
-                  !allow_auth_to_host(data))
+                  !Curl_allow_auth_to_host(data))
             ;
           else {
 #ifdef USE_HYPER
index 0972261e63bd62afdb458be409b70dc9b33f0ed9..c4ab3c22dec9ec3b435e7a7f39fb3d9ef5b67ea6 100644 (file)
@@ -364,4 +364,10 @@ Curl_http_output_auth(struct Curl_easy *data,
                       bool proxytunnel); /* TRUE if this is the request setting
                                             up the proxy tunnel */
 
+/*
+ * Curl_allow_auth_to_host() tells if authentication, cookies or other
+ * "sensitive data" can (still) be sent to this host.
+ */
+bool Curl_allow_auth_to_host(struct Curl_easy *data);
+
 #endif /* HEADER_CURL_HTTP_H */
index 5d8e2d39d8e263f91caa31ec8be12899fcc1ea41..3722005d44e95c39cc46a4ee6fe9479c7051296d 100644 (file)
@@ -2924,7 +2924,8 @@ static CURLcode ossl_connect_step1(struct Curl_easy *data,
 #endif
 
 #ifdef USE_OPENSSL_SRP
-  if(ssl_authtype == CURL_TLSAUTH_SRP) {
+  if((ssl_authtype == CURL_TLSAUTH_SRP) &&
+     Curl_allow_auth_to_host(data)) {
     char * const ssl_username = SSL_SET_OPTION(username);
 
     infof(data, "Using TLS-SRP username: %s", ssl_username);