diff options
author | J0WI <J0WI@users.noreply.github.com> | 2024-01-25 21:40:01 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2024-01-26 01:53:36 +0000 |
commit | 9fd14fce55ac36f382b575276db9131d69466024 (patch) | |
tree | ff5f58d1f34aa934b966af16426d7eb5603a69b7 | |
parent | 3ec961bc602a71357d28380a4d6927b3c61ef626 (diff) |
main/openssl: patch CVE-2024-0727
-rw-r--r-- | main/openssl/APKBUILD | 6 | ||||
-rw-r--r-- | main/openssl/CVE-2024-0727.patch | 120 |
2 files changed, 125 insertions, 1 deletions
diff --git a/main/openssl/APKBUILD b/main/openssl/APKBUILD index 7d41ce0a8a7..5a9d3d03241 100644 --- a/main/openssl/APKBUILD +++ b/main/openssl/APKBUILD @@ -4,7 +4,7 @@ pkgname=openssl pkgver=3.0.12 _abiver=${pkgver%.*.*} -pkgrel=3 +pkgrel=4 pkgdesc="Toolkit for Transport Layer Security (TLS)" url="https://www.openssl.org/" arch="all" @@ -16,6 +16,7 @@ makedepends="$makedepends_host $makedepends_build" subpackages="$pkgname-dbg $pkgname-libs-static $pkgname-dev $pkgname-doc libcrypto$_abiver:_libcrypto libssl$_abiver:_libssl" source="https://www.openssl.org/source/openssl-$pkgver.tar.gz + CVE-2024-0727.patch CVE-2023-6237.patch CVE-2023-6129.patch CVE-2023-5678.patch @@ -24,6 +25,8 @@ source="https://www.openssl.org/source/openssl-$pkgver.tar.gz builddir="$srcdir/openssl-$pkgver" # secfixes: +# 3.0.12-r4: +# - CVE-2024-0727 # 3.0.12-r3: # - CVE-2023-6237 # 3.0.12-r2: @@ -221,6 +224,7 @@ _libssl() { sha512sums=" 63e003653dd1126c66e278969a626cdf0801b97da8b7076824d661e4a77e1572c3171cf7f006c972b95bcfa284889ee0362d8a46a851f7d8e743e2a1fe593b24 openssl-3.0.12.tar.gz +5074ce0e10bec0ecd1cefa76f2660fa2e4693ed38f1dbbad1cbb5f2983c7170957099e0cd0f870e21515966ba2dcfc495f037078129cbd8b6644813592a1ddb6 CVE-2024-0727.patch 207dd6613310e150a9534e474f41f535c963198a293dae430e339c4fb3c01091d7412cb84fd01604aa8f50e1e84890b41c7d36c2b91c128c19793821d7bdaff7 CVE-2023-6237.patch f4767a4f76bc3681e06996cef86ebc981327bb9af296385d29c694696a80557b4984166c057518c3cd414a858558ecae81f6dda54f5215c4666629a6ef8b88ce CVE-2023-6129.patch a2461996df36330601d518a77509e4991c98969b100ae794eefb102b3070ef7f3a970e1be7ea3acd5b25537a1458dfba642d1f291e83b1737b0ef7b72931a113 CVE-2023-5678.patch diff --git a/main/openssl/CVE-2024-0727.patch b/main/openssl/CVE-2024-0727.patch new file mode 100644 index 00000000000..8c8e0ba21dd --- /dev/null +++ b/main/openssl/CVE-2024-0727.patch @@ -0,0 +1,120 @@ +From 09df4395b5071217b76dc7d3d2e630eb8c5a79c2 Mon Sep 17 00:00:00 2001 +From: Matt Caswell <matt@openssl.org> +Date: Fri, 19 Jan 2024 11:28:58 +0000 +Subject: [PATCH] Add NULL checks where ContentInfo data can be NULL + +PKCS12 structures contain PKCS7 ContentInfo fields. These fields are +optional and can be NULL even if the "type" is a valid value. OpenSSL +was not properly accounting for this and a NULL dereference can occur +causing a crash. + +CVE-2024-0727 + +Reviewed-by: Tomas Mraz <tomas@openssl.org> +Reviewed-by: Hugo Landau <hlandau@openssl.org> +Reviewed-by: Neil Horman <nhorman@openssl.org> +(Merged from https://github.com/openssl/openssl/pull/23362) + +(cherry picked from commit d135eeab8a5dbf72b3da5240bab9ddb7678dbd2c) +--- + crypto/pkcs12/p12_add.c | 18 ++++++++++++++++++ + crypto/pkcs12/p12_mutl.c | 5 +++++ + crypto/pkcs12/p12_npas.c | 5 +++-- + crypto/pkcs7/pk7_mime.c | 7 +++++-- + 4 files changed, 31 insertions(+), 4 deletions(-) + +diff --git a/crypto/pkcs12/p12_add.c b/crypto/pkcs12/p12_add.c +index 6fd4184af5a52..80ce31b3bca66 100644 +--- a/crypto/pkcs12/p12_add.c ++++ b/crypto/pkcs12/p12_add.c +@@ -78,6 +78,12 @@ STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7) + ERR_raise(ERR_LIB_PKCS12, PKCS12_R_CONTENT_TYPE_NOT_DATA); + return NULL; + } ++ ++ if (p7->d.data == NULL) { ++ ERR_raise(ERR_LIB_PKCS12, PKCS12_R_DECODE_ERROR); ++ return NULL; ++ } ++ + return ASN1_item_unpack(p7->d.data, ASN1_ITEM_rptr(PKCS12_SAFEBAGS)); + } + +@@ -150,6 +156,12 @@ STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, + { + if (!PKCS7_type_is_encrypted(p7)) + return NULL; ++ ++ if (p7->d.encrypted == NULL) { ++ ERR_raise(ERR_LIB_PKCS12, PKCS12_R_DECODE_ERROR); ++ return NULL; ++ } ++ + return PKCS12_item_decrypt_d2i_ex(p7->d.encrypted->enc_data->algorithm, + ASN1_ITEM_rptr(PKCS12_SAFEBAGS), + pass, passlen, +@@ -188,6 +200,12 @@ STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12) + ERR_raise(ERR_LIB_PKCS12, PKCS12_R_CONTENT_TYPE_NOT_DATA); + return NULL; + } ++ ++ if (p12->authsafes->d.data == NULL) { ++ ERR_raise(ERR_LIB_PKCS12, PKCS12_R_DECODE_ERROR); ++ return NULL; ++ } ++ + p7s = ASN1_item_unpack(p12->authsafes->d.data, + ASN1_ITEM_rptr(PKCS12_AUTHSAFES)); + if (p7s != NULL) { +diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c +index 67a885a45f89e..68ff54d0e90ee 100644 +--- a/crypto/pkcs12/p12_mutl.c ++++ b/crypto/pkcs12/p12_mutl.c +@@ -98,6 +98,11 @@ static int pkcs12_gen_mac(PKCS12 *p12, const char *pass, int passlen, + return 0; + } + ++ if (p12->authsafes->d.data == NULL) { ++ ERR_raise(ERR_LIB_PKCS12, PKCS12_R_DECODE_ERROR); ++ return 0; ++ } ++ + salt = p12->mac->salt->data; + saltlen = p12->mac->salt->length; + if (p12->mac->iter == NULL) +diff --git a/crypto/pkcs12/p12_npas.c b/crypto/pkcs12/p12_npas.c +index 62230bc6187ff..1e5b5495991a4 100644 +--- a/crypto/pkcs12/p12_npas.c ++++ b/crypto/pkcs12/p12_npas.c +@@ -77,8 +77,9 @@ static int newpass_p12(PKCS12 *p12, const char *oldpass, const char *newpass) + bags = PKCS12_unpack_p7data(p7); + } else if (bagnid == NID_pkcs7_encrypted) { + bags = PKCS12_unpack_p7encdata(p7, oldpass, -1); +- if (!alg_get(p7->d.encrypted->enc_data->algorithm, +- &pbe_nid, &pbe_iter, &pbe_saltlen)) ++ if (p7->d.encrypted == NULL ++ || !alg_get(p7->d.encrypted->enc_data->algorithm, ++ &pbe_nid, &pbe_iter, &pbe_saltlen)) + goto err; + } else { + continue; +diff --git a/crypto/pkcs7/pk7_mime.c b/crypto/pkcs7/pk7_mime.c +index 49a0da5f819c4..8228315eeaa3a 100644 +--- a/crypto/pkcs7/pk7_mime.c ++++ b/crypto/pkcs7/pk7_mime.c +@@ -33,10 +33,13 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) + int ctype_nid = OBJ_obj2nid(p7->type); + const PKCS7_CTX *ctx = ossl_pkcs7_get0_ctx(p7); + +- if (ctype_nid == NID_pkcs7_signed) ++ if (ctype_nid == NID_pkcs7_signed) { ++ if (p7->d.sign == NULL) ++ return 0; + mdalgs = p7->d.sign->md_algs; +- else ++ } else { + mdalgs = NULL; ++ } + + flags ^= SMIME_OLDMIME; + |