|
|
34bc20 |
From d4247fa7baf0859729fff2fe5cf0bfab8322d1a5 Mon Sep 17 00:00:00 2001
|
|
|
34bc20 |
From: Daniel Stenberg <daniel@haxx.se>
|
|
|
34bc20 |
Date: Mon, 9 May 2022 23:13:53 +0200
|
|
|
34bc20 |
Subject: [PATCH 1/2] tls: check more TLS details for connection reuse
|
|
|
34bc20 |
|
|
|
34bc20 |
CVE-2022-27782
|
|
|
34bc20 |
|
|
|
34bc20 |
Reported-by: Harry Sintonen
|
|
|
34bc20 |
Bug: https://curl.se/docs/CVE-2022-27782.html
|
|
|
34bc20 |
Closes #8825
|
|
|
34bc20 |
|
|
|
34bc20 |
Upstream-commit: f18af4f874cecab82a9797e8c7541e0990c7a64c
|
|
|
34bc20 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
34bc20 |
---
|
|
|
34bc20 |
lib/setopt.c | 29 +++++++++++++++++------------
|
|
|
34bc20 |
lib/url.c | 19 ++++++++++++-------
|
|
|
34bc20 |
lib/urldata.h | 14 +++++++-------
|
|
|
34bc20 |
lib/vtls/openssl.c | 10 +++++-----
|
|
|
34bc20 |
lib/vtls/vtls.c | 21 +++++++++++++++++++++
|
|
|
34bc20 |
5 files changed, 62 insertions(+), 31 deletions(-)
|
|
|
34bc20 |
|
|
|
34bc20 |
diff --git a/lib/setopt.c b/lib/setopt.c
|
|
|
34bc20 |
index b07ccfe..319a010 100644
|
|
|
34bc20 |
--- a/lib/setopt.c
|
|
|
34bc20 |
+++ b/lib/setopt.c
|
|
|
34bc20 |
@@ -2044,6 +2044,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
|
|
|
34bc20 |
|
|
|
34bc20 |
case CURLOPT_SSL_OPTIONS:
|
|
|
34bc20 |
arg = va_arg(param, long);
|
|
|
34bc20 |
+ data->set.ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
|
|
|
34bc20 |
data->set.ssl.enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
|
|
|
34bc20 |
data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
|
|
|
34bc20 |
data->set.ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
|
|
|
34bc20 |
@@ -2051,6 +2052,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
|
|
|
34bc20 |
|
|
|
34bc20 |
case CURLOPT_PROXY_SSL_OPTIONS:
|
|
|
34bc20 |
arg = va_arg(param, long);
|
|
|
34bc20 |
+ data->set.proxy_ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
|
|
|
34bc20 |
data->set.proxy_ssl.enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
|
|
|
34bc20 |
data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
|
|
|
34bc20 |
break;
|
|
|
34bc20 |
@@ -2451,44 +2453,47 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
|
|
|
34bc20 |
case CURLOPT_TLSAUTH_USERNAME:
|
|
|
34bc20 |
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME],
|
|
|
34bc20 |
va_arg(param, char *));
|
|
|
34bc20 |
- if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
|
|
|
34bc20 |
- data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
|
|
|
34bc20 |
+ if(data->set.str[STRING_TLSAUTH_USERNAME] &&
|
|
|
34bc20 |
+ !data->set.ssl.primary.authtype)
|
|
|
34bc20 |
+ data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
|
|
|
34bc20 |
break;
|
|
|
34bc20 |
case CURLOPT_PROXY_TLSAUTH_USERNAME:
|
|
|
34bc20 |
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY],
|
|
|
34bc20 |
va_arg(param, char *));
|
|
|
34bc20 |
if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
|
|
|
34bc20 |
- !data->set.proxy_ssl.authtype)
|
|
|
34bc20 |
- data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
|
|
|
34bc20 |
+ !data->set.proxy_ssl.primary.authtype)
|
|
|
34bc20 |
+ data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default to
|
|
|
34bc20 |
+ SRP */
|
|
|
34bc20 |
break;
|
|
|
34bc20 |
case CURLOPT_TLSAUTH_PASSWORD:
|
|
|
34bc20 |
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD],
|
|
|
34bc20 |
va_arg(param, char *));
|
|
|
34bc20 |
- if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
|
|
|
34bc20 |
- data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
|
|
|
34bc20 |
+ if(data->set.str[STRING_TLSAUTH_USERNAME] &&
|
|
|
34bc20 |
+ !data->set.ssl.primary.authtype)
|
|
|
34bc20 |
+ data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default */
|
|
|
34bc20 |
break;
|
|
|
34bc20 |
case CURLOPT_PROXY_TLSAUTH_PASSWORD:
|
|
|
34bc20 |
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY],
|
|
|
34bc20 |
va_arg(param, char *));
|
|
|
34bc20 |
if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
|
|
|
34bc20 |
- !data->set.proxy_ssl.authtype)
|
|
|
34bc20 |
- data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
|
|
|
34bc20 |
+ !data->set.proxy_ssl.primary.authtype)
|
|
|
34bc20 |
+ data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default */
|
|
|
34bc20 |
break;
|
|
|
34bc20 |
case CURLOPT_TLSAUTH_TYPE:
|
|
|
34bc20 |
argptr = va_arg(param, char *);
|
|
|
34bc20 |
if(!argptr ||
|
|
|
34bc20 |
strncasecompare(argptr, "SRP", strlen("SRP")))
|
|
|
34bc20 |
- data->set.ssl.authtype = CURL_TLSAUTH_SRP;
|
|
|
34bc20 |
+ data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP;
|
|
|
34bc20 |
else
|
|
|
34bc20 |
- data->set.ssl.authtype = CURL_TLSAUTH_NONE;
|
|
|
34bc20 |
+ data->set.ssl.primary.authtype = CURL_TLSAUTH_NONE;
|
|
|
34bc20 |
break;
|
|
|
34bc20 |
case CURLOPT_PROXY_TLSAUTH_TYPE:
|
|
|
34bc20 |
argptr = va_arg(param, char *);
|
|
|
34bc20 |
if(!argptr ||
|
|
|
34bc20 |
strncasecompare(argptr, "SRP", strlen("SRP")))
|
|
|
34bc20 |
- data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP;
|
|
|
34bc20 |
+ data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP;
|
|
|
34bc20 |
else
|
|
|
34bc20 |
- data->set.proxy_ssl.authtype = CURL_TLSAUTH_NONE;
|
|
|
34bc20 |
+ data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_NONE;
|
|
|
34bc20 |
break;
|
|
|
34bc20 |
#endif
|
|
|
34bc20 |
case CURLOPT_DNS_SERVERS:
|
|
|
34bc20 |
diff --git a/lib/url.c b/lib/url.c
|
|
|
34bc20 |
index 7dd5267..30fc5ad 100644
|
|
|
34bc20 |
--- a/lib/url.c
|
|
|
34bc20 |
+++ b/lib/url.c
|
|
|
34bc20 |
@@ -461,7 +461,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
|
|
|
34bc20 |
set->ssl.primary.verifypeer = TRUE;
|
|
|
34bc20 |
set->ssl.primary.verifyhost = TRUE;
|
|
|
34bc20 |
#ifdef USE_TLS_SRP
|
|
|
34bc20 |
- set->ssl.authtype = CURL_TLSAUTH_NONE;
|
|
|
34bc20 |
+ set->ssl.primary.authtype = CURL_TLSAUTH_NONE;
|
|
|
34bc20 |
#endif
|
|
|
34bc20 |
set->ssh_auth_types = CURLSSH_AUTH_DEFAULT; /* defaults to any auth
|
|
|
34bc20 |
type */
|
|
|
34bc20 |
@@ -1881,10 +1881,12 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
|
|
|
34bc20 |
conn->ssl_config.verifystatus = data->set.ssl.primary.verifystatus;
|
|
|
34bc20 |
conn->ssl_config.verifypeer = data->set.ssl.primary.verifypeer;
|
|
|
34bc20 |
conn->ssl_config.verifyhost = data->set.ssl.primary.verifyhost;
|
|
|
34bc20 |
+ conn->ssl_config.ssl_options = data->set.ssl.primary.ssl_options;
|
|
|
34bc20 |
conn->proxy_ssl_config.verifystatus =
|
|
|
34bc20 |
data->set.proxy_ssl.primary.verifystatus;
|
|
|
34bc20 |
conn->proxy_ssl_config.verifypeer = data->set.proxy_ssl.primary.verifypeer;
|
|
|
34bc20 |
conn->proxy_ssl_config.verifyhost = data->set.proxy_ssl.primary.verifyhost;
|
|
|
34bc20 |
+ conn->proxy_ssl_config.ssl_options = data->set.proxy_ssl.primary.ssl_options;
|
|
|
34bc20 |
|
|
|
34bc20 |
conn->ip_version = data->set.ipver;
|
|
|
34bc20 |
|
|
|
34bc20 |
@@ -4362,8 +4364,9 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|
|
34bc20 |
data->set.proxy_ssl.primary.cipher_list13 =
|
|
|
34bc20 |
data->set.str[STRING_SSL_CIPHER13_LIST_PROXY];
|
|
|
34bc20 |
|
|
|
34bc20 |
- data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE];
|
|
|
34bc20 |
- data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
|
|
|
34bc20 |
+ data->set.ssl.primary.CRLfile = data->set.str[STRING_SSL_CRLFILE];
|
|
|
34bc20 |
+ data->set.proxy_ssl.primary.CRLfile =
|
|
|
34bc20 |
+ data->set.str[STRING_SSL_CRLFILE_PROXY];
|
|
|
34bc20 |
data->set.ssl.cert = data->set.str[STRING_CERT];
|
|
|
34bc20 |
data->set.proxy_ssl.cert = data->set.str[STRING_CERT_PROXY];
|
|
|
34bc20 |
data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE];
|
|
|
34bc20 |
@@ -4377,10 +4380,12 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|
|
34bc20 |
data->set.ssl.primary.clientcert = data->set.str[STRING_CERT];
|
|
|
34bc20 |
data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY];
|
|
|
34bc20 |
#ifdef USE_TLS_SRP
|
|
|
34bc20 |
- data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME];
|
|
|
34bc20 |
- data->set.proxy_ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
|
|
|
34bc20 |
- data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD];
|
|
|
34bc20 |
- data->set.proxy_ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY];
|
|
|
34bc20 |
+ data->set.ssl.primary.username = data->set.str[STRING_TLSAUTH_USERNAME];
|
|
|
34bc20 |
+ data->set.ssl.primary.password = data->set.str[STRING_TLSAUTH_PASSWORD];
|
|
|
34bc20 |
+ data->set.proxy_ssl.primary.username =
|
|
|
34bc20 |
+ data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
|
|
|
34bc20 |
+ data->set.proxy_ssl.primary.password =
|
|
|
34bc20 |
+ data->set.str[STRING_TLSAUTH_PASSWORD_PROXY];
|
|
|
34bc20 |
#endif
|
|
|
34bc20 |
|
|
|
34bc20 |
if(!Curl_clone_primary_ssl_config(&data->set.ssl.primary,
|
|
|
34bc20 |
diff --git a/lib/urldata.h b/lib/urldata.h
|
|
|
34bc20 |
index 026684b..0e48841 100644
|
|
|
34bc20 |
--- a/lib/urldata.h
|
|
|
34bc20 |
+++ b/lib/urldata.h
|
|
|
34bc20 |
@@ -229,6 +229,13 @@ struct ssl_primary_config {
|
|
|
34bc20 |
char *egdsocket; /* path to file containing the EGD daemon socket */
|
|
|
34bc20 |
char *cipher_list; /* list of ciphers to use */
|
|
|
34bc20 |
char *cipher_list13; /* list of TLS 1.3 cipher suites to use */
|
|
|
34bc20 |
+ char *CRLfile; /* CRL to check certificate revocation */
|
|
|
34bc20 |
+#ifdef USE_TLS_SRP
|
|
|
34bc20 |
+ char *username; /* TLS username (for, e.g., SRP) */
|
|
|
34bc20 |
+ char *password; /* TLS password (for, e.g., SRP) */
|
|
|
34bc20 |
+ enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */
|
|
|
34bc20 |
+#endif
|
|
|
34bc20 |
+ unsigned char ssl_options; /* the CURLOPT_SSL_OPTIONS bitmask */
|
|
|
34bc20 |
};
|
|
|
34bc20 |
|
|
|
34bc20 |
struct ssl_config_data {
|
|
|
34bc20 |
@@ -238,7 +245,6 @@ struct ssl_config_data {
|
|
|
34bc20 |
bool no_revoke; /* disable SSL certificate revocation checks */
|
|
|
34bc20 |
bool no_partialchain; /* don't accept partial certificate chains */
|
|
|
34bc20 |
long certverifyresult; /* result from the certificate verification */
|
|
|
34bc20 |
- char *CRLfile; /* CRL to check certificate revocation */
|
|
|
34bc20 |
curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
|
|
|
34bc20 |
void *fsslctxp; /* parameter for call back */
|
|
|
34bc20 |
bool certinfo; /* gather lots of certificate info */
|
|
|
34bc20 |
@@ -249,12 +255,6 @@ struct ssl_config_data {
|
|
|
34bc20 |
char *key; /* private key file name */
|
|
|
34bc20 |
char *key_type; /* format for private key (default: PEM) */
|
|
|
34bc20 |
char *key_passwd; /* plain text private key password */
|
|
|
34bc20 |
-
|
|
|
34bc20 |
-#ifdef USE_TLS_SRP
|
|
|
34bc20 |
- char *username; /* TLS username (for, e.g., SRP) */
|
|
|
34bc20 |
- char *password; /* TLS password (for, e.g., SRP) */
|
|
|
34bc20 |
- enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */
|
|
|
34bc20 |
-#endif
|
|
|
34bc20 |
};
|
|
|
34bc20 |
|
|
|
34bc20 |
struct ssl_general_config {
|
|
|
34bc20 |
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
|
|
|
34bc20 |
index 6c8faa2..75ff8d8 100644
|
|
|
34bc20 |
--- a/lib/vtls/openssl.c
|
|
|
34bc20 |
+++ b/lib/vtls/openssl.c
|
|
|
34bc20 |
@@ -2232,14 +2232,14 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
|
|
|
34bc20 |
&data->set.proxy_ssl.certverifyresult : &data->set.ssl.certverifyresult;
|
|
|
34bc20 |
const long int ssl_version = SSL_CONN_CONFIG(version);
|
|
|
34bc20 |
#ifdef USE_TLS_SRP
|
|
|
34bc20 |
- const enum CURL_TLSAUTH ssl_authtype = SSL_SET_OPTION(authtype);
|
|
|
34bc20 |
+ const enum CURL_TLSAUTH ssl_authtype = SSL_SET_OPTION(primary.authtype);
|
|
|
34bc20 |
#endif
|
|
|
34bc20 |
char * const ssl_cert = SSL_SET_OPTION(cert);
|
|
|
34bc20 |
const char * const ssl_cert_type = SSL_SET_OPTION(cert_type);
|
|
|
34bc20 |
const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile);
|
|
|
34bc20 |
const char * const ssl_capath = SSL_CONN_CONFIG(CApath);
|
|
|
34bc20 |
const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
|
|
|
34bc20 |
- const char * const ssl_crlfile = SSL_SET_OPTION(CRLfile);
|
|
|
34bc20 |
+ const char * const ssl_crlfile = SSL_SET_OPTION(primary.CRLfile);
|
|
|
34bc20 |
char error_buffer[256];
|
|
|
34bc20 |
|
|
|
34bc20 |
DEBUGASSERT(ssl_connect_1 == connssl->connecting_state);
|
|
|
34bc20 |
@@ -2501,15 +2501,15 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
|
|
|
34bc20 |
#ifdef USE_TLS_SRP
|
|
|
34bc20 |
if((ssl_authtype == CURL_TLSAUTH_SRP) &&
|
|
|
34bc20 |
Curl_allow_auth_to_host(conn)) {
|
|
|
34bc20 |
- char * const ssl_username = SSL_SET_OPTION(username);
|
|
|
34bc20 |
-
|
|
|
34bc20 |
+ char * const ssl_username = SSL_SET_OPTION(primary.username);
|
|
|
34bc20 |
+ char * const ssl_password = SSL_SET_OPTION(primary.password);
|
|
|
34bc20 |
infof(data, "Using TLS-SRP username: %s\n", ssl_username);
|
|
|
34bc20 |
|
|
|
34bc20 |
if(!SSL_CTX_set_srp_username(BACKEND->ctx, ssl_username)) {
|
|
|
34bc20 |
failf(data, "Unable to set SRP user name");
|
|
|
34bc20 |
return CURLE_BAD_FUNCTION_ARGUMENT;
|
|
|
34bc20 |
}
|
|
|
34bc20 |
- if(!SSL_CTX_set_srp_password(BACKEND->ctx, SSL_SET_OPTION(password))) {
|
|
|
34bc20 |
+ if(!SSL_CTX_set_srp_password(BACKEND->ctx, ssl_password)) {
|
|
|
34bc20 |
failf(data, "failed setting SRP password");
|
|
|
34bc20 |
return CURLE_BAD_FUNCTION_ARGUMENT;
|
|
|
34bc20 |
}
|
|
|
34bc20 |
diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
|
|
|
34bc20 |
index bdff93f..2b14fa6 100644
|
|
|
34bc20 |
--- a/lib/vtls/vtls.c
|
|
|
34bc20 |
+++ b/lib/vtls/vtls.c
|
|
|
34bc20 |
@@ -88,6 +88,7 @@ Curl_ssl_config_matches(struct ssl_primary_config* data,
|
|
|
34bc20 |
{
|
|
|
34bc20 |
if((data->version == needle->version) &&
|
|
|
34bc20 |
(data->version_max == needle->version_max) &&
|
|
|
34bc20 |
+ (data->ssl_options == needle->ssl_options) &&
|
|
|
34bc20 |
(data->verifypeer == needle->verifypeer) &&
|
|
|
34bc20 |
(data->verifyhost == needle->verifyhost) &&
|
|
|
34bc20 |
(data->verifystatus == needle->verifystatus) &&
|
|
|
34bc20 |
@@ -96,6 +97,12 @@ Curl_ssl_config_matches(struct ssl_primary_config* data,
|
|
|
34bc20 |
Curl_safecmp(data->clientcert, needle->clientcert) &&
|
|
|
34bc20 |
Curl_safecmp(data->random_file, needle->random_file) &&
|
|
|
34bc20 |
Curl_safecmp(data->egdsocket, needle->egdsocket) &&
|
|
|
34bc20 |
+#ifdef USE_TLS_SRP
|
|
|
34bc20 |
+ Curl_safecmp(data->username, needle->username) &&
|
|
|
34bc20 |
+ Curl_safecmp(data->password, needle->password) &&
|
|
|
34bc20 |
+ (data->authtype == needle->authtype) &&
|
|
|
34bc20 |
+#endif
|
|
|
34bc20 |
+ Curl_safe_strcasecompare(data->CRLfile, needle->CRLfile) &&
|
|
|
34bc20 |
Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list) &&
|
|
|
34bc20 |
Curl_safe_strcasecompare(data->cipher_list13, needle->cipher_list13))
|
|
|
34bc20 |
return TRUE;
|
|
|
34bc20 |
@@ -113,6 +120,10 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
|
|
|
34bc20 |
dest->verifyhost = source->verifyhost;
|
|
|
34bc20 |
dest->verifystatus = source->verifystatus;
|
|
|
34bc20 |
dest->sessionid = source->sessionid;
|
|
|
34bc20 |
+ dest->ssl_options = source->ssl_options;
|
|
|
34bc20 |
+#ifdef USE_TLS_SRP
|
|
|
34bc20 |
+ dest->authtype = source->authtype;
|
|
|
34bc20 |
+#endif
|
|
|
34bc20 |
|
|
|
34bc20 |
CLONE_STRING(CApath);
|
|
|
34bc20 |
CLONE_STRING(CAfile);
|
|
|
34bc20 |
@@ -122,6 +133,11 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
|
|
|
34bc20 |
CLONE_STRING(egdsocket);
|
|
|
34bc20 |
CLONE_STRING(cipher_list);
|
|
|
34bc20 |
CLONE_STRING(cipher_list13);
|
|
|
34bc20 |
+ CLONE_STRING(CRLfile);
|
|
|
34bc20 |
+#ifdef USE_TLS_SRP
|
|
|
34bc20 |
+ CLONE_STRING(username);
|
|
|
34bc20 |
+ CLONE_STRING(password);
|
|
|
34bc20 |
+#endif
|
|
|
34bc20 |
|
|
|
34bc20 |
return TRUE;
|
|
|
34bc20 |
}
|
|
|
34bc20 |
@@ -136,6 +152,11 @@ void Curl_free_primary_ssl_config(struct ssl_primary_config* sslc)
|
|
|
34bc20 |
Curl_safefree(sslc->egdsocket);
|
|
|
34bc20 |
Curl_safefree(sslc->cipher_list);
|
|
|
34bc20 |
Curl_safefree(sslc->cipher_list13);
|
|
|
34bc20 |
+ Curl_safefree(sslc->CRLfile);
|
|
|
34bc20 |
+#ifdef USE_TLS_SRP
|
|
|
34bc20 |
+ Curl_safefree(sslc->username);
|
|
|
34bc20 |
+ Curl_safefree(sslc->password);
|
|
|
34bc20 |
+#endif
|
|
|
34bc20 |
}
|
|
|
34bc20 |
|
|
|
34bc20 |
#ifdef USE_SSL
|
|
|
34bc20 |
--
|
|
|
34bc20 |
2.34.1
|
|
|
34bc20 |
|
|
|
34bc20 |
|
|
|
34bc20 |
From a9cf46e6c6c9a4261f3ea8500dfef87c1436908b Mon Sep 17 00:00:00 2001
|
|
|
34bc20 |
From: Daniel Stenberg <daniel@haxx.se>
|
|
|
34bc20 |
Date: Mon, 9 May 2022 23:13:53 +0200
|
|
|
34bc20 |
Subject: [PATCH 2/2] url: check SSH config match on connection reuse
|
|
|
34bc20 |
|
|
|
34bc20 |
CVE-2022-27782
|
|
|
34bc20 |
|
|
|
34bc20 |
Reported-by: Harry Sintonen
|
|
|
34bc20 |
Bug: https://curl.se/docs/CVE-2022-27782.html
|
|
|
34bc20 |
Closes #8825
|
|
|
34bc20 |
|
|
|
34bc20 |
Upstream-commit: 1645e9b44505abd5cbaf65da5282c3f33b5924a5
|
|
|
34bc20 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
34bc20 |
---
|
|
|
34bc20 |
lib/ssh.h | 4 ++--
|
|
|
34bc20 |
lib/url.c | 11 +++++++++++
|
|
|
34bc20 |
2 files changed, 13 insertions(+), 2 deletions(-)
|
|
|
34bc20 |
|
|
|
34bc20 |
diff --git a/lib/ssh.h b/lib/ssh.h
|
|
|
34bc20 |
index 0620aac..1114f8a 100644
|
|
|
34bc20 |
--- a/lib/ssh.h
|
|
|
34bc20 |
+++ b/lib/ssh.h
|
|
|
34bc20 |
@@ -117,8 +117,8 @@ struct ssh_conn {
|
|
|
34bc20 |
|
|
|
34bc20 |
/* common */
|
|
|
34bc20 |
const char *passphrase; /* pass-phrase to use */
|
|
|
34bc20 |
- char *rsa_pub; /* path name */
|
|
|
34bc20 |
- char *rsa; /* path name */
|
|
|
34bc20 |
+ char *rsa_pub; /* strdup'ed public key file */
|
|
|
34bc20 |
+ char *rsa; /* strdup'ed private key file */
|
|
|
34bc20 |
bool authed; /* the connection has been authenticated fine */
|
|
|
34bc20 |
sshstate state; /* always use ssh.c:state() to change state! */
|
|
|
34bc20 |
sshstate nextstate; /* the state to goto after stopping */
|
|
|
34bc20 |
diff --git a/lib/url.c b/lib/url.c
|
|
|
34bc20 |
index 30fc5ad..8653ebb 100644
|
|
|
34bc20 |
--- a/lib/url.c
|
|
|
34bc20 |
+++ b/lib/url.c
|
|
|
34bc20 |
@@ -1030,6 +1030,12 @@ static size_t max_pipeline_length(struct Curl_multi *multi)
|
|
|
34bc20 |
}
|
|
|
34bc20 |
|
|
|
34bc20 |
|
|
|
34bc20 |
+static bool ssh_config_matches(struct connectdata *one,
|
|
|
34bc20 |
+ struct connectdata *two)
|
|
|
34bc20 |
+{
|
|
|
34bc20 |
+ return (Curl_safecmp(one->proto.sshc.rsa, two->proto.sshc.rsa) &&
|
|
|
34bc20 |
+ Curl_safecmp(one->proto.sshc.rsa_pub, two->proto.sshc.rsa_pub));
|
|
|
34bc20 |
+}
|
|
|
34bc20 |
/*
|
|
|
34bc20 |
* Given one filled in connection struct (named needle), this function should
|
|
|
34bc20 |
* detect if there already is one that has all the significant details
|
|
|
34bc20 |
@@ -1299,6 +1305,11 @@ ConnectionExists(struct Curl_easy *data,
|
|
|
34bc20 |
}
|
|
|
34bc20 |
}
|
|
|
34bc20 |
|
|
|
34bc20 |
+ if(needle->handler->protocol & (CURLPROTO_SCP|CURLPROTO_SFTP)) {
|
|
|
34bc20 |
+ if(!ssh_config_matches(needle, check))
|
|
|
34bc20 |
+ continue;
|
|
|
34bc20 |
+ }
|
|
|
34bc20 |
+
|
|
|
34bc20 |
if(!needle->bits.httpproxy || (needle->handler->flags&PROTOPT_SSL) ||
|
|
|
34bc20 |
needle->bits.tunnel_proxy) {
|
|
|
34bc20 |
/* The requested connection does not use a HTTP proxy or it uses SSL or
|
|
|
34bc20 |
--
|
|
|
34bc20 |
2.34.1
|
|
|
34bc20 |
|