summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2023-08-10 19:46:12 +0200
committerSteve Sakoman <steve@sakoman.com>2023-08-16 03:55:13 -1000
commit5e47346311d9f14a0ca4c71d59963f25c0f2898d (patch)
tree5ebaff9421f5e202d4396e6398c208ae6ac5805f
parentd76406934a99352fd715b4152e25294ca0f38016 (diff)
downloadpoky-5e47346311d9f14a0ca4c71d59963f25c0f2898d.tar.gz
openssl: Upgrade 1.1.1t -> 1.1.1v
https://www.openssl.org/news/openssl-1.1.1-notes.html Major changes between OpenSSL 1.1.1u and OpenSSL 1.1.1v [1 Aug 2023] * Fix excessive time spent checking DH q parameter value (CVE-2023-3817) * 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] * Mitigate for very slow `OBJ_obj2txt()` performance with gigantic OBJECT IDENTIFIER sub-identities. (CVE-2023-2650) * Fixed documentation of X509_VERIFY_PARAM_add0_policy() (CVE-2023-0466) * Fixed handling of invalid certificate policies in leaf certificates (CVE-2023-0465) * Limited the number of nodes created in a policy tree ([CVE-2023-0464]) All CVEs for upgrade to 1.1.1u were already patched, so effectively this will apply patches for CVE-2023-3446 and CVE-2023-3817 plus several non-CVE fixes. Because of mips build changes were backported to openssl 1.1.1 branch, backport of a patch from kirkstone is necessary. (From OE-Core rev: be5d49d86553769deaf4754969d2cf6931d6ac34) Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-connectivity/openssl/openssl/0001-Configure-do-not-tweak-mips-cflags.patch37
-rw-r--r--meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch226
-rw-r--r--meta/recipes-connectivity/openssl/openssl/CVE-2023-0465.patch60
-rw-r--r--meta/recipes-connectivity/openssl/openssl/CVE-2023-0466.patch82
-rw-r--r--meta/recipes-connectivity/openssl/openssl/CVE-2023-2650.patch122
-rw-r--r--meta/recipes-connectivity/openssl/openssl_1.1.1v.bb (renamed from meta/recipes-connectivity/openssl/openssl_1.1.1t.bb)7
6 files changed, 39 insertions, 495 deletions
diff --git a/meta/recipes-connectivity/openssl/openssl/0001-Configure-do-not-tweak-mips-cflags.patch b/meta/recipes-connectivity/openssl/openssl/0001-Configure-do-not-tweak-mips-cflags.patch
new file mode 100644
index 0000000000..b3f6a942d5
--- /dev/null
+++ b/meta/recipes-connectivity/openssl/openssl/0001-Configure-do-not-tweak-mips-cflags.patch
@@ -0,0 +1,37 @@
1From 326909baf81a638d51fa8be1d8227518784f5cc4 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex@linutronix.de>
3Date: Tue, 14 Sep 2021 12:18:25 +0200
4Subject: [PATCH] Configure: do not tweak mips cflags
5
6This conflicts with mips machine definitons from yocto,
7e.g.
8| Error: -mips3 conflicts with the other architecture options, which imply -mips64r2
9
10Upstream-Status: Inappropriate [oe-core specific]
11Signed-off-by: Alexander Kanavin <alex@linutronix.de>
12Signed-off-by: Peter Marko <peter.marko@siemens.com>
13---
14 Configure | 10 ----------
15 1 file changed, 10 deletions(-)
16
17Index: openssl-3.0.4/Configure
18===================================================================
19--- openssl-3.0.4.orig/Configure
20+++ openssl-3.0.4/Configure
21@@ -1243,16 +1243,6 @@ if ($target =~ /^mingw/ && `$config{CC} --target-help 2>&1` =~ m/-mno-cygwin/m)
22 push @{$config{shared_ldflag}}, "-mno-cygwin";
23 }
24
25-if ($target =~ /linux.*-mips/ && !$disabled{asm}
26- && !grep { $_ =~ /-m(ips|arch=)/ } (@{$config{CFLAGS}})) {
27- # minimally required architecture flags for assembly modules
28- my $value;
29- $value = '-mips2' if ($target =~ /mips32/);
30- $value = '-mips3' if ($target =~ /mips64/);
31- unshift @{$config{cflags}}, $value;
32- unshift @{$config{cxxflags}}, $value if $config{CXX};
33-}
34-
35 # If threads aren't disabled, check how possible they are
36 unless ($disabled{threads}) {
37 if ($auto_threads) {
diff --git a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch
deleted file mode 100644
index cce5bad9f0..0000000000
--- a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch
+++ /dev/null
@@ -1,226 +0,0 @@
1From 879f7080d7e141f415c79eaa3a8ac4a3dad0348b Mon Sep 17 00:00:00 2001
2From: Pauli <pauli@openssl.org>
3Date: Wed, 8 Mar 2023 15:28:20 +1100
4Subject: [PATCH] x509: excessive resource use verifying policy constraints
5
6A security vulnerability has been identified in all supported versions
7of OpenSSL related to the verification of X.509 certificate chains
8that include policy constraints. Attackers may be able to exploit this
9vulnerability by creating a malicious certificate chain that triggers
10exponential use of computational resources, leading to a denial-of-service
11(DoS) attack on affected systems.
12
13Fixes CVE-2023-0464
14
15Reviewed-by: Tomas Mraz <tomas@openssl.org>
16Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
17(Merged from https://github.com/openssl/openssl/pull/20569)
18
19CVE: CVE-2023-0464
20Upstream-Status: Backport [https://git.openssl.org/gitweb/?p=openssl.git;a=patch;h=879f7080d7e141f415c79eaa3a8ac4a3dad0348b]
21Signed-off-by: Nikhil R <nikhil.r@kpit.com>
22
23---
24 crypto/x509v3/pcy_local.h | 8 +++++++-
25 crypto/x509v3/pcy_node.c | 12 +++++++++---
26 crypto/x509v3/pcy_tree.c | 37 +++++++++++++++++++++++++++----------
27 3 files changed, 43 insertions(+), 14 deletions(-)
28
29diff --git a/crypto/x509v3/pcy_local.h b/crypto/x509v3/pcy_local.h
30index 5daf78de45..344aa06765 100644
31--- a/crypto/x509v3/pcy_local.h
32+++ b/crypto/x509v3/pcy_local.h
33@@ -111,6 +111,11 @@ struct X509_POLICY_LEVEL_st {
34 };
35
36 struct X509_POLICY_TREE_st {
37+ /* The number of nodes in the tree */
38+ size_t node_count;
39+ /* The maximum number of nodes in the tree */
40+ size_t node_maximum;
41+
42 /* This is the tree 'level' data */
43 X509_POLICY_LEVEL *levels;
44 int nlevel;
45@@ -159,7 +164,8 @@ X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk,
46 X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
47 X509_POLICY_DATA *data,
48 X509_POLICY_NODE *parent,
49- X509_POLICY_TREE *tree);
50+ X509_POLICY_TREE *tree,
51+ int extra_data);
52 void policy_node_free(X509_POLICY_NODE *node);
53 int policy_node_match(const X509_POLICY_LEVEL *lvl,
54 const X509_POLICY_NODE *node, const ASN1_OBJECT *oid);
55diff --git a/crypto/x509v3/pcy_node.c b/crypto/x509v3/pcy_node.c
56index e2d7b15322..d574fb9d66 100644
57--- a/crypto/x509v3/pcy_node.c
58+++ b/crypto/x509v3/pcy_node.c
59@@ -59,10 +59,15 @@ X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level,
60 X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
61 X509_POLICY_DATA *data,
62 X509_POLICY_NODE *parent,
63- X509_POLICY_TREE *tree)
64+ X509_POLICY_TREE *tree,
65+ int extra_data)
66 {
67 X509_POLICY_NODE *node;
68
69+ /* Verify that the tree isn't too large. This mitigates CVE-2023-0464 */
70+ if (tree->node_maximum > 0 && tree->node_count >= tree->node_maximum)
71+ return NULL;
72+
73 node = OPENSSL_zalloc(sizeof(*node));
74 if (node == NULL) {
75 X509V3err(X509V3_F_LEVEL_ADD_NODE, ERR_R_MALLOC_FAILURE);
76@@ -70,7 +75,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
77 }
78 node->data = data;
79 node->parent = parent;
80- if (level) {
81+ if (level != NULL) {
82 if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) {
83 if (level->anyPolicy)
84 goto node_error;
85@@ -90,7 +95,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
86 }
87 }
88
89- if (tree) {
90+ if (extra_data) {
91 if (tree->extra_data == NULL)
92 tree->extra_data = sk_X509_POLICY_DATA_new_null();
93 if (tree->extra_data == NULL){
94@@ -103,6 +108,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
95 }
96 }
97
98+ tree->node_count++;
99 if (parent)
100 parent->nchild++;
101
102diff --git a/crypto/x509v3/pcy_tree.c b/crypto/x509v3/pcy_tree.c
103index 6e8322cbc5..6c7fd35405 100644
104--- a/crypto/x509v3/pcy_tree.c
105+++ b/crypto/x509v3/pcy_tree.c
106@@ -13,6 +13,18 @@
107
108 #include "pcy_local.h"
109
110+/*
111+ * If the maximum number of nodes in the policy tree isn't defined, set it to
112+ * a generous default of 1000 nodes.
113+ *
114+ * Defining this to be zero means unlimited policy tree growth which opens the
115+ * door on CVE-2023-0464.
116+ */
117+
118+#ifndef OPENSSL_POLICY_TREE_NODES_MAX
119+# define OPENSSL_POLICY_TREE_NODES_MAX 1000
120+#endif
121+
122 /*
123 * Enable this to print out the complete policy tree at various point during
124 * evaluation.
125@@ -168,6 +180,9 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
126 return X509_PCY_TREE_INTERNAL;
127 }
128
129+ /* Limit the growth of the tree to mitigate CVE-2023-0464 */
130+ tree->node_maximum = OPENSSL_POLICY_TREE_NODES_MAX;
131+
132 /*
133 * http://tools.ietf.org/html/rfc5280#section-6.1.2, figure 3.
134 *
135@@ -184,7 +199,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
136 level = tree->levels;
137 if ((data = policy_data_new(NULL, OBJ_nid2obj(NID_any_policy), 0)) == NULL)
138 goto bad_tree;
139- if (level_add_node(level, data, NULL, tree) == NULL) {
140+ if (level_add_node(level, data, NULL, tree, 1) == NULL) {
141 policy_data_free(data);
142 goto bad_tree;
143 }
144@@ -243,7 +258,8 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
145 * Return value: 1 on success, 0 otherwise
146 */
147 static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
148- X509_POLICY_DATA *data)
149+ X509_POLICY_DATA *data,
150+ X509_POLICY_TREE *tree)
151 {
152 X509_POLICY_LEVEL *last = curr - 1;
153 int i, matched = 0;
154@@ -253,13 +269,13 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
155 X509_POLICY_NODE *node = sk_X509_POLICY_NODE_value(last->nodes, i);
156
157 if (policy_node_match(last, node, data->valid_policy)) {
158- if (level_add_node(curr, data, node, NULL) == NULL)
159+ if (level_add_node(curr, data, node, tree, 0) == NULL)
160 return 0;
161 matched = 1;
162 }
163 }
164 if (!matched && last->anyPolicy) {
165- if (level_add_node(curr, data, last->anyPolicy, NULL) == NULL)
166+ if (level_add_node(curr, data, last->anyPolicy, tree, 0) == NULL)
167 return 0;
168 }
169 return 1;
170@@ -272,7 +288,8 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
171 * Return value: 1 on success, 0 otherwise.
172 */
173 static int tree_link_nodes(X509_POLICY_LEVEL *curr,
174- const X509_POLICY_CACHE *cache)
175+ const X509_POLICY_CACHE *cache,
176+ X509_POLICY_TREE *tree)
177 {
178 int i;
179
180@@ -280,7 +297,7 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr,
181 X509_POLICY_DATA *data = sk_X509_POLICY_DATA_value(cache->data, i);
182
183 /* Look for matching nodes in previous level */
184- if (!tree_link_matching_nodes(curr, data))
185+ if (!tree_link_matching_nodes(curr, data, tree))
186 return 0;
187 }
188 return 1;
189@@ -311,7 +328,7 @@ static int tree_add_unmatched(X509_POLICY_LEVEL *curr,
190 /* Curr may not have anyPolicy */
191 data->qualifier_set = cache->anyPolicy->qualifier_set;
192 data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
193- if (level_add_node(curr, data, node, tree) == NULL) {
194+ if (level_add_node(curr, data, node, tree, 1) == NULL) {
195 policy_data_free(data);
196 return 0;
197 }
198@@ -373,7 +390,7 @@ static int tree_link_any(X509_POLICY_LEVEL *curr,
199 }
200 /* Finally add link to anyPolicy */
201 if (last->anyPolicy &&
202- level_add_node(curr, cache->anyPolicy, last->anyPolicy, NULL) == NULL)
203+ level_add_node(curr, cache->anyPolicy, last->anyPolicy, tree, 0) == NULL)
204 return 0;
205 return 1;
206 }
207@@ -555,7 +572,7 @@ static int tree_calculate_user_set(X509_POLICY_TREE *tree,
208 extra->qualifier_set = anyPolicy->data->qualifier_set;
209 extra->flags = POLICY_DATA_FLAG_SHARED_QUALIFIERS
210 | POLICY_DATA_FLAG_EXTRA_NODE;
211- node = level_add_node(NULL, extra, anyPolicy->parent, tree);
212+ node = level_add_node(NULL, extra, anyPolicy->parent, tree, 1);
213 }
214 if (!tree->user_policies) {
215 tree->user_policies = sk_X509_POLICY_NODE_new_null();
216@@ -582,7 +599,7 @@ static int tree_evaluate(X509_POLICY_TREE *tree)
217
218 for (i = 1; i < tree->nlevel; i++, curr++) {
219 cache = policy_cache_set(curr->cert);
220- if (!tree_link_nodes(curr, cache))
221+ if (!tree_link_nodes(curr, cache, tree))
222 return X509_PCY_TREE_INTERNAL;
223
224 if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY)
225--
2262.34.1
diff --git a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0465.patch b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0465.patch
deleted file mode 100644
index be5068074e..0000000000
--- a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0465.patch
+++ /dev/null
@@ -1,60 +0,0 @@
1From b013765abfa80036dc779dd0e50602c57bb3bf95 Mon Sep 17 00:00:00 2001
2From: Matt Caswell <matt@openssl.org>
3Date: Tue, 7 Mar 2023 16:52:55 +0000
4Subject: [PATCH] Ensure that EXFLAG_INVALID_POLICY is checked even in leaf
5 certs
6
7Even though we check the leaf cert to confirm it is valid, we
8later ignored the invalid flag and did not notice that the leaf
9cert was bad.
10
11Fixes: CVE-2023-0465
12
13Reviewed-by: Hugo Landau <hlandau@openssl.org>
14Reviewed-by: Tomas Mraz <tomas@openssl.org>
15(Merged from https://github.com/openssl/openssl/pull/20588)
16
17CVE: CVE-2023-0465
18Upstream-Status: Backport [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=b013765abfa80036dc779dd0e50602c57bb3bf95]
19Comment: Refreshed first hunk
20Signed-off-by: Omkar Patil <omkar.patil@kpit.com>
21
22---
23 crypto/x509/x509_vfy.c | 11 +++++++++--
24 1 file changed, 9 insertions(+), 2 deletions(-)
25
26diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
27index 925fbb5412..1dfe4f9f31 100644
28--- a/crypto/x509/x509_vfy.c
29+++ b/crypto/x509/x509_vfy.c
30@@ -1649,18 +1649,25 @@
31 }
32 /* Invalid or inconsistent extensions */
33 if (ret == X509_PCY_TREE_INVALID) {
34- int i;
35+ int i, cbcalled = 0;
36
37 /* Locate certificates with bad extensions and notify callback. */
38- for (i = 1; i < sk_X509_num(ctx->chain); i++) {
39+ for (i = 0; i < sk_X509_num(ctx->chain); i++) {
40 X509 *x = sk_X509_value(ctx->chain, i);
41
42 if (!(x->ex_flags & EXFLAG_INVALID_POLICY))
43 continue;
44+ cbcalled = 1;
45 if (!verify_cb_cert(ctx, x, i,
46 X509_V_ERR_INVALID_POLICY_EXTENSION))
47 return 0;
48 }
49+ if (!cbcalled) {
50+ /* Should not be able to get here */
51+ X509err(X509_F_CHECK_POLICY, ERR_R_INTERNAL_ERROR);
52+ return 0;
53+ }
54+ /* The callback ignored the error so we return success */
55 return 1;
56 }
57 if (ret == X509_PCY_TREE_FAILURE) {
58--
592.34.1
60
diff --git a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0466.patch b/meta/recipes-connectivity/openssl/openssl/CVE-2023-0466.patch
deleted file mode 100644
index f042aa5da1..0000000000
--- a/meta/recipes-connectivity/openssl/openssl/CVE-2023-0466.patch
+++ /dev/null
@@ -1,82 +0,0 @@
1From 0d16b7e99aafc0b4a6d729eec65a411a7e025f0a Mon Sep 17 00:00:00 2001
2From: Tomas Mraz <tomas@openssl.org>
3Date: Tue, 21 Mar 2023 16:15:47 +0100
4Subject: [PATCH] Fix documentation of X509_VERIFY_PARAM_add0_policy()
5
6The function was incorrectly documented as enabling policy checking.
7
8Fixes: CVE-2023-0466
9
10Reviewed-by: Matt Caswell <matt@openssl.org>
11Reviewed-by: Paul Dale <pauli@openssl.org>
12(Merged from https://github.com/openssl/openssl/pull/20564)
13
14CVE: CVE-2023-0466
15Upstream-Status: Backport [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=0d16b7e99aafc0b4a6d729eec65a411a7e025f0a]
16Comment: Refreshed first hunk from CHANGE and NEWS
17Signed-off-by: Omkar Patil <omkar.patil@kpit.com>
18
19---
20 CHANGES | 5 +++++
21 NEWS | 1 +
22 doc/man3/X509_VERIFY_PARAM_set_flags.pod | 9 +++++++--
23 3 files changed, 13 insertions(+), 2 deletions(-)
24
25diff --git a/CHANGES b/CHANGES
26index efccf7838e..b19f1429bb 100644
27--- a/CHANGES
28+++ b/CHANGES
29@@ -9,6 +9,11 @@
30
31 Changes between 1.1.1s and 1.1.1t [7 Feb 2023]
32
33+ *) Corrected documentation of X509_VERIFY_PARAM_add0_policy() to mention
34+ that it does not enable policy checking. Thanks to
35+ David Benjamin for discovering this issue. (CVE-2023-0466)
36+ [Tomas Mraz]
37+
38 *) Fixed X.400 address type confusion in X.509 GeneralName.
39
40 There is a type confusion vulnerability relating to X.400 address processing
41diff --git a/NEWS b/NEWS
42index 36a9bb6890..62615693fa 100644
43--- a/NEWS
44+++ b/NEWS
45@@ -7,6 +7,7 @@
46
47 Major changes between OpenSSL 1.1.1s and OpenSSL 1.1.1t [7 Feb 2023]
48
49+ o Fixed documentation of X509_VERIFY_PARAM_add0_policy() (CVE-2023-0466)
50 o Fixed X.400 address type confusion in X.509 GeneralName (CVE-2023-0286)
51 o Fixed Use-after-free following BIO_new_NDEF (CVE-2023-0215)
52 o Fixed Double free after calling PEM_read_bio_ex (CVE-2022-4450)
53diff --git a/doc/man3/X509_VERIFY_PARAM_set_flags.pod b/doc/man3/X509_VERIFY_PARAM_set_flags.pod
54index f6f304bf7b..aa292f9336 100644
55--- a/doc/man3/X509_VERIFY_PARAM_set_flags.pod
56+++ b/doc/man3/X509_VERIFY_PARAM_set_flags.pod
57@@ -92,8 +92,9 @@ B<trust>.
58 X509_VERIFY_PARAM_set_time() sets the verification time in B<param> to
59 B<t>. Normally the current time is used.
60
61-X509_VERIFY_PARAM_add0_policy() enables policy checking (it is disabled
62-by default) and adds B<policy> to the acceptable policy set.
63+X509_VERIFY_PARAM_add0_policy() adds B<policy> to the acceptable policy set.
64+Contrary to preexisting documentation of this function it does not enable
65+policy checking.
66
67 X509_VERIFY_PARAM_set1_policies() enables policy checking (it is disabled
68 by default) and sets the acceptable policy set to B<policies>. Any existing
69@@ -377,6 +378,10 @@ and has no effect.
70
71 The X509_VERIFY_PARAM_get_hostflags() function was added in OpenSSL 1.1.0i.
72
73+The function X509_VERIFY_PARAM_add0_policy() was historically documented as
74+enabling policy checking however the implementation has never done this.
75+The documentation was changed to align with the implementation.
76+
77 =head1 COPYRIGHT
78
79 Copyright 2009-2020 The OpenSSL Project Authors. All Rights Reserved.
80--
812.34.1
82
diff --git a/meta/recipes-connectivity/openssl/openssl/CVE-2023-2650.patch b/meta/recipes-connectivity/openssl/openssl/CVE-2023-2650.patch
deleted file mode 100644
index ef344dda7f..0000000000
--- a/meta/recipes-connectivity/openssl/openssl/CVE-2023-2650.patch
+++ /dev/null
@@ -1,122 +0,0 @@
1From 9e209944b35cf82368071f160a744b6178f9b098 Mon Sep 17 00:00:00 2001
2From: Richard Levitte <levitte@openssl.org>
3Date: Fri, 12 May 2023 10:00:13 +0200
4Subject: [PATCH] Restrict the size of OBJECT IDENTIFIERs that OBJ_obj2txt will
5 translate
6
7OBJ_obj2txt() would translate any size OBJECT IDENTIFIER to canonical
8numeric text form. For gigantic sub-identifiers, this would take a very
9long time, the time complexity being O(n^2) where n is the size of that
10sub-identifier.
11
12To mitigate this, a restriction on the size that OBJ_obj2txt() will
13translate to canonical numeric text form is added, based on RFC 2578
14(STD 58), which says this:
15
16> 3.5. OBJECT IDENTIFIER values
17>
18> An OBJECT IDENTIFIER value is an ordered list of non-negative numbers.
19> For the SMIv2, each number in the list is referred to as a sub-identifier,
20> there are at most 128 sub-identifiers in a value, and each sub-identifier
21> has a maximum value of 2^32-1 (4294967295 decimal).
22
23Fixes otc/security#96
24Fixes CVE-2023-2650
25
26Reviewed-by: Matt Caswell <matt@openssl.org>
27Reviewed-by: Tomas Mraz <tomas@openssl.org>
28
29Upstream-Status: Backport [https://github.com/openssl/openssl/commit/9e209944b35cf82368071f160a744b6178f9b098]
30CVE: CVE-2023-2650
31Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
32---
33 CHANGES | 28 +++++++++++++++++++++++++++-
34 NEWS | 2 ++
35 crypto/objects/obj_dat.c | 19 +++++++++++++++++++
36 3 files changed, 48 insertions(+), 1 deletion(-)
37
38diff --git a/CHANGES b/CHANGES
39index 1eaaf4e..f2cf38f 100644
40--- a/CHANGES
41+++ b/CHANGES
42@@ -7,7 +7,33 @@
43 https://github.com/openssl/openssl/commits/ and pick the appropriate
44 release branch.
45
46- Changes between 1.1.1s and 1.1.1t [7 Feb 2023]
47+ Changes between 1.1.1t and 1.1.1u [xx XXX xxxx]
48+
49+ *) Mitigate for the time it takes for `OBJ_obj2txt` to translate gigantic
50+ OBJECT IDENTIFIER sub-identifiers to canonical numeric text form.
51+
52+ OBJ_obj2txt() would translate any size OBJECT IDENTIFIER to canonical
53+ numeric text form. For gigantic sub-identifiers, this would take a very
54+ long time, the time complexity being O(n^2) where n is the size of that
55+ sub-identifier. (CVE-2023-2650)
56+
57+ To mitigitate this, `OBJ_obj2txt()` will only translate an OBJECT
58+ IDENTIFIER to canonical numeric text form if the size of that OBJECT
59+ IDENTIFIER is 586 bytes or less, and fail otherwise.
60+
61+ The basis for this restriction is RFC 2578 (STD 58), section 3.5. OBJECT
62+ IDENTIFIER values, which stipulates that OBJECT IDENTIFIERS may have at
63+ most 128 sub-identifiers, and that the maximum value that each sub-
64+ identifier may have is 2^32-1 (4294967295 decimal).
65+
66+ For each byte of every sub-identifier, only the 7 lower bits are part of
67+ the value, so the maximum amount of bytes that an OBJECT IDENTIFIER with
68+ these restrictions may occupy is 32 * 128 / 7, which is approximately 586
69+ bytes.
70+
71+ Ref: https://datatracker.ietf.org/doc/html/rfc2578#section-3.5
72+
73+Changes between 1.1.1s and 1.1.1t [7 Feb 2023]
74
75 *) Corrected documentation of X509_VERIFY_PARAM_add0_policy() to mention
76 that it does not enable policy checking. Thanks to
77diff --git a/NEWS b/NEWS
78index a86220a..41922c4 100644
79--- a/NEWS
80+++ b/NEWS
81@@ -7,6 +7,8 @@
82
83 Major changes between OpenSSL 1.1.1s and OpenSSL 1.1.1t [7 Feb 2023]
84
85+ o Mitigate for very slow `OBJ_obj2txt()` performance with gigantic
86+ OBJECT IDENTIFIER sub-identities. (CVE-2023-2650)
87 o Fixed documentation of X509_VERIFY_PARAM_add0_policy() (CVE-2023-0466)
88 o Fixed X.400 address type confusion in X.509 GeneralName (CVE-2023-0286)
89 o Fixed Use-after-free following BIO_new_NDEF (CVE-2023-0215)
90diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
91index 7e8de72..d699915 100644
92--- a/crypto/objects/obj_dat.c
93+++ b/crypto/objects/obj_dat.c
94@@ -428,6 +428,25 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
95 first = 1;
96 bl = NULL;
97
98+ /*
99+ * RFC 2578 (STD 58) says this about OBJECT IDENTIFIERs:
100+ *
101+ * > 3.5. OBJECT IDENTIFIER values
102+ * >
103+ * > An OBJECT IDENTIFIER value is an ordered list of non-negative
104+ * > numbers. For the SMIv2, each number in the list is referred to as a
105+ * > sub-identifier, there are at most 128 sub-identifiers in a value,
106+ * > and each sub-identifier has a maximum value of 2^32-1 (4294967295
107+ * > decimal).
108+ *
109+ * So a legitimate OID according to this RFC is at most (32 * 128 / 7),
110+ * i.e. 586 bytes long.
111+ *
112+ * Ref: https://datatracker.ietf.org/doc/html/rfc2578#section-3.5
113+ */
114+ if (len > 586)
115+ goto err;
116+
117 while (len > 0) {
118 l = 0;
119 use_bn = 0;
120--
1212.25.1
122
diff --git a/meta/recipes-connectivity/openssl/openssl_1.1.1t.bb b/meta/recipes-connectivity/openssl/openssl_1.1.1v.bb
index eea8ef64af..d1222dc470 100644
--- a/meta/recipes-connectivity/openssl/openssl_1.1.1t.bb
+++ b/meta/recipes-connectivity/openssl/openssl_1.1.1v.bb
@@ -19,17 +19,14 @@ SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
19 file://reproducible.patch \ 19 file://reproducible.patch \
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://CVE-2023-0464.patch \ 22 file://0001-Configure-do-not-tweak-mips-cflags.patch \
23 file://CVE-2023-0465.patch \
24 file://CVE-2023-0466.patch \
25 file://CVE-2023-2650.patch \
26 " 23 "
27 24
28SRC_URI_append_class-nativesdk = " \ 25SRC_URI_append_class-nativesdk = " \
29 file://environment.d-openssl.sh \ 26 file://environment.d-openssl.sh \
30 " 27 "
31 28
32SRC_URI[sha256sum] = "8dee9b24bdb1dcbf0c3d1e9b02fb8f6bf22165e807f45adeb7c9677536859d3b" 29SRC_URI[sha256sum] = "d6697e2871e77238460402e9362d47d18382b15ef9f246aba6c7bd780d38a6b0"
33 30
34inherit lib_package multilib_header multilib_script ptest 31inherit lib_package multilib_header multilib_script ptest
35MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash" 32MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash"