diff options
| author | virendra thakur <thakur.virendra1810@gmail.com> | 2024-03-22 11:05:24 +0530 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-04-05 06:34:42 -0700 |
| commit | f010cd7f241f37a70aca71a0d9de48321ac0579c (patch) | |
| tree | 637fa5c1d67ce445006c9f8a2a9c153c61bf972d | |
| parent | dbb4e8a5ccaa1d2f7c64f656fcce516da78d545c (diff) | |
| download | poky-f010cd7f241f37a70aca71a0d9de48321ac0579c.tar.gz | |
openssl: Fix CVE-2024-0727
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.
(From OE-Core rev: 18eb56925878a67ca1d7ce3eb9092f611023bc23)
Signed-off-by: virendra thakur <virendrak@kpit.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-connectivity/openssl/openssl/CVE-2024-0727.patch | 122 | ||||
| -rw-r--r-- | meta/recipes-connectivity/openssl/openssl_1.1.1w.bb | 1 |
2 files changed, 123 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssl/openssl/CVE-2024-0727.patch b/meta/recipes-connectivity/openssl/openssl/CVE-2024-0727.patch new file mode 100644 index 0000000000..3da6879ccb --- /dev/null +++ b/meta/recipes-connectivity/openssl/openssl/CVE-2024-0727.patch | |||
| @@ -0,0 +1,122 @@ | |||
| 1 | Backport of: | ||
| 2 | |||
| 3 | From 09df4395b5071217b76dc7d3d2e630eb8c5a79c2 Mon Sep 17 00:00:00 2001 | ||
| 4 | From: Matt Caswell <matt@openssl.org> | ||
| 5 | Date: Fri, 19 Jan 2024 11:28:58 +0000 | ||
| 6 | Subject: [PATCH] Add NULL checks where ContentInfo data can be NULL | ||
| 7 | |||
| 8 | PKCS12 structures contain PKCS7 ContentInfo fields. These fields are | ||
| 9 | optional and can be NULL even if the "type" is a valid value. OpenSSL | ||
| 10 | was not properly accounting for this and a NULL dereference can occur | ||
| 11 | causing a crash. | ||
| 12 | |||
| 13 | CVE-2024-0727 | ||
| 14 | |||
| 15 | Reviewed-by: Tomas Mraz <tomas@openssl.org> | ||
| 16 | Reviewed-by: Hugo Landau <hlandau@openssl.org> | ||
| 17 | Reviewed-by: Neil Horman <nhorman@openssl.org> | ||
| 18 | (Merged from https://github.com/openssl/openssl/pull/23362) | ||
| 19 | |||
| 20 | (cherry picked from commit d135eeab8a5dbf72b3da5240bab9ddb7678dbd2c) | ||
| 21 | |||
| 22 | Upstream-Status: Backport [https://github.com/openssl/openssl/commit/d135eeab8a5dbf72b3da5240bab9ddb7678dbd2c] | ||
| 23 | |||
| 24 | CVE: CVE-2024-0727 | ||
| 25 | |||
| 26 | Signed-off-by: virendra thakur <virendrak@kpit.com> | ||
| 27 | --- | ||
| 28 | crypto/pkcs12/p12_add.c | 18 ++++++++++++++++++ | ||
| 29 | crypto/pkcs12/p12_mutl.c | 5 +++++ | ||
| 30 | crypto/pkcs12/p12_npas.c | 5 +++-- | ||
| 31 | crypto/pkcs7/pk7_mime.c | 7 +++++-- | ||
| 32 | 4 files changed, 31 insertions(+), 4 deletions(-) | ||
| 33 | |||
| 34 | --- a/crypto/pkcs12/p12_add.c | ||
| 35 | +++ b/crypto/pkcs12/p12_add.c | ||
| 36 | @@ -76,6 +76,13 @@ STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_ | ||
| 37 | PKCS12_R_CONTENT_TYPE_NOT_DATA); | ||
| 38 | return NULL; | ||
| 39 | } | ||
| 40 | + | ||
| 41 | + if (p7->d.data == NULL) { | ||
| 42 | + PKCS12err(PKCS12_F_PKCS12_UNPACK_P7DATA, | ||
| 43 | + PKCS12_R_DECODE_ERROR); | ||
| 44 | + return NULL; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | return ASN1_item_unpack(p7->d.data, ASN1_ITEM_rptr(PKCS12_SAFEBAGS)); | ||
| 48 | } | ||
| 49 | |||
| 50 | @@ -132,6 +139,12 @@ STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_ | ||
| 51 | { | ||
| 52 | if (!PKCS7_type_is_encrypted(p7)) | ||
| 53 | return NULL; | ||
| 54 | + | ||
| 55 | + if (p7->d.encrypted == NULL) { | ||
| 56 | + PKCS12err(PKCS12_F_PKCS12_UNPACK_P7DATA, PKCS12_R_DECODE_ERROR); | ||
| 57 | + return NULL; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | return PKCS12_item_decrypt_d2i(p7->d.encrypted->enc_data->algorithm, | ||
| 61 | ASN1_ITEM_rptr(PKCS12_SAFEBAGS), | ||
| 62 | pass, passlen, | ||
| 63 | @@ -159,6 +172,13 @@ STACK_OF(PKCS7) *PKCS12_unpack_authsafes | ||
| 64 | PKCS12_R_CONTENT_TYPE_NOT_DATA); | ||
| 65 | return NULL; | ||
| 66 | } | ||
| 67 | + | ||
| 68 | + if (p12->authsafes->d.data == NULL) { | ||
| 69 | + PKCS12err(PKCS12_F_PKCS12_UNPACK_AUTHSAFES, | ||
| 70 | + PKCS12_R_DECODE_ERROR); | ||
| 71 | + return NULL; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | return ASN1_item_unpack(p12->authsafes->d.data, | ||
| 75 | ASN1_ITEM_rptr(PKCS12_AUTHSAFES)); | ||
| 76 | } | ||
| 77 | --- a/crypto/pkcs12/p12_mutl.c | ||
| 78 | +++ b/crypto/pkcs12/p12_mutl.c | ||
| 79 | @@ -93,6 +93,11 @@ static int pkcs12_gen_mac(PKCS12 *p12, c | ||
| 80 | return 0; | ||
| 81 | } | ||
| 82 | |||
| 83 | + if (p12->authsafes->d.data == NULL) { | ||
| 84 | + PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_DECODE_ERROR); | ||
| 85 | + return 0; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | salt = p12->mac->salt->data; | ||
| 89 | saltlen = p12->mac->salt->length; | ||
| 90 | if (!p12->mac->iter) | ||
| 91 | --- a/crypto/pkcs12/p12_npas.c | ||
| 92 | +++ b/crypto/pkcs12/p12_npas.c | ||
| 93 | @@ -78,8 +78,9 @@ static int newpass_p12(PKCS12 *p12, cons | ||
| 94 | bags = PKCS12_unpack_p7data(p7); | ||
| 95 | } else if (bagnid == NID_pkcs7_encrypted) { | ||
| 96 | bags = PKCS12_unpack_p7encdata(p7, oldpass, -1); | ||
| 97 | - if (!alg_get(p7->d.encrypted->enc_data->algorithm, | ||
| 98 | - &pbe_nid, &pbe_iter, &pbe_saltlen)) | ||
| 99 | + if (p7->d.encrypted == NULL | ||
| 100 | + || !alg_get(p7->d.encrypted->enc_data->algorithm, | ||
| 101 | + &pbe_nid, &pbe_iter, &pbe_saltlen)) | ||
| 102 | goto err; | ||
| 103 | } else { | ||
| 104 | continue; | ||
| 105 | --- a/crypto/pkcs7/pk7_mime.c | ||
| 106 | +++ b/crypto/pkcs7/pk7_mime.c | ||
| 107 | @@ -30,10 +30,13 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p | ||
| 108 | { | ||
| 109 | STACK_OF(X509_ALGOR) *mdalgs; | ||
| 110 | int ctype_nid = OBJ_obj2nid(p7->type); | ||
| 111 | - if (ctype_nid == NID_pkcs7_signed) | ||
| 112 | + if (ctype_nid == NID_pkcs7_signed) { | ||
| 113 | + if (p7->d.sign == NULL) | ||
| 114 | + return 0; | ||
| 115 | mdalgs = p7->d.sign->md_algs; | ||
| 116 | - else | ||
| 117 | + } else { | ||
| 118 | mdalgs = NULL; | ||
| 119 | + } | ||
| 120 | |||
| 121 | flags ^= SMIME_OLDMIME; | ||
| 122 | |||
diff --git a/meta/recipes-connectivity/openssl/openssl_1.1.1w.bb b/meta/recipes-connectivity/openssl/openssl_1.1.1w.bb index 8a53b06862..0e490eabc3 100644 --- a/meta/recipes-connectivity/openssl/openssl_1.1.1w.bb +++ b/meta/recipes-connectivity/openssl/openssl_1.1.1w.bb | |||
| @@ -20,6 +20,7 @@ SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \ | |||
| 20 | file://reproducibility.patch \ | 20 | file://reproducibility.patch \ |
| 21 | file://0001-Configure-add-2-missing-key-sorts.patch \ | 21 | file://0001-Configure-add-2-missing-key-sorts.patch \ |
| 22 | file://0001-Configure-do-not-tweak-mips-cflags.patch \ | 22 | file://0001-Configure-do-not-tweak-mips-cflags.patch \ |
| 23 | file://CVE-2024-0727.patch \ | ||
| 23 | " | 24 | " |
| 24 | 25 | ||
| 25 | SRC_URI_append_class-nativesdk = " \ | 26 | SRC_URI_append_class-nativesdk = " \ |
