diff --git a/backport-CVE-2021-43527.patch b/backport-CVE-2021-43527.patch deleted file mode 100644 index bc40c387d93826e3bea72e7122ae0f8f66533db6..0000000000000000000000000000000000000000 --- a/backport-CVE-2021-43527.patch +++ /dev/null @@ -1,288 +0,0 @@ -From 73a449016a1ff68539031ad600d88eab4399911f Mon Sep 17 00:00:00 2001 -From: Dennis Jackson -Date: Mon, 22 Nov 2021 10:40:42 +0000 -Subject: [PATCH] Bug 1737470 - Ensure DER encoded signatures are within size - limits. r=jschanck,mt,bbeurdouche,rrelyea - -Differential Revision: https://phabricator.services.mozilla.com/D129514 ---- - lib/cryptohi/secvfy.c | 192 ++++++++++++++++++++++++++---------------- - 1 file changed, 121 insertions(+), 71 deletions(-) - -diff --git a/lib/cryptohi/secvfy.c b/lib/cryptohi/secvfy.c -index 2540a544c5..17545848cf 100644 ---- a/lib/cryptohi/secvfy.c -+++ b/lib/cryptohi/secvfy.c -@@ -164,6 +164,37 @@ verifyPKCS1DigestInfo(const VFYContext *cx, const SECItem *digest) - PR_FALSE /*XXX: unsafeAllowMissingParameters*/); - } - -+static unsigned int -+checkedSignatureLen(const SECKEYPublicKey *pubk) -+{ -+ unsigned int sigLen = SECKEY_SignatureLen(pubk); -+ if (sigLen == 0) { -+ /* Error set by SECKEY_SignatureLen */ -+ return sigLen; -+ } -+ unsigned int maxSigLen; -+ switch (pubk->keyType) { -+ case rsaKey: -+ case rsaPssKey: -+ maxSigLen = (RSA_MAX_MODULUS_BITS + 7) / 8; -+ break; -+ case dsaKey: -+ maxSigLen = DSA_MAX_SIGNATURE_LEN; -+ break; -+ case ecKey: -+ maxSigLen = 2 * MAX_ECKEY_LEN; -+ break; -+ default: -+ PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG); -+ return 0; -+ } -+ if (sigLen > maxSigLen) { -+ PORT_SetError(SEC_ERROR_INVALID_KEY); -+ return 0; -+ } -+ return sigLen; -+} -+ - /* - * decode the ECDSA or DSA signature from it's DER wrapping. - * The unwrapped/raw signature is placed in the buffer pointed -@@ -174,38 +205,38 @@ decodeECorDSASignature(SECOidTag algid, const SECItem *sig, unsigned char *dsig, - unsigned int len) - { - SECItem *dsasig = NULL; /* also used for ECDSA */ -- SECStatus rv = SECSuccess; - -- if ((algid != SEC_OID_ANSIX9_DSA_SIGNATURE) && -- (algid != SEC_OID_ANSIX962_EC_PUBLIC_KEY)) { -- if (sig->len != len) { -- PORT_SetError(SEC_ERROR_BAD_DER); -- return SECFailure; -+ /* Safety: Ensure algId is as expected and that signature size is within maxmimums */ -+ if (algid == SEC_OID_ANSIX9_DSA_SIGNATURE) { -+ if (len > DSA_MAX_SIGNATURE_LEN) { -+ goto loser; - } -- -- PORT_Memcpy(dsig, sig->data, sig->len); -- return SECSuccess; -- } -- -- if (algid == SEC_OID_ANSIX962_EC_PUBLIC_KEY) { -+ } else if (algid == SEC_OID_ANSIX962_EC_PUBLIC_KEY) { - if (len > MAX_ECKEY_LEN * 2) { -- PORT_SetError(SEC_ERROR_BAD_DER); -- return SECFailure; -+ goto loser; - } -- } -- dsasig = DSAU_DecodeDerSigToLen((SECItem *)sig, len); -- -- if ((dsasig == NULL) || (dsasig->len != len)) { -- rv = SECFailure; - } else { -- PORT_Memcpy(dsig, dsasig->data, dsasig->len); -+ goto loser; - } - -- if (dsasig != NULL) -+ /* Decode and pad to length */ -+ dsasig = DSAU_DecodeDerSigToLen((SECItem *)sig, len); -+ if (dsasig == NULL) { -+ goto loser; -+ } -+ if (dsasig->len != len) { - SECITEM_FreeItem(dsasig, PR_TRUE); -- if (rv == SECFailure) -- PORT_SetError(SEC_ERROR_BAD_DER); -- return rv; -+ goto loser; -+ } -+ -+ PORT_Memcpy(dsig, dsasig->data, len); -+ SECITEM_FreeItem(dsasig, PR_TRUE); -+ -+ return SECSuccess; -+ -+loser: -+ PORT_SetError(SEC_ERROR_BAD_DER); -+ return SECFailure; - } - - const SEC_ASN1Template hashParameterTemplate[] = -@@ -281,7 +312,7 @@ SECStatus - sec_DecodeSigAlg(const SECKEYPublicKey *key, SECOidTag sigAlg, - const SECItem *param, SECOidTag *encalgp, SECOidTag *hashalg) - { -- int len; -+ unsigned int len; - PLArenaPool *arena; - SECStatus rv; - SECItem oid; -@@ -466,48 +497,52 @@ vfy_CreateContext(const SECKEYPublicKey *key, const SECItem *sig, - cx->pkcs1RSADigestInfo = NULL; - rv = SECSuccess; - if (sig) { -- switch (type) { -- case rsaKey: -- rv = recoverPKCS1DigestInfo(hashAlg, &cx->hashAlg, -- &cx->pkcs1RSADigestInfo, -- &cx->pkcs1RSADigestInfoLen, -- cx->key, -- sig, wincx); -- break; -- case rsaPssKey: -- sigLen = SECKEY_SignatureLen(key); -- if (sigLen == 0) { -- /* error set by SECKEY_SignatureLen */ -- rv = SECFailure; -+ rv = SECFailure; -+ if (type == rsaKey) { -+ rv = recoverPKCS1DigestInfo(hashAlg, &cx->hashAlg, -+ &cx->pkcs1RSADigestInfo, -+ &cx->pkcs1RSADigestInfoLen, -+ cx->key, -+ sig, wincx); -+ } else { -+ sigLen = checkedSignatureLen(key); -+ /* Check signature length is within limits */ -+ if (sigLen == 0) { -+ /* error set by checkedSignatureLen */ -+ rv = SECFailure; -+ goto loser; -+ } -+ if (sigLen > sizeof(cx->u)) { -+ PORT_SetError(SEC_ERROR_BAD_SIGNATURE); -+ rv = SECFailure; -+ goto loser; -+ } -+ switch (type) { -+ case rsaPssKey: -+ if (sig->len != sigLen) { -+ PORT_SetError(SEC_ERROR_BAD_SIGNATURE); -+ rv = SECFailure; -+ goto loser; -+ } -+ PORT_Memcpy(cx->u.buffer, sig->data, sigLen); -+ rv = SECSuccess; - break; -- } -- if (sig->len != sigLen) { -- PORT_SetError(SEC_ERROR_BAD_SIGNATURE); -- rv = SECFailure; -+ case ecKey: -+ case dsaKey: -+ /* decodeECorDSASignature will check sigLen == sig->len after padding */ -+ rv = decodeECorDSASignature(encAlg, sig, cx->u.buffer, sigLen); - break; -- } -- PORT_Memcpy(cx->u.buffer, sig->data, sigLen); -- break; -- case dsaKey: -- case ecKey: -- sigLen = SECKEY_SignatureLen(key); -- if (sigLen == 0) { -- /* error set by SECKEY_SignatureLen */ -+ default: -+ /* Unreachable */ - rv = SECFailure; -- break; -- } -- rv = decodeECorDSASignature(encAlg, sig, cx->u.buffer, sigLen); -- break; -- default: -- rv = SECFailure; -- PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG); -- break; -+ goto loser; -+ } -+ } -+ if (rv != SECSuccess) { -+ goto loser; - } - } - -- if (rv) -- goto loser; -- - /* check hash alg again, RSA may have changed it.*/ - if (HASH_GetHashTypeByOidTag(cx->hashAlg) == HASH_AlgNULL) { - /* error set by HASH_GetHashTypeByOidTag */ -@@ -650,11 +685,16 @@ VFY_EndWithSignature(VFYContext *cx, SECItem *sig) - switch (cx->key->keyType) { - case ecKey: - case dsaKey: -- dsasig.data = cx->u.buffer; -- dsasig.len = SECKEY_SignatureLen(cx->key); -+ dsasig.len = checkedSignatureLen(cx->key); - if (dsasig.len == 0) { - return SECFailure; - } -+ if (dsasig.len > sizeof(cx->u)) { -+ PORT_SetError(SEC_ERROR_BAD_SIGNATURE); -+ return SECFailure; -+ } -+ dsasig.data = cx->u.buffer; -+ - if (sig) { - rv = decodeECorDSASignature(cx->encAlg, sig, dsasig.data, - dsasig.len); -@@ -686,8 +726,13 @@ VFY_EndWithSignature(VFYContext *cx, SECItem *sig) - } - - rsasig.data = cx->u.buffer; -- rsasig.len = SECKEY_SignatureLen(cx->key); -+ rsasig.len = checkedSignatureLen(cx->key); - if (rsasig.len == 0) { -+ /* Error set by checkedSignatureLen */ -+ return SECFailure; -+ } -+ if (rsasig.len > sizeof(cx->u)) { -+ PORT_SetError(SEC_ERROR_BAD_SIGNATURE); - return SECFailure; - } - if (sig) { -@@ -749,7 +794,6 @@ vfy_VerifyDigest(const SECItem *digest, const SECKEYPublicKey *key, - SECStatus rv; - VFYContext *cx; - SECItem dsasig; /* also used for ECDSA */ -- - rv = SECFailure; - - cx = vfy_CreateContext(key, sig, encAlg, hashAlg, NULL, wincx); -@@ -757,19 +801,25 @@ vfy_VerifyDigest(const SECItem *digest, const SECKEYPublicKey *key, - switch (key->keyType) { - case rsaKey: - rv = verifyPKCS1DigestInfo(cx, digest); -+ /* Error (if any) set by verifyPKCS1DigestInfo */ - break; -- case dsaKey: - case ecKey: -+ case dsaKey: - dsasig.data = cx->u.buffer; -- dsasig.len = SECKEY_SignatureLen(cx->key); -+ dsasig.len = checkedSignatureLen(cx->key); - if (dsasig.len == 0) { -+ /* Error set by checkedSignatureLen */ -+ rv = SECFailure; - break; - } -- if (PK11_Verify(cx->key, &dsasig, (SECItem *)digest, cx->wincx) != -- SECSuccess) { -+ if (dsasig.len > sizeof(cx->u)) { -+ PORT_SetError(SEC_ERROR_BAD_SIGNATURE); -+ rv = SECFailure; -+ break; -+ } -+ rv = PK11_Verify(cx->key, &dsasig, (SECItem *)digest, cx->wincx); -+ if (rv != SECSuccess) { - PORT_SetError(SEC_ERROR_BAD_SIGNATURE); -- } else { -- rv = SECSuccess; - } - break; - default: diff --git a/nss-3.72.tar.gz b/nss-3.76.tar.gz similarity index 84% rename from nss-3.72.tar.gz rename to nss-3.76.tar.gz index 03c18e014aaf6b74079f1f26cbf06790d78b9422..ad9fb66c1b6b93b25f8e89ee498e567e440182f5 100644 Binary files a/nss-3.72.tar.gz and b/nss-3.76.tar.gz differ diff --git a/nss-539183.patch b/nss-539183.patch deleted file mode 100644 index eda32492eff006038ccdadd229ff07c57fdd6ebb..0000000000000000000000000000000000000000 --- a/nss-539183.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- ./nss/cmd/httpserv/httpserv.c.539183 2016-05-21 18:31:39.879585420 -0700 -+++ ./nss/cmd/httpserv/httpserv.c 2016-05-21 18:37:22.374464057 -0700 -@@ -953,23 +953,23 @@ - getBoundListenSocket(unsigned short port) - { - PRFileDesc *listen_sock; - int listenQueueDepth = 5 + (2 * maxThreads); - PRStatus prStatus; - PRNetAddr addr; - PRSocketOptionData opt; - -- addr.inet.family = PR_AF_INET; -- addr.inet.ip = PR_INADDR_ANY; -- addr.inet.port = PR_htons(port); -+ if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, port, &addr) != PR_SUCCESS) { -+ errExit("PR_SetNetAddr"); -+ } - -- listen_sock = PR_NewTCPSocket(); -+ listen_sock = PR_OpenTCPSocket(PR_AF_INET6); - if (listen_sock == NULL) { -- errExit("PR_NewTCPSocket"); -+ errExit("PR_OpenTCPSockett"); - } - - opt.option = PR_SockOpt_Nonblocking; - opt.value.non_blocking = PR_FALSE; - prStatus = PR_SetSocketOption(listen_sock, &opt); - if (prStatus < 0) { - PR_Close(listen_sock); - errExit("PR_SetSocketOption(PR_SockOpt_Nonblocking)"); ---- ./nss/cmd/selfserv/selfserv.c.539183 2016-05-21 18:31:39.882585367 -0700 -+++ ./nss/cmd/selfserv/selfserv.c 2016-05-21 18:41:43.092801174 -0700 -@@ -1711,23 +1711,23 @@ - getBoundListenSocket(unsigned short port) - { - PRFileDesc *listen_sock; - int listenQueueDepth = 5 + (2 * maxThreads); - PRStatus prStatus; - PRNetAddr addr; - PRSocketOptionData opt; - -- addr.inet.family = PR_AF_INET; -- addr.inet.ip = PR_INADDR_ANY; -- addr.inet.port = PR_htons(port); -+ if (PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, port, &addr) != PR_SUCCESS) { -+ errExit("PR_SetNetAddr"); -+ } - -- listen_sock = PR_NewTCPSocket(); -+ listen_sock = PR_OpenTCPSocket(PR_AF_INET6); - if (listen_sock == NULL) { -- errExit("PR_NewTCPSocket"); -+ errExit("PR_OpenTCPSocket error"); - } - - opt.option = PR_SockOpt_Nonblocking; - opt.value.non_blocking = PR_FALSE; - prStatus = PR_SetSocketOption(listen_sock, &opt); - if (prStatus < 0) { - PR_Close(listen_sock); - errExit("PR_SetSocketOption(PR_SockOpt_Nonblocking)"); diff --git a/nss-config b/nss-config index f1faa4c1e74176d10669c03283a0d5f5b59950d5..b1425070bf2b7e89a8c61b500873574ced24854d 100644 --- a/nss-config +++ b/nss-config @@ -3,7 +3,7 @@ prefix=/usr major_version=3 -minor_version=54 +minor_version=76 patch_version=0 usage() diff --git a/nss-softokn-config b/nss-softokn-config index 250809588fe45e1fe0bd64eae96a1683c348555a..2b2fc090d5f772ca095cc31b3809f197972f7a50 100644 --- a/nss-softokn-config +++ b/nss-softokn-config @@ -3,7 +3,7 @@ prefix=/usr major_version=3 -minor_version=54 +minor_version=76 patch_version=0 usage() diff --git a/nss-softokn.pc b/nss-softokn.pc index db1cf7af72f1fe66befd204a2ec54fe531c2a6cb..12b60735aeda843327343ac3c4b2f5dbbe3ea86b 100644 --- a/nss-softokn.pc +++ b/nss-softokn.pc @@ -5,7 +5,7 @@ includedir=/usr/include/nss3 Name: NSS-SOFTOKN Description: Network Security Services Softoken PKCS #11 Module -Version: 3.54 -Requires: nspr >= 4.20.0, nss-util >= 3.54 +Version: 3.76 +Requires: nspr >= 4.32.0, nss-util >= 3.76 Libs: -L${libdir} -lfreebl3 -lnssdbm3 -lsoftokn3 Cflags: -I${includedir} diff --git a/nss-util-config b/nss-util-config index d430180d5f17365eb96ce79221110fc22a5d6497..7c65c06033028401c9ec4259420ef1c146ba56ec 100644 --- a/nss-util-config +++ b/nss-util-config @@ -3,7 +3,7 @@ prefix=/usr major_version=3 -minor_version=54 +minor_version=76 patch_version=0 usage() diff --git a/nss-util.pc b/nss-util.pc index f036ca2e9820ec0bdb3a2e8bbe2a7e4c9ac2f202..e3265e30b78a68c73cf977a0fa52ccdc2efdc293 100644 --- a/nss-util.pc +++ b/nss-util.pc @@ -5,7 +5,7 @@ includedir=/usr/include/nss3 Name: NSS-UTIL Description: Network Security Services Utility Library -Version: 3.54 -Requires: nspr >= 4.20.0 +Version: 3.76 +Requires: nspr >= 4.32.0 Libs: -L${libdir} -lnssutil3 Cflags: -I${includedir} diff --git a/nss.pc b/nss.pc index 042352ba62ea8862ffb7f2182a7415741bac1cc6..147a95b5a2ae67a7b11cebd32b4b0f1ddbf50e96 100644 --- a/nss.pc +++ b/nss.pc @@ -5,7 +5,7 @@ includedir=/usr/include/nss3 Name: NSS Description: Network Security Services -Version: 3.54 -Requires: nspr >= 4.20.0, nss-util >= 3.54 +Version: 3.76 +Requires: nspr >= 4.32.0, nss-util >= 3.76 Libs: -L${libdir} -lssl3 -lsmime3 -lnss3 Cflags: -I${includedir} diff --git a/nss.spec b/nss.spec index efb5a473793fd5053693fb3a556b0f70bc854836..a790ca346826967da1fe281da4804f2940d3f594 100644 --- a/nss.spec +++ b/nss.spec @@ -1,6 +1,6 @@ -%global nspr_version 4.26.0 -%global nss_version 3.72.0 -%global nss_archive_version 3.72 +%global nspr_version 4.32.0 +%global nss_version 3.76.0 +%global nss_archive_version 3.76 %global unsupported_tools_directory %{_libdir}/nss/unsupported-tools %global allTools "certutil cmsutil crlutil derdump modutil pk12util signtool signver ssltap vfychain vfyserv" @@ -14,7 +14,7 @@ Summary: Network Security Services Name: nss Version: %{nss_version} -Release: 2 +Release: 1 License: MPLv2.0 URL: http://www.mozilla.org/projects/security/pki/nss/ Provides: nss-system-init @@ -25,7 +25,7 @@ BuildRequires: nspr-devel >= %{nspr_version} nss-softokn sqlite-devel zlib-de BuildRequires: pkgconf gawk psmisc perl-interpreter gcc-c++ obsoletes: nss-sysinit < %{version}-%{release} -Source0: https://ftp.mozilla.org/pub/security/nss/releases/NSS_3_54_RTM/src/%{name}-%{nss_archive_version}.tar.gz +Source0: https://ftp.mozilla.org/pub/security/nss/releases/NSS_3_74_RTM/src/%{name}-%{nss_archive_version}.tar.gz Source1: nss-util.pc Source2: nss-util-config Source3: nss-softokn.pc @@ -39,9 +39,6 @@ Source13: blank-cert9.db Source14: blank-key4.db Source15: system-pkcs11.txt Source16: setup-nsssysinit.sh -Patch0: nss-539183.patch - -Patch6000: backport-CVE-2021-43527.patch %description Network Security Services (NSS) is a set of libraries designed to @@ -124,13 +121,9 @@ Help document for NSS %prep %setup -q -n %{name}-%{nss_archive_version} -%patch0 -p0 -b .539183 -pushd nss -%patch6000 -p1 -popd - %build + export NSS_FORCE_FIPS=1 # Enable compiler optimizations and disable debugging code @@ -174,7 +167,6 @@ export USE_64=1 %endif %endif - # Set the policy file location # if set NSS will always check for the policy file and load if it exists export POLICY_FILE="nss.config" @@ -549,6 +541,9 @@ update-crypto-policies &>/dev/null||: %doc %{_mandir}/man* %changelog +* Sun May 29 2022 Jingwiw - 3.74.0-1 +- upgrade version to 3.74 + * Tue Dec 28 2021 shangyibin - 3.72-2 - fix CVE-2021-43527