Version in base suite: 7.74.0-1.3+deb11u7 Base version: curl_7.74.0-1.3+deb11u7 Target version: curl_7.74.0-1.3+deb11u8 Base file: /srv/ftp-master.debian.org/ftp/pool/main/c/curl/curl_7.74.0-1.3+deb11u7.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/c/curl/curl_7.74.0-1.3+deb11u8.dsc changelog | 13 +++ patches/CVE-2023-27533.patch | 56 +++++++++++++ patches/CVE-2023-27534.patch | 116 +++++++++++++++++++++++++++ patches/CVE-2023-27535.patch | 162 ++++++++++++++++++++++++++++++++++++++ patches/CVE-2023-27536.patch | 50 +++++++++++ patches/CVE-2023-27538.patch | 26 ++++++ patches/add_Curl_timestrcmp.patch | 51 +++++++++++ patches/series | 6 + 8 files changed, 480 insertions(+) diff -Nru curl-7.74.0/debian/changelog curl-7.74.0/debian/changelog --- curl-7.74.0/debian/changelog 2023-02-23 22:09:57.000000000 +0000 +++ curl-7.74.0/debian/changelog 2023-04-02 19:34:17.000000000 +0000 @@ -1,3 +1,16 @@ +curl (7.74.0-1.3+deb11u8) bullseye; urgency=medium + + * Backport upstream patches to fix 5 CVEs: + - CVE-2023-27533: TELNET option IAC injection + - CVE-2023-27534: SFTP path ~ resolving discrepancy + - CVE-2023-27535: FTP too eager connection reuse + - CVE-2023-27536: GSS delegation too eager connection re-use + - CVE-2023-27538: SSH connection too eager reuse still + * d/p/add_Curl_timestrcmp.patch: New patch to backport Curl_timestrcmp(), + required for CVE-2023-27535. + + -- Samuel Henrique Sun, 02 Apr 2023 20:34:17 +0100 + curl (7.74.0-1.3+deb11u7) bullseye-security; urgency=medium * Fix CVE-2023-23916: HTTP multi-header compression denial of service: diff -Nru curl-7.74.0/debian/patches/CVE-2023-27533.patch curl-7.74.0/debian/patches/CVE-2023-27533.patch --- curl-7.74.0/debian/patches/CVE-2023-27533.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.74.0/debian/patches/CVE-2023-27533.patch 2023-04-02 19:34:17.000000000 +0000 @@ -0,0 +1,56 @@ +From 538b1e79a6e7b0bb829ab4cecc828d32105d0684 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Mon, 6 Mar 2023 12:07:33 +0100 +Subject: [PATCH] telnet: only accept option arguments in ascii + +To avoid embedded telnet negotiation commands etc. + +Reported-by: Harry Sintonen +Closes #10728 + +Backported to Debian by Samuel Henrique +--- + lib/telnet.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +Index: curl/lib/telnet.c +=================================================================== +--- curl.orig/lib/telnet.c ++++ curl/lib/telnet.c +@@ -770,6 +770,17 @@ static void printsub(struct Curl_easy *d + } + } + ++static bool str_is_nonascii(const char *str) ++{ ++ size_t len = strlen(str); ++ while(len--) { ++ if(*str & 0x80) ++ return TRUE; ++ str++; ++ } ++ return FALSE; ++} ++ + static CURLcode check_telnet_options(struct connectdata *conn) + { + struct curl_slist *head; +@@ -784,6 +795,8 @@ static CURLcode check_telnet_options(str + /* Add the user name as an environment variable if it + was given on the command line */ + if(conn->bits.user_passwd) { ++ if(str_is_nonascii(conn->user)) ++ return CURLE_BAD_FUNCTION_ARGUMENT; + msnprintf(option_arg, sizeof(option_arg), "USER,%s", conn->user); + beg = curl_slist_append(tn->telnet_vars, option_arg); + if(!beg) { +@@ -799,6 +812,9 @@ static CURLcode check_telnet_options(str + if(sscanf(head->data, "%127[^= ]%*[ =]%255s", + option_keyword, option_arg) == 2) { + ++ if(str_is_nonascii(option_arg)) ++ continue; ++ + /* Terminal type */ + if(strcasecompare(option_keyword, "TTYPE")) { + strncpy(tn->subopt_ttype, option_arg, 31); diff -Nru curl-7.74.0/debian/patches/CVE-2023-27534.patch curl-7.74.0/debian/patches/CVE-2023-27534.patch --- curl-7.74.0/debian/patches/CVE-2023-27534.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.74.0/debian/patches/CVE-2023-27534.patch 2023-04-02 19:34:17.000000000 +0000 @@ -0,0 +1,116 @@ +From 4e2b52b5f7a3bf50a0f1494155717b02cc1df6d6 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Thu, 9 Mar 2023 16:22:11 +0100 +Subject: [PATCH] curl_path: create the new path with dynbuf + +Closes #10729 + +Backported to Debian by Samuel Henrique +--- + lib/curl_path.c | 75 +++++++++++++++++++++++-------------------------- + 1 file changed, 35 insertions(+), 40 deletions(-) + +Index: curl/lib/curl_path.c +=================================================================== +--- curl.orig/lib/curl_path.c ++++ curl/lib/curl_path.c +@@ -30,6 +30,8 @@ + #include "escape.h" + #include "memdebug.h" + ++#define MAX_SSHPATH_LEN 100000 /* arbitrary */ ++ + /* figure out the path to work with in this particular request */ + CURLcode Curl_getworkingpath(struct connectdata *conn, + char *homedir, /* when SFTP is used */ +@@ -40,57 +42,55 @@ CURLcode Curl_getworkingpath(struct conn + char *real_path = NULL; + char *working_path; + size_t working_path_len; ++ struct dynbuf npath; + CURLcode result = + Curl_urldecode(data, data->state.up.path, 0, &working_path, + &working_path_len, REJECT_ZERO); + if(result) + return result; + ++ /* new path to switch to in case we need to */ ++ Curl_dyn_init(&npath, MAX_SSHPATH_LEN); ++ + /* Check for /~/, indicating relative to the user's home directory */ +- if(conn->handler->protocol & CURLPROTO_SCP) { +- real_path = malloc(working_path_len + 1); +- if(real_path == NULL) { ++ if((data->conn->handler->protocol & CURLPROTO_SCP) && ++ (working_path_len > 3) && (!memcmp(working_path, "/~/", 3))) { ++ /* It is referenced to the home directory, so strip the leading '/~/' */ ++ if(Curl_dyn_addn(&npath, &working_path[3], working_path_len - 3)) { + free(working_path); + return CURLE_OUT_OF_MEMORY; + } +- if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3))) +- /* It is referenced to the home directory, so strip the leading '/~/' */ +- memcpy(real_path, working_path + 3, working_path_len - 2); +- else +- memcpy(real_path, working_path, 1 + working_path_len); + } +- else if(conn->handler->protocol & CURLPROTO_SFTP) { +- if((working_path_len > 1) && (working_path[1] == '~')) { +- size_t homelen = strlen(homedir); +- real_path = malloc(homelen + working_path_len + 1); +- if(real_path == NULL) { +- free(working_path); +- return CURLE_OUT_OF_MEMORY; +- } +- /* It is referenced to the home directory, so strip the +- leading '/' */ +- memcpy(real_path, homedir, homelen); +- real_path[homelen] = '/'; +- real_path[homelen + 1] = '\0'; +- if(working_path_len > 3) { +- memcpy(real_path + homelen + 1, working_path + 3, +- 1 + working_path_len -3); +- } ++ else if((conn->handler->protocol & CURLPROTO_SFTP) && ++ (working_path_len > 2) && !memcmp(working_path, "/~/", 3)) { ++ size_t len; ++ const char *p; ++ int copyfrom = 3; ++ if(Curl_dyn_add(&npath, homedir)) { ++ free(working_path); ++ return CURLE_OUT_OF_MEMORY; + } +- else { +- real_path = malloc(working_path_len + 1); +- if(real_path == NULL) { +- free(working_path); +- return CURLE_OUT_OF_MEMORY; +- } +- memcpy(real_path, working_path, 1 + working_path_len); ++ /* Copy a separating '/' if homedir does not end with one */ ++ len = Curl_dyn_len(&npath); ++ p = Curl_dyn_ptr(&npath); ++ if(len && (p[len-1] != '/')) ++ copyfrom = 2; ++ ++ if(Curl_dyn_addn(&npath, ++ &working_path[copyfrom], working_path_len - copyfrom)) { ++ free(working_path); ++ return CURLE_OUT_OF_MEMORY; + } + } + +- free(working_path); ++ if(Curl_dyn_len(&npath)) { ++ free(working_path); + +- /* store the pointer for the caller to receive */ +- *path = real_path; ++ /* store the pointer for the caller to receive */ ++ *path = Curl_dyn_ptr(&npath); ++ } ++ else ++ *path = working_path; + + return CURLE_OK; + } diff -Nru curl-7.74.0/debian/patches/CVE-2023-27535.patch curl-7.74.0/debian/patches/CVE-2023-27535.patch --- curl-7.74.0/debian/patches/CVE-2023-27535.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.74.0/debian/patches/CVE-2023-27535.patch 2023-04-02 19:34:17.000000000 +0000 @@ -0,0 +1,162 @@ +From 8f4608468b890dce2dad9f91d5607ee7e9c1aba1 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Thu, 9 Mar 2023 17:47:06 +0100 +Subject: [PATCH] ftp: add more conditions for connection reuse + +Reported-by: Harry Sintonen +Closes #10730 + +Backported to Debian by Samuel Henrique +--- + lib/ftp.c | 28 ++++++++++++++++++++++++++-- + lib/ftp.h | 5 +++++ + lib/setopt.c | 2 +- + lib/url.c | 17 +++++++++++++++-- + lib/urldata.h | 4 ++-- + 5 files changed, 49 insertions(+), 7 deletions(-) + +Index: curl/lib/ftp.c +=================================================================== +--- curl.orig/lib/ftp.c ++++ curl/lib/ftp.c +@@ -4038,6 +4038,8 @@ static CURLcode ftp_disconnect(struct co + } + + freedirs(ftpc); ++ Curl_safefree(ftpc->account); ++ Curl_safefree(ftpc->alternative_to_user); + Curl_safefree(ftpc->prevpath); + Curl_safefree(ftpc->server_os); + Curl_pp_disconnect(pp); +@@ -4298,11 +4300,31 @@ static CURLcode ftp_setup_connection(str + struct Curl_easy *data = conn->data; + char *type; + struct FTP *ftp; ++ struct ftp_conn *ftpc = &conn->proto.ftpc; + +- conn->data->req.p.ftp = ftp = calloc(sizeof(struct FTP), 1); ++ ftp = calloc(sizeof(struct FTP), 1); + if(NULL == ftp) + return CURLE_OUT_OF_MEMORY; + ++ /* clone connection related data that is FTP specific */ ++ if(data->set.str[STRING_FTP_ACCOUNT]) { ++ ftpc->account = strdup(data->set.str[STRING_FTP_ACCOUNT]); ++ if(!ftpc->account) { ++ free(ftp); ++ return CURLE_OUT_OF_MEMORY; ++ } ++ } ++ if(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]) { ++ ftpc->alternative_to_user = ++ strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]); ++ if(!ftpc->alternative_to_user) { ++ Curl_safefree(ftpc->account); ++ free(ftp); ++ return CURLE_OUT_OF_MEMORY; ++ } ++ } ++ data->req.p.ftp = ftp; ++ + ftp->path = &data->state.up.path[1]; /* don't include the initial slash */ + + /* FTP URLs support an extension like ";type=" that +@@ -4337,7 +4359,9 @@ static CURLcode ftp_setup_connection(str + /* get some initial data into the ftp struct */ + ftp->transfer = FTPTRANSFER_BODY; + ftp->downloadsize = 0; +- conn->proto.ftpc.known_filesize = -1; /* unknown size for now */ ++ ftpc->known_filesize = -1; /* unknown size for now */ ++ ftpc->use_ssl = data->set.use_ssl; ++ ftpc->ccc = data->set.ftp_ccc; + + return CURLE_OK; + } +Index: curl/lib/ftp.h +=================================================================== +--- curl.orig/lib/ftp.h ++++ curl/lib/ftp.h +@@ -115,6 +115,8 @@ struct FTP { + struct */ + struct ftp_conn { + struct pingpong pp; ++ char *account; ++ char *alternative_to_user; + char *entrypath; /* the PWD reply when we logged on */ + char **dirs; /* realloc()ed array for path components */ + int dirdepth; /* number of entries used in the 'dirs' array */ +@@ -140,6 +142,9 @@ struct ftp_conn { + ftpstate state; /* always use ftp.c:state() to change state! */ + ftpstate state_saved; /* transfer type saved to be reloaded after + data connection is established */ ++ unsigned char use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or ++ IMAP or POP3 or others! (type: curl_usessl)*/ ++ unsigned char ccc; /* ccc level for this connection */ + curl_off_t retr_size_saved; /* Size of retrieved file saved */ + char *server_os; /* The target server operating system. */ + curl_off_t known_filesize; /* file size is different from -1, if wildcard +Index: curl/lib/setopt.c +=================================================================== +--- curl.orig/lib/setopt.c ++++ curl/lib/setopt.c +@@ -2213,7 +2213,7 @@ CURLcode Curl_vsetopt(struct Curl_easy * + arg = va_arg(param, long); + if((arg < CURLUSESSL_NONE) || (arg >= CURLUSESSL_LAST)) + return CURLE_BAD_FUNCTION_ARGUMENT; +- data->set.use_ssl = (curl_usessl)arg; ++ data->set.use_ssl = (unsigned char)arg; + break; + + case CURLOPT_SSL_OPTIONS: +Index: curl/lib/url.c +=================================================================== +--- curl.orig/lib/url.c ++++ curl/lib/url.c +@@ -1299,10 +1299,24 @@ ConnectionExists(struct Curl_easy *data, + } + } + +- if(get_protocol_family(needle->handler) & PROTO_FAMILY_SSH) { ++#ifdef USE_SSH ++ else if(get_protocol_family(needle->handler) & PROTO_FAMILY_SSH) { + if(!ssh_config_matches(needle, check)) + continue; + } ++#endif ++#ifndef CURL_DISABLE_FTP ++ else if(get_protocol_family(needle->handler) & PROTO_FAMILY_FTP) { ++ /* Also match ACCOUNT, ALTERNATIVE-TO-USER, USE_SSL and CCC options */ ++ if(Curl_timestrcmp(needle->proto.ftpc.account, ++ check->proto.ftpc.account) || ++ Curl_timestrcmp(needle->proto.ftpc.alternative_to_user, ++ check->proto.ftpc.alternative_to_user) || ++ (needle->proto.ftpc.use_ssl != check->proto.ftpc.use_ssl) || ++ (needle->proto.ftpc.ccc != check->proto.ftpc.ccc)) ++ continue; ++ } ++#endif + + if((needle->handler->flags&PROTOPT_SSL) + #ifndef CURL_DISABLE_PROXY +Index: curl/lib/urldata.h +=================================================================== +--- curl.orig/lib/urldata.h ++++ curl/lib/urldata.h +@@ -1741,8 +1741,6 @@ struct UserDefined { + void *ssh_keyfunc_userp; /* custom pointer to callback */ + enum CURL_NETRC_OPTION + use_netrc; /* defined in include/curl.h */ +- curl_usessl use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or +- IMAP or POP3 or others! */ + long new_file_perms; /* Permissions to use when creating remote files */ + long new_directory_perms; /* Permissions to use when creating remote dirs */ + long ssh_auth_types; /* allowed SSH auth types */ +@@ -1785,6 +1783,8 @@ struct UserDefined { + CURLU *uh; /* URL handle for the current parsed URL */ + void *trailer_data; /* pointer to pass to trailer data callback */ + curl_trailer_callback trailer_callback; /* trailing data callback */ ++ unsigned char use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or ++ IMAP or POP3 or others! (type: curl_usessl)*/ + BIT(is_fread_set); /* has read callback been set to non-NULL? */ + BIT(is_fwrite_set); /* has write callback been set to non-NULL? */ + BIT(free_referer); /* set TRUE if 'referer' points to a string we diff -Nru curl-7.74.0/debian/patches/CVE-2023-27536.patch curl-7.74.0/debian/patches/CVE-2023-27536.patch --- curl-7.74.0/debian/patches/CVE-2023-27536.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.74.0/debian/patches/CVE-2023-27536.patch 2023-04-02 19:34:17.000000000 +0000 @@ -0,0 +1,50 @@ +From cb49e67303dbafbab1cebf4086e3ec15b7d56ee5 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Fri, 10 Mar 2023 09:22:43 +0100 +Subject: [PATCH] url: only reuse connections with same GSS delegation + +Reported-by: Harry Sintonen +Closes #10731 + +Backported to Debian by Samuel Henrique +--- + lib/url.c | 6 ++++++ + lib/urldata.h | 1 + + 2 files changed, 7 insertions(+) + +Index: curl/lib/url.c +=================================================================== +--- curl.orig/lib/url.c ++++ curl/lib/url.c +@@ -1299,6 +1299,11 @@ ConnectionExists(struct Curl_easy *data, + } + } + ++ /* GSS delegation differences do not actually affect every connection ++ and auth method, but this check takes precaution before efficiency */ ++ if(needle->gssapi_delegation != check->gssapi_delegation) ++ continue; ++ + #ifdef USE_SSH + else if(get_protocol_family(needle->handler) & PROTO_FAMILY_SSH) { + if(!ssh_config_matches(needle, check)) +@@ -1764,6 +1769,7 @@ static struct connectdata *allocate_conn + conn->fclosesocket = data->set.fclosesocket; + conn->closesocket_client = data->set.closesocket_client; + conn->lastused = Curl_now(); /* used now */ ++ conn->gssapi_delegation = data->set.gssapi_delegation; + + return conn; + error: +Index: curl/lib/urldata.h +=================================================================== +--- curl.orig/lib/urldata.h ++++ curl/lib/urldata.h +@@ -1016,6 +1016,7 @@ struct connectdata { + const struct Curl_handler *given; /* The protocol first given */ + + long ip_version; /* copied from the Curl_easy at creation time */ ++ unsigned char gssapi_delegation; /* inherited from set.gssapi_delegation */ + + /* Protocols can use a custom keepalive mechanism to keep connections alive. + This allows those protocols to track the last time the keepalive mechanism diff -Nru curl-7.74.0/debian/patches/CVE-2023-27538.patch curl-7.74.0/debian/patches/CVE-2023-27538.patch --- curl-7.74.0/debian/patches/CVE-2023-27538.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.74.0/debian/patches/CVE-2023-27538.patch 2023-04-02 19:34:17.000000000 +0000 @@ -0,0 +1,26 @@ +From af369db4d3833272b8ed443f7fcc2e757a0872eb Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Fri, 10 Mar 2023 08:22:51 +0100 +Subject: [PATCH] url: fix the SSH connection reuse check + +Reported-by: Harry Sintonen +Closes #10735 + +Backported to Debian by Samuel Henrique +--- + lib/url.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: curl/lib/url.c +=================================================================== +--- curl.orig/lib/url.c ++++ curl/lib/url.c +@@ -1299,7 +1299,7 @@ ConnectionExists(struct Curl_easy *data, + } + } + +- if(get_protocol_family(needle->handler) == PROTO_FAMILY_SSH) { ++ if(get_protocol_family(needle->handler) & PROTO_FAMILY_SSH) { + if(!ssh_config_matches(needle, check)) + continue; + } diff -Nru curl-7.74.0/debian/patches/add_Curl_timestrcmp.patch curl-7.74.0/debian/patches/add_Curl_timestrcmp.patch --- curl-7.74.0/debian/patches/add_Curl_timestrcmp.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.74.0/debian/patches/add_Curl_timestrcmp.patch 2023-04-02 19:34:17.000000000 +0000 @@ -0,0 +1,51 @@ +Description: Backport Curl_timestrcmp in lib/strcase.(c|h) + This patch was backported by Samuel Henrique and it + only has the changes required to backport other patches, so we are not + converting the whole codebase to make use of the new function (yet). +Author: Samuel Henrique + +Original patch details +Author: Daniel Stenberg +Origin: https://github.com/curl/curl/commit/ed5095ed94281989e103c72e032200b83be37878 + +Index: curl/lib/strcase.c +=================================================================== +--- curl.orig/lib/strcase.c ++++ curl/lib/strcase.c +@@ -271,3 +271,25 @@ int curl_strnequal(const char *first, co + { + return Curl_strncasecompare(first, second, max); + } ++ ++/* ++ * Curl_timestrcmp() returns 0 if the two strings are identical. The time this ++ * function spends is a function of the shortest string, not of the contents. ++ */ ++int Curl_timestrcmp(const char *a, const char *b) ++{ ++ int match = 0; ++ int i = 0; ++ ++ if(a && b) { ++ while(1) { ++ match |= a[i]^b[i]; ++ if(!a[i] || !b[i]) ++ break; ++ i++; ++ } ++ } ++ else ++ return a || b; ++ return match; ++} +Index: curl/lib/strcase.h +=================================================================== +--- curl.orig/lib/strcase.h ++++ curl/lib/strcase.h +@@ -49,5 +49,6 @@ void Curl_strntoupper(char *dest, const + void Curl_strntolower(char *dest, const char *src, size_t n); + + bool Curl_safecmp(char *a, char *b); ++int Curl_timestrcmp(const char *first, const char *second); + + #endif /* HEADER_CURL_STRCASE_H */ diff -Nru curl-7.74.0/debian/patches/series curl-7.74.0/debian/patches/series --- curl-7.74.0/debian/patches/series 2023-02-23 22:09:57.000000000 +0000 +++ curl-7.74.0/debian/patches/series 2023-04-02 19:34:17.000000000 +0000 @@ -32,6 +32,12 @@ CVE-2022-32221.patch CVE-2022-43552.patch CVE-2023-23916.patch +CVE-2023-27533.patch +CVE-2023-27534.patch +CVE-2023-27538.patch +add_Curl_timestrcmp.patch +CVE-2023-27535.patch +CVE-2023-27536.patch # Always add CVE patches before these two patches 90_gnutls.patch