diff -Nru curl-7.58.0/debian/changelog curl-7.58.0/debian/changelog --- curl-7.58.0/debian/changelog 2018-10-29 12:10:57.000000000 +0000 +++ curl-7.58.0/debian/changelog 2019-01-29 13:48:30.000000000 +0000 @@ -1,3 +1,20 @@ +curl (7.58.0-2ubuntu3.6) bionic-security; urgency=medium + + * SECURITY UPDATE: NTLM type-2 out-of-bounds buffer read + - debian/patches/CVE-2018-16890.patch: fix size check condition for + type2 received data in lib/vauth/ntlm.c. + - CVE-2018-16890 + * SECURITY UPDATE: NTLMv2 type-3 header stack buffer overflow + - debian/patches/CVE-2019-3822.patch: ix *_type3_message size check to + avoid buffer overflow in lib/vauth/ntlm.c. + - CVE-2019-3822 + * SECURITY UPDATE: SMTP end-of-response out-of-bounds read + - debian/patches/CVE-2019-3823.patch: avoid risk of buffer overflow in + strtol in lib/smtp.c. + - CVE-2019-3823 + + -- Marc Deslauriers Tue, 29 Jan 2019 08:48:30 -0500 + curl (7.58.0-2ubuntu3.5) bionic-security; urgency=medium * SECURITY UPDATE: SASL password overflow via integer overflow diff -Nru curl-7.58.0/debian/patches/CVE-2018-16890.patch curl-7.58.0/debian/patches/CVE-2018-16890.patch --- curl-7.58.0/debian/patches/CVE-2018-16890.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.58.0/debian/patches/CVE-2018-16890.patch 2019-01-29 13:47:09.000000000 +0000 @@ -0,0 +1,30 @@ +Backport of: + +From a54ba07a3a01f21de64ecabaafcc01b40b9db5a4 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Wed, 2 Jan 2019 20:33:08 +0100 +Subject: [PATCH 1/3] NTLM: fix size check condition for type2 received data + +Reported-by: Wenxiang Qian +--- + lib/vauth/ntlm.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +Index: curl-7.61.0/lib/vauth/ntlm.c +=================================================================== +--- curl-7.61.0.orig/lib/vauth/ntlm.c 2019-01-29 08:43:06.089838502 -0500 ++++ curl-7.61.0/lib/vauth/ntlm.c 2019-01-29 08:43:06.085838488 -0500 +@@ -182,10 +182,11 @@ static CURLcode ntlm_decode_type2_target + target_info_len = Curl_read16_le(&buffer[40]); + target_info_offset = Curl_read32_le(&buffer[44]); + if(target_info_len > 0) { +- if(((target_info_offset + target_info_len) > size) || ++ if((target_info_offset >= size) || ++ ((target_info_offset + target_info_len) > size) || + (target_info_offset < 48)) { + infof(data, "NTLM handshake failure (bad type-2 message). " +- "Target Info Offset Len is set incorrect by the peer\n"); ++ "Target Info Offset Len is set incorrect by the peer\n"); + return CURLE_BAD_CONTENT_ENCODING; + } + diff -Nru curl-7.58.0/debian/patches/CVE-2019-3822.patch curl-7.58.0/debian/patches/CVE-2019-3822.patch --- curl-7.58.0/debian/patches/CVE-2019-3822.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.58.0/debian/patches/CVE-2019-3822.patch 2019-01-29 13:48:10.000000000 +0000 @@ -0,0 +1,33 @@ +From ea9e76bc934ace9e260ab3d99438320b1f2ef501 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Thu, 3 Jan 2019 12:59:28 +0100 +Subject: [PATCH 2/3] ntlm: fix *_type3_message size check to avoid buffer + overflow + +--- + lib/vauth/ntlm.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +Index: curl-7.58.0/lib/vauth/ntlm.c +=================================================================== +--- curl-7.58.0.orig/lib/vauth/ntlm.c 2019-01-29 08:48:07.922809181 -0500 ++++ curl-7.58.0/lib/vauth/ntlm.c 2019-01-29 08:48:07.918809168 -0500 +@@ -771,11 +771,14 @@ CURLcode Curl_auth_create_ntlm_type3_mes + }); + + #ifdef USE_NTRESPONSES +- if(size < (NTLM_BUFSIZE - ntresplen)) { +- DEBUGASSERT(size == (size_t)ntrespoff); +- memcpy(&ntlmbuf[size], ptr_ntresp, ntresplen); +- size += ntresplen; ++ /* ntresplen + size should not be risking an integer overflow here */ ++ if(ntresplen + size > sizeof(ntlmbuf)) { ++ failf(data, "incoming NTLM message too big"); ++ return CURLE_OUT_OF_MEMORY; + } ++ DEBUGASSERT(size == (size_t)ntrespoff); ++ memcpy(&ntlmbuf[size], ptr_ntresp, ntresplen); ++ size += ntresplen; + + DEBUG_OUT({ + fprintf(stderr, "\n ntresp="); diff -Nru curl-7.58.0/debian/patches/CVE-2019-3823.patch curl-7.58.0/debian/patches/CVE-2019-3823.patch --- curl-7.58.0/debian/patches/CVE-2019-3823.patch 1970-01-01 00:00:00.000000000 +0000 +++ curl-7.58.0/debian/patches/CVE-2019-3823.patch 2019-01-29 13:48:13.000000000 +0000 @@ -0,0 +1,53 @@ +From 89dd3f49e1248d7f39401ecc9eecb4e82885e629 Mon Sep 17 00:00:00 2001 +From: Daniel Gustafsson +Date: Sat, 19 Jan 2019 00:42:47 +0100 +Subject: [PATCH 3/3] smtp: avoid risk of buffer overflow in strtol + +If the incoming len 5, but the buffer does not have a termination +after 5 bytes, the strtol() call may keep reading through the line +buffer until is exceeds its boundary. Fix by ensuring that we are +using a bounded read with a temporary buffer on the stack. + +Reported-by: Brian Carpenter (Geeknik Labs) +--- + lib/smtp.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/lib/smtp.c b/lib/smtp.c +index 84fc68e41..d55647b12 100644 +--- a/lib/smtp.c ++++ b/lib/smtp.c +@@ -3,11 +3,11 @@ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * +- * Copyright (C) 1998 - 2018, Daniel Stenberg, , et al. ++ * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * +@@ -205,12 +205,16 @@ static bool smtp_endofresp(struct connectdata *conn, char *line, size_t len, + /* Do we have a command response? This should be the response code followed + by a space and optionally some text as per RFC-5321 and as outlined in + Section 4. Examples of RFC-4954 but some e-mail servers ignore this and + only send the response code instead as per Section 4.2. */ + if(line[3] == ' ' || len == 5) { ++ char tmpline[6]; ++ + result = TRUE; +- *resp = curlx_sltosi(strtol(line, NULL, 10)); ++ memset(tmpline, '\0', sizeof(tmpline)); ++ memcpy(tmpline, line, (len == 5 ? 5 : 3)); ++ *resp = curlx_sltosi(strtol(tmpline, NULL, 10)); + + /* Make sure real server never sends internal value */ + if(*resp == 1) + *resp = 0; + } +-- +2.20.1 + diff -Nru curl-7.58.0/debian/patches/series curl-7.58.0/debian/patches/series --- curl-7.58.0/debian/patches/series 2018-10-29 12:10:52.000000000 +0000 +++ curl-7.58.0/debian/patches/series 2019-01-29 13:48:25.000000000 +0000 @@ -13,6 +13,9 @@ CVE-2018-16839-pre.patch CVE-2018-16839.patch oob-read.patch +CVE-2018-16890.patch +CVE-2019-3822.patch +CVE-2019-3823.patch # do not add patches below 90_gnutls.patch