diff options
author | Siddharth Doshi <sdoshi@mvista.com> | 2023-03-29 20:23:12 +0530 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-04-11 11:31:52 +0100 |
commit | fd78b2c6ac8a952154c1eebd412d271af6ec6805 (patch) | |
tree | 4d86d94d9bc362cbb6fc07b7ba9d0948290e18c7 /meta/recipes-connectivity | |
parent | 7a9f4f7a29425d37501dae2c977a124bdc74335d (diff) | |
download | poky-fd78b2c6ac8a952154c1eebd412d271af6ec6805.tar.gz |
openssl: Security fix for CVE-2023-0464, CVE-2023-0465, CVE-2023-0466
Upstream-Status:
- CVE-2023-0464: Backport from [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=959c59c7a0164117e7f8366466a32bb1f8d77ff1]
- CVE-2023-0465: Backport from [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=1dd43e0709fece299b15208f36cc7c76209ba0bb]
- CVE-2023-0466: Backport from [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=51e8a84ce742db0f6c70510d0159dad8f7825908]
(From OE-Core rev: 699ed495ee65991bf4ab286070d72109e72b1f81)
Signed-off-by: Siddharth Doshi <sdoshi@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-connectivity')
4 files changed, 334 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch new file mode 100644 index 0000000000..3b94c48e8d --- /dev/null +++ b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch | |||
@@ -0,0 +1,225 @@ | |||
1 | From 959c59c7a0164117e7f8366466a32bb1f8d77ff1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Pauli <pauli@openssl.org> | ||
3 | Date: Wed, 8 Mar 2023 15:28:20 +1100 | ||
4 | Subject: [PATCH] x509: excessive resource use verifying policy constraints | ||
5 | |||
6 | A security vulnerability has been identified in all supported versions | ||
7 | of OpenSSL related to the verification of X.509 certificate chains | ||
8 | that include policy constraints. Attackers may be able to exploit this | ||
9 | vulnerability by creating a malicious certificate chain that triggers | ||
10 | exponential use of computational resources, leading to a denial-of-service | ||
11 | (DoS) attack on affected systems. | ||
12 | |||
13 | Fixes CVE-2023-0464 | ||
14 | |||
15 | Reviewed-by: Tomas Mraz <tomas@openssl.org> | ||
16 | Reviewed-by: Shane Lontis <shane.lontis@oracle.com> | ||
17 | (Merged from https://github.com/openssl/openssl/pull/20568) | ||
18 | |||
19 | Upstream-Status: Backport from [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=959c59c7a0164117e7f8366466a32bb1f8d77ff1] | ||
20 | CVE: CVE-2023-0464 | ||
21 | Signed-off-by: Siddharth Doshi <sdoshi@mvista.com> | ||
22 | --- | ||
23 | crypto/x509/pcy_local.h | 8 +++++++- | ||
24 | crypto/x509/pcy_node.c | 12 +++++++++--- | ||
25 | crypto/x509/pcy_tree.c | 36 ++++++++++++++++++++++++++---------- | ||
26 | 3 files changed, 42 insertions(+), 14 deletions(-) | ||
27 | |||
28 | diff --git a/crypto/x509/pcy_local.h b/crypto/x509/pcy_local.h | ||
29 | index 18b53cc..cba107c 100644 | ||
30 | --- a/crypto/x509/pcy_local.h | ||
31 | +++ b/crypto/x509/pcy_local.h | ||
32 | @@ -111,6 +111,11 @@ struct X509_POLICY_LEVEL_st { | ||
33 | }; | ||
34 | |||
35 | struct X509_POLICY_TREE_st { | ||
36 | + /* The number of nodes in the tree */ | ||
37 | + size_t node_count; | ||
38 | + /* The maximum number of nodes in the tree */ | ||
39 | + size_t node_maximum; | ||
40 | + | ||
41 | /* This is the tree 'level' data */ | ||
42 | X509_POLICY_LEVEL *levels; | ||
43 | int nlevel; | ||
44 | @@ -157,7 +162,8 @@ X509_POLICY_NODE *ossl_policy_tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk, | ||
45 | X509_POLICY_NODE *ossl_policy_level_add_node(X509_POLICY_LEVEL *level, | ||
46 | X509_POLICY_DATA *data, | ||
47 | X509_POLICY_NODE *parent, | ||
48 | - X509_POLICY_TREE *tree); | ||
49 | + X509_POLICY_TREE *tree, | ||
50 | + int extra_data); | ||
51 | void ossl_policy_node_free(X509_POLICY_NODE *node); | ||
52 | int ossl_policy_node_match(const X509_POLICY_LEVEL *lvl, | ||
53 | const X509_POLICY_NODE *node, const ASN1_OBJECT *oid); | ||
54 | diff --git a/crypto/x509/pcy_node.c b/crypto/x509/pcy_node.c | ||
55 | index 9d9a7ea..450f95a 100644 | ||
56 | --- a/crypto/x509/pcy_node.c | ||
57 | +++ b/crypto/x509/pcy_node.c | ||
58 | @@ -59,10 +59,15 @@ X509_POLICY_NODE *ossl_policy_level_find_node(const X509_POLICY_LEVEL *level, | ||
59 | X509_POLICY_NODE *ossl_policy_level_add_node(X509_POLICY_LEVEL *level, | ||
60 | X509_POLICY_DATA *data, | ||
61 | X509_POLICY_NODE *parent, | ||
62 | - X509_POLICY_TREE *tree) | ||
63 | + X509_POLICY_TREE *tree, | ||
64 | + int extra_data) | ||
65 | { | ||
66 | X509_POLICY_NODE *node; | ||
67 | |||
68 | + /* Verify that the tree isn't too large. This mitigates CVE-2023-0464 */ | ||
69 | + if (tree->node_maximum > 0 && tree->node_count >= tree->node_maximum) | ||
70 | + return NULL; | ||
71 | + | ||
72 | node = OPENSSL_zalloc(sizeof(*node)); | ||
73 | if (node == NULL) { | ||
74 | ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE); | ||
75 | @@ -70,7 +75,7 @@ X509_POLICY_NODE *ossl_policy_level_add_node(X509_POLICY_LEVEL *level, | ||
76 | } | ||
77 | node->data = data; | ||
78 | node->parent = parent; | ||
79 | - if (level) { | ||
80 | + if (level != NULL) { | ||
81 | if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) { | ||
82 | if (level->anyPolicy) | ||
83 | goto node_error; | ||
84 | @@ -90,7 +95,7 @@ X509_POLICY_NODE *ossl_policy_level_add_node(X509_POLICY_LEVEL *level, | ||
85 | } | ||
86 | } | ||
87 | |||
88 | - if (tree) { | ||
89 | + if (extra_data) { | ||
90 | if (tree->extra_data == NULL) | ||
91 | tree->extra_data = sk_X509_POLICY_DATA_new_null(); | ||
92 | if (tree->extra_data == NULL){ | ||
93 | @@ -103,6 +108,7 @@ X509_POLICY_NODE *ossl_policy_level_add_node(X509_POLICY_LEVEL *level, | ||
94 | } | ||
95 | } | ||
96 | |||
97 | + tree->node_count++; | ||
98 | if (parent) | ||
99 | parent->nchild++; | ||
100 | |||
101 | diff --git a/crypto/x509/pcy_tree.c b/crypto/x509/pcy_tree.c | ||
102 | index fa45da5..f953a05 100644 | ||
103 | --- a/crypto/x509/pcy_tree.c | ||
104 | +++ b/crypto/x509/pcy_tree.c | ||
105 | @@ -14,6 +14,17 @@ | ||
106 | |||
107 | #include "pcy_local.h" | ||
108 | |||
109 | +/* | ||
110 | + * If the maximum number of nodes in the policy tree isn't defined, set it to | ||
111 | + * a generous default of 1000 nodes. | ||
112 | + * | ||
113 | + * Defining this to be zero means unlimited policy tree growth which opens the | ||
114 | + * door on CVE-2023-0464. | ||
115 | + */ | ||
116 | +#ifndef OPENSSL_POLICY_TREE_NODES_MAX | ||
117 | +# define OPENSSL_POLICY_TREE_NODES_MAX 1000 | ||
118 | +#endif | ||
119 | + | ||
120 | static void expected_print(BIO *channel, | ||
121 | X509_POLICY_LEVEL *lev, X509_POLICY_NODE *node, | ||
122 | int indent) | ||
123 | @@ -163,6 +174,9 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, | ||
124 | return X509_PCY_TREE_INTERNAL; | ||
125 | } | ||
126 | |||
127 | + /* Limit the growth of the tree to mitigate CVE-2023-0464 */ | ||
128 | + tree->node_maximum = OPENSSL_POLICY_TREE_NODES_MAX; | ||
129 | + | ||
130 | /* | ||
131 | * http://tools.ietf.org/html/rfc5280#section-6.1.2, figure 3. | ||
132 | * | ||
133 | @@ -180,7 +194,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, | ||
134 | if ((data = ossl_policy_data_new(NULL, | ||
135 | OBJ_nid2obj(NID_any_policy), 0)) == NULL) | ||
136 | goto bad_tree; | ||
137 | - if (ossl_policy_level_add_node(level, data, NULL, tree) == NULL) { | ||
138 | + if (ossl_policy_level_add_node(level, data, NULL, tree, 1) == NULL) { | ||
139 | ossl_policy_data_free(data); | ||
140 | goto bad_tree; | ||
141 | } | ||
142 | @@ -239,7 +253,8 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, | ||
143 | * Return value: 1 on success, 0 otherwise | ||
144 | */ | ||
145 | static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr, | ||
146 | - X509_POLICY_DATA *data) | ||
147 | + X509_POLICY_DATA *data, | ||
148 | + X509_POLICY_TREE *tree) | ||
149 | { | ||
150 | X509_POLICY_LEVEL *last = curr - 1; | ||
151 | int i, matched = 0; | ||
152 | @@ -249,13 +264,13 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr, | ||
153 | X509_POLICY_NODE *node = sk_X509_POLICY_NODE_value(last->nodes, i); | ||
154 | |||
155 | if (ossl_policy_node_match(last, node, data->valid_policy)) { | ||
156 | - if (ossl_policy_level_add_node(curr, data, node, NULL) == NULL) | ||
157 | + if (ossl_policy_level_add_node(curr, data, node, tree, 0) == NULL) | ||
158 | return 0; | ||
159 | matched = 1; | ||
160 | } | ||
161 | } | ||
162 | if (!matched && last->anyPolicy) { | ||
163 | - if (ossl_policy_level_add_node(curr, data, last->anyPolicy, NULL) == NULL) | ||
164 | + if (ossl_policy_level_add_node(curr, data, last->anyPolicy, tree, 0) == NULL) | ||
165 | return 0; | ||
166 | } | ||
167 | return 1; | ||
168 | @@ -268,7 +283,8 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr, | ||
169 | * Return value: 1 on success, 0 otherwise. | ||
170 | */ | ||
171 | static int tree_link_nodes(X509_POLICY_LEVEL *curr, | ||
172 | - const X509_POLICY_CACHE *cache) | ||
173 | + const X509_POLICY_CACHE *cache, | ||
174 | + X509_POLICY_TREE *tree) | ||
175 | { | ||
176 | int i; | ||
177 | |||
178 | @@ -276,7 +292,7 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr, | ||
179 | X509_POLICY_DATA *data = sk_X509_POLICY_DATA_value(cache->data, i); | ||
180 | |||
181 | /* Look for matching nodes in previous level */ | ||
182 | - if (!tree_link_matching_nodes(curr, data)) | ||
183 | + if (!tree_link_matching_nodes(curr, data, tree)) | ||
184 | return 0; | ||
185 | } | ||
186 | return 1; | ||
187 | @@ -307,7 +323,7 @@ static int tree_add_unmatched(X509_POLICY_LEVEL *curr, | ||
188 | /* Curr may not have anyPolicy */ | ||
189 | data->qualifier_set = cache->anyPolicy->qualifier_set; | ||
190 | data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS; | ||
191 | - if (ossl_policy_level_add_node(curr, data, node, tree) == NULL) { | ||
192 | + if (ossl_policy_level_add_node(curr, data, node, tree, 1) == NULL) { | ||
193 | ossl_policy_data_free(data); | ||
194 | return 0; | ||
195 | } | ||
196 | @@ -370,7 +386,7 @@ static int tree_link_any(X509_POLICY_LEVEL *curr, | ||
197 | /* Finally add link to anyPolicy */ | ||
198 | if (last->anyPolicy && | ||
199 | ossl_policy_level_add_node(curr, cache->anyPolicy, | ||
200 | - last->anyPolicy, NULL) == NULL) | ||
201 | + last->anyPolicy, tree, 0) == NULL) | ||
202 | return 0; | ||
203 | return 1; | ||
204 | } | ||
205 | @@ -553,7 +569,7 @@ static int tree_calculate_user_set(X509_POLICY_TREE *tree, | ||
206 | extra->flags = POLICY_DATA_FLAG_SHARED_QUALIFIERS | ||
207 | | POLICY_DATA_FLAG_EXTRA_NODE; | ||
208 | node = ossl_policy_level_add_node(NULL, extra, anyPolicy->parent, | ||
209 | - tree); | ||
210 | + tree, 1); | ||
211 | } | ||
212 | if (!tree->user_policies) { | ||
213 | tree->user_policies = sk_X509_POLICY_NODE_new_null(); | ||
214 | @@ -580,7 +596,7 @@ static int tree_evaluate(X509_POLICY_TREE *tree) | ||
215 | |||
216 | for (i = 1; i < tree->nlevel; i++, curr++) { | ||
217 | cache = ossl_policy_cache_set(curr->cert); | ||
218 | - if (!tree_link_nodes(curr, cache)) | ||
219 | + if (!tree_link_nodes(curr, cache, tree)) | ||
220 | return X509_PCY_TREE_INTERNAL; | ||
221 | |||
222 | if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY) | ||
223 | -- | ||
224 | 2.35.7 | ||
225 | |||
diff --git a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0465.patch b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0465.patch new file mode 100644 index 0000000000..57fd494464 --- /dev/null +++ b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0465.patch | |||
@@ -0,0 +1,56 @@ | |||
1 | From 1dd43e0709fece299b15208f36cc7c76209ba0bb Mon Sep 17 00:00:00 2001 | ||
2 | From: Matt Caswell <matt@openssl.org> | ||
3 | Date: Tue, 7 Mar 2023 16:52:55 +0000 | ||
4 | Subject: [PATCH] Ensure that EXFLAG_INVALID_POLICY is checked even in leaf | ||
5 | certs | ||
6 | |||
7 | Even though we check the leaf cert to confirm it is valid, we | ||
8 | later ignored the invalid flag and did not notice that the leaf | ||
9 | cert was bad. | ||
10 | |||
11 | Fixes: CVE-2023-0465 | ||
12 | |||
13 | Reviewed-by: Hugo Landau <hlandau@openssl.org> | ||
14 | Reviewed-by: Tomas Mraz <tomas@openssl.org> | ||
15 | (Merged from https://github.com/openssl/openssl/pull/20587) | ||
16 | |||
17 | Upstream-Status: Backport from [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=1dd43e0709fece299b15208f36cc7c76209ba0bb] | ||
18 | CVE: CVE-2023-0465 | ||
19 | Signed-off-by: Siddharth Doshi <sdoshi@mvista.com> | ||
20 | --- | ||
21 | crypto/x509/x509_vfy.c | 12 ++++++++++-- | ||
22 | 1 file changed, 10 insertions(+), 2 deletions(-) | ||
23 | |||
24 | diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c | ||
25 | index 9384f1d..a0282c3 100644 | ||
26 | --- a/crypto/x509/x509_vfy.c | ||
27 | +++ b/crypto/x509/x509_vfy.c | ||
28 | @@ -1654,15 +1654,23 @@ static int check_policy(X509_STORE_CTX *ctx) | ||
29 | goto memerr; | ||
30 | /* Invalid or inconsistent extensions */ | ||
31 | if (ret == X509_PCY_TREE_INVALID) { | ||
32 | - int i; | ||
33 | + int i, cbcalled = 0; | ||
34 | |||
35 | /* Locate certificates with bad extensions and notify callback. */ | ||
36 | - for (i = 1; i < sk_X509_num(ctx->chain); i++) { | ||
37 | + for (i = 0; i < sk_X509_num(ctx->chain); i++) { | ||
38 | X509 *x = sk_X509_value(ctx->chain, i); | ||
39 | |||
40 | + if ((x->ex_flags & EXFLAG_INVALID_POLICY) != 0) | ||
41 | + cbcalled = 1; | ||
42 | CB_FAIL_IF((x->ex_flags & EXFLAG_INVALID_POLICY) != 0, | ||
43 | ctx, x, i, X509_V_ERR_INVALID_POLICY_EXTENSION); | ||
44 | } | ||
45 | + if (!cbcalled) { | ||
46 | + /* Should not be able to get here */ | ||
47 | + ERR_raise(ERR_LIB_X509, ERR_R_INTERNAL_ERROR); | ||
48 | + return 0; | ||
49 | + } | ||
50 | + /* The callback ignored the error so we return success */ | ||
51 | return 1; | ||
52 | } | ||
53 | if (ret == X509_PCY_TREE_FAILURE) { | ||
54 | -- | ||
55 | 2.35.7 | ||
56 | |||
diff --git a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0466.patch b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0466.patch new file mode 100644 index 0000000000..a16bfe42ca --- /dev/null +++ b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0466.patch | |||
@@ -0,0 +1,50 @@ | |||
1 | From 51e8a84ce742db0f6c70510d0159dad8f7825908 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tomas Mraz <tomas@openssl.org> | ||
3 | Date: Tue, 21 Mar 2023 16:15:47 +0100 | ||
4 | Subject: [PATCH] Fix documentation of X509_VERIFY_PARAM_add0_policy() | ||
5 | |||
6 | The function was incorrectly documented as enabling policy checking. | ||
7 | |||
8 | Fixes: CVE-2023-0466 | ||
9 | |||
10 | Reviewed-by: Matt Caswell <matt@openssl.org> | ||
11 | Reviewed-by: Paul Dale <pauli@openssl.org> | ||
12 | (Merged from https://github.com/openssl/openssl/pull/20563) | ||
13 | |||
14 | Upstream-Status: Backport from [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=51e8a84ce742db0f6c70510d0159dad8f7825908] | ||
15 | CVE: CVE-2023-0466 | ||
16 | Signed-off-by: Siddharth Doshi <sdoshi@mvista.com> | ||
17 | --- | ||
18 | doc/man3/X509_VERIFY_PARAM_set_flags.pod | 9 +++++++-- | ||
19 | 1 file changed, 7 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/doc/man3/X509_VERIFY_PARAM_set_flags.pod b/doc/man3/X509_VERIFY_PARAM_set_flags.pod | ||
22 | index 75a1677..43c1900 100644 | ||
23 | --- a/doc/man3/X509_VERIFY_PARAM_set_flags.pod | ||
24 | +++ b/doc/man3/X509_VERIFY_PARAM_set_flags.pod | ||
25 | @@ -98,8 +98,9 @@ B<trust>. | ||
26 | X509_VERIFY_PARAM_set_time() sets the verification time in B<param> to | ||
27 | B<t>. Normally the current time is used. | ||
28 | |||
29 | -X509_VERIFY_PARAM_add0_policy() enables policy checking (it is disabled | ||
30 | -by default) and adds B<policy> to the acceptable policy set. | ||
31 | +X509_VERIFY_PARAM_add0_policy() adds B<policy> to the acceptable policy set. | ||
32 | +Contrary to preexisting documentation of this function it does not enable | ||
33 | +policy checking. | ||
34 | |||
35 | X509_VERIFY_PARAM_set1_policies() enables policy checking (it is disabled | ||
36 | by default) and sets the acceptable policy set to B<policies>. Any existing | ||
37 | @@ -400,6 +401,10 @@ The X509_VERIFY_PARAM_get_hostflags() function was added in OpenSSL 1.1.0i. | ||
38 | The X509_VERIFY_PARAM_get0_host(), X509_VERIFY_PARAM_get0_email(), | ||
39 | and X509_VERIFY_PARAM_get1_ip_asc() functions were added in OpenSSL 3.0. | ||
40 | |||
41 | +The function X509_VERIFY_PARAM_add0_policy() was historically documented as | ||
42 | +enabling policy checking however the implementation has never done this. | ||
43 | +The documentation was changed to align with the implementation. | ||
44 | + | ||
45 | =head1 COPYRIGHT | ||
46 | |||
47 | Copyright 2009-2023 The OpenSSL Project Authors. All Rights Reserved. | ||
48 | -- | ||
49 | 2.35.7 | ||
50 | |||
diff --git a/meta/recipes-connectivity/openssl/openssl_3.0.8.bb b/meta/recipes-connectivity/openssl/openssl_3.0.8.bb index 75f9e44748..e1f30d7a47 100644 --- a/meta/recipes-connectivity/openssl/openssl_3.0.8.bb +++ b/meta/recipes-connectivity/openssl/openssl_3.0.8.bb | |||
@@ -12,6 +12,9 @@ SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \ | |||
12 | file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \ | 12 | file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \ |
13 | file://afalg.patch \ | 13 | file://afalg.patch \ |
14 | file://0001-Configure-do-not-tweak-mips-cflags.patch \ | 14 | file://0001-Configure-do-not-tweak-mips-cflags.patch \ |
15 | file://CVE-2023-0464.patch \ | ||
16 | file://CVE-2023-0465.patch \ | ||
17 | file://CVE-2023-0466.patch \ | ||
15 | " | 18 | " |
16 | 19 | ||
17 | SRC_URI:append:class-nativesdk = " \ | 20 | SRC_URI:append:class-nativesdk = " \ |