From nobody Tue Aug 01 19:20:23 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RFlM34vsRz4plm7; Tue, 1 Aug 2023 19:20:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RFlLc3RTsz4c9Q; Tue, 1 Aug 2023 19:20:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690917624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wCII1jqN/Q6Eid/MSxSLsfTSpZUHprWJRTnuniyCzgM=; b=iMUbn/cnDFMt+ZYI5rW6gXWIja6QuxsHnKFbueI8EWnPsE+KaZ8SqbDigq68I9M/znxYnB 1yDVnvlZqL6pRr/AvidYTEeIu5+xPQmeQ0QC5vTSQeHg5d8iFsEHD32RVLho8kV6aM7/tT SpX/vvVPeBPm3rPEGhWXjhtT1k/PhXWWOBSvIGG0PHVkNeePLnPjFmobBwRjaCI/ynT60b RQfz0pdrTKitvWqA7P6Sw7UTpf+3f8tUXsCSWO3d95CIodaxCSoE6OrALlvlz3GGxq19cv k4krCK9E7pmVD8N8FWCadi4MREHicogHbXn+kKrilsBSzdmgxk/vFSouF9WYnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690917624; a=rsa-sha256; cv=none; b=WzrZFShN6ZtxnoPTqsc7hpYQzFY3x2PSQ/Nar0HOml2At2P3RLjo9shd9BQyL+PTAs+2/l XCEZ261AvtLoOehKetqA4+EepQbYn/O1E9ZJKU/t+ZWPnv2XGU+rAyJ/LhMQ7GoaPYggXJ zv7bviluTu1xLwi+lsCZi0EmL6OC/TjhAC4c8sTeCq1NmtTowaoPo5bFVCNDy5+mDc1f7T 2uCiAhqJaPWR5TQeCnOyAexKJpK6GwpujiKWweUyp0OgSVZvrk0IMEDG7G8pAcssS3e9dE Ipwkm6tTyL9jLdOmVZjRXAq6x1WRVwkiEHQX+3fs55jTDKUnBCGl2lJ9c+aCzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690917624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wCII1jqN/Q6Eid/MSxSLsfTSpZUHprWJRTnuniyCzgM=; b=MqC4V00YhIj/1wVsgJntet0hbXkPiwS7FScY+hvPhZqqSVk8nNGL6FYIbzUOXGkSvbseMQ 4fYrxkjXPCEgSuGg38Fyk54AD7m9OJ3Y6v47w0KyNOldSWQngfPqNWVnwlADXOKTzd+2bt NftIztZUfsfz18WNwBK1lLE6zvMVkIZ7H6d52Z4ORj4yF+Pq7FWQtuNf8+09eN37sN5ckM HjfcXoeYS/VjesCXw7MQYcwNk/GvHKWUt9soEqAZEBuRvaTSq5ebsWbxdsUxmCbDdtnTGv mPEnbkmU4JOfkksrQXxWC453anx1f6jFkjwKMkk6eEF6iqsotcvDRh+/ZGrAXw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RFlLc0xF0zppf; Tue, 1 Aug 2023 19:20:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 371JKNdF038634; Tue, 1 Aug 2023 19:20:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 371JKNIS038633; Tue, 1 Aug 2023 19:20:23 GMT (envelope-from git) Date: Tue, 1 Aug 2023 19:20:23 GMT Message-Id: <202308011920.371JKNIS038633@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jung-uk Kim Subject: git: 1b34edce0aa1 - stable/12 - OpenSSL: Import OpenSSL 1.1.1v List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jkim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 1b34edce0aa1da318262b1b54eb6829c31d8ccfb Auto-Submitted: auto-generated The branch stable/12 has been updated by jkim: URL: https://cgit.FreeBSD.org/src/commit/?id=1b34edce0aa1da318262b1b54eb6829c31d8ccfb commit 1b34edce0aa1da318262b1b54eb6829c31d8ccfb Author: Jung-uk Kim AuthorDate: 2023-08-01 14:48:37 +0000 Commit: Jung-uk Kim CommitDate: 2023-08-01 19:15:45 +0000 OpenSSL: Import OpenSSL 1.1.1v (cherry picked from commit cc0d356166e39da7f956c39f874e6dee67fd5d60) --- crypto/openssl/CHANGES | 35 +++++++++++++++++++++++++++++++ crypto/openssl/NEWS | 5 +++++ crypto/openssl/README | 2 +- crypto/openssl/crypto/dh/dh_check.c | 20 +++++++++++++++--- crypto/openssl/crypto/dh/dh_err.c | 3 ++- crypto/openssl/crypto/err/openssl.txt | 3 ++- crypto/openssl/include/openssl/dh.h | 5 ++++- crypto/openssl/include/openssl/dherr.h | 3 ++- crypto/openssl/include/openssl/opensslv.h | 4 ++-- 9 files changed, 70 insertions(+), 10 deletions(-) diff --git a/crypto/openssl/CHANGES b/crypto/openssl/CHANGES index 8945260c3eaf..52c2edf150e9 100644 --- a/crypto/openssl/CHANGES +++ b/crypto/openssl/CHANGES @@ -7,6 +7,41 @@ https://github.com/openssl/openssl/commits/ and pick the appropriate release branch. + Changes between 1.1.1u and 1.1.1v [1 Aug 2023] + + *) Fix excessive time spent checking DH q parameter value. + + The function DH_check() performs various checks on DH parameters. After + fixing CVE-2023-3446 it was discovered that a large q parameter value can + also trigger an overly long computation during some of these checks. + A correct q value, if present, cannot be larger than the modulus p + parameter, thus it is unnecessary to perform these checks if q is larger + than p. + + If DH_check() is called with such q parameter value, + DH_CHECK_INVALID_Q_VALUE return flag is set and the computationally + intensive checks are skipped. + + (CVE-2023-3817) + [Tomáš Mráz] + + *) Fix DH_check() excessive time with over sized modulus + + The function DH_check() performs various checks on DH parameters. One of + those checks confirms that the modulus ("p" parameter) is not too large. + Trying to use a very large modulus is slow and OpenSSL will not normally use + a modulus which is over 10,000 bits in length. + + However the DH_check() function checks numerous aspects of the key or + parameters that have been supplied. Some of those checks use the supplied + modulus value even if it has already been found to be too large. + + A new limit has been added to DH_check of 32,768 bits. Supplying a + key/parameters with a modulus over this size will simply cause DH_check() + to fail. + (CVE-2023-3446) + [Matt Caswell] + Changes between 1.1.1t and 1.1.1u [30 May 2023] *) Mitigate for the time it takes for `OBJ_obj2txt` to translate gigantic diff --git a/crypto/openssl/NEWS b/crypto/openssl/NEWS index f5a2d5ad33f8..c71c02911db0 100644 --- a/crypto/openssl/NEWS +++ b/crypto/openssl/NEWS @@ -5,6 +5,11 @@ This file gives a brief overview of the major changes between each OpenSSL release. For more details please read the CHANGES file. + Major changes between OpenSSL 1.1.1u and OpenSSL 1.1.1v [1 Aug 2023] + + o Fix excessive time spent checking DH q parameter value (CVE-2023-3817) + o Fix DH_check() excessive time with over sized modulus (CVE-2023-3446) + Major changes between OpenSSL 1.1.1t and OpenSSL 1.1.1u [30 May 2023] o Mitigate for very slow `OBJ_obj2txt()` performance with gigantic diff --git a/crypto/openssl/README b/crypto/openssl/README index b9bf50f4b1e5..dbe6bf756e94 100644 --- a/crypto/openssl/README +++ b/crypto/openssl/README @@ -1,5 +1,5 @@ - OpenSSL 1.1.1u 30 May 2023 + OpenSSL 1.1.1v 1 Aug 2023 Copyright (c) 1998-2023 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson diff --git a/crypto/openssl/crypto/dh/dh_check.c b/crypto/openssl/crypto/dh/dh_check.c index 4ac169e75c23..ae1b03bc92d9 100644 --- a/crypto/openssl/crypto/dh/dh_check.c +++ b/crypto/openssl/crypto/dh/dh_check.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -97,10 +97,17 @@ int DH_check_ex(const DH *dh) int DH_check(const DH *dh, int *ret) { - int ok = 0, r; + int ok = 0, r, q_good = 0; BN_CTX *ctx = NULL; BIGNUM *t1 = NULL, *t2 = NULL; + /* Don't do any checks at all with an excessively large modulus */ + if (BN_num_bits(dh->p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) { + DHerr(DH_F_DH_CHECK, DH_R_MODULUS_TOO_LARGE); + *ret = DH_CHECK_P_NOT_PRIME; + return 0; + } + if (!DH_check_params(dh, ret)) return 0; @@ -113,7 +120,14 @@ int DH_check(const DH *dh, int *ret) if (t2 == NULL) goto err; - if (dh->q) { + if (dh->q != NULL) { + if (BN_ucmp(dh->p, dh->q) > 0) + q_good = 1; + else + *ret |= DH_CHECK_INVALID_Q_VALUE; + } + + if (q_good) { if (BN_cmp(dh->g, BN_value_one()) <= 0) *ret |= DH_NOT_SUITABLE_GENERATOR; else if (BN_cmp(dh->g, dh->p) >= 0) diff --git a/crypto/openssl/crypto/dh/dh_err.c b/crypto/openssl/crypto/dh/dh_err.c index 7285587b4ade..92800d3fcc6b 100644 --- a/crypto/openssl/crypto/dh/dh_err.c +++ b/crypto/openssl/crypto/dh/dh_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -18,6 +18,7 @@ static const ERR_STRING_DATA DH_str_functs[] = { {ERR_PACK(ERR_LIB_DH, DH_F_DHPARAMS_PRINT_FP, 0), "DHparams_print_fp"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS, 0), "dh_builtin_genparams"}, + {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK, 0), "DH_check"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_EX, 0), "DH_check_ex"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_PARAMS_EX, 0), "DH_check_params_ex"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_PUB_KEY_EX, 0), "DH_check_pub_key_ex"}, diff --git a/crypto/openssl/crypto/err/openssl.txt b/crypto/openssl/crypto/err/openssl.txt index 9f91a4a811e6..c0a3cd720ba7 100644 --- a/crypto/openssl/crypto/err/openssl.txt +++ b/crypto/openssl/crypto/err/openssl.txt @@ -1,4 +1,4 @@ -# Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 1999-2023 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the OpenSSL license (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy @@ -401,6 +401,7 @@ CT_F_SCT_SET_VERSION:104:SCT_set_version DH_F_COMPUTE_KEY:102:compute_key DH_F_DHPARAMS_PRINT_FP:101:DHparams_print_fp DH_F_DH_BUILTIN_GENPARAMS:106:dh_builtin_genparams +DH_F_DH_CHECK:126:DH_check DH_F_DH_CHECK_EX:121:DH_check_ex DH_F_DH_CHECK_PARAMS_EX:122:DH_check_params_ex DH_F_DH_CHECK_PUB_KEY_EX:123:DH_check_pub_key_ex diff --git a/crypto/openssl/include/openssl/dh.h b/crypto/openssl/include/openssl/dh.h index 3527540cdddb..6c6ff3636ae7 100644 --- a/crypto/openssl/include/openssl/dh.h +++ b/crypto/openssl/include/openssl/dh.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -29,6 +29,9 @@ extern "C" { # ifndef OPENSSL_DH_MAX_MODULUS_BITS # define OPENSSL_DH_MAX_MODULUS_BITS 10000 # endif +# ifndef OPENSSL_DH_CHECK_MAX_MODULUS_BITS +# define OPENSSL_DH_CHECK_MAX_MODULUS_BITS 32768 +# endif # define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024 diff --git a/crypto/openssl/include/openssl/dherr.h b/crypto/openssl/include/openssl/dherr.h index 916b3bed0b59..528c81985633 100644 --- a/crypto/openssl/include/openssl/dherr.h +++ b/crypto/openssl/include/openssl/dherr.h @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -30,6 +30,7 @@ int ERR_load_DH_strings(void); # define DH_F_COMPUTE_KEY 102 # define DH_F_DHPARAMS_PRINT_FP 101 # define DH_F_DH_BUILTIN_GENPARAMS 106 +# define DH_F_DH_CHECK 126 # define DH_F_DH_CHECK_EX 121 # define DH_F_DH_CHECK_PARAMS_EX 122 # define DH_F_DH_CHECK_PUB_KEY_EX 123 diff --git a/crypto/openssl/include/openssl/opensslv.h b/crypto/openssl/include/openssl/opensslv.h index 029d292e63e3..7a8ba63d9603 100644 --- a/crypto/openssl/include/openssl/opensslv.h +++ b/crypto/openssl/include/openssl/opensslv.h @@ -39,8 +39,8 @@ extern "C" { * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -# define OPENSSL_VERSION_NUMBER 0x1010115fL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1u-freebsd 30 May 2023" +# define OPENSSL_VERSION_NUMBER 0x1010116fL +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1v-freebsd 1 Aug 2023" /*- * The macros below are to be used for shared library (.so, .dll, ...)