Skip to content

Commit 2f75300

Browse files
hlandaut8m
authored andcommitted
CVE-2023-0286: Fix GENERAL_NAME_cmp for x400Address (3.0)
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org>
1 parent 7e37185 commit 2f75300

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

CHANGES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ breaking changes, and mappings for the large list of deprecated functions.
4444

4545
*Nicola Tuveri*
4646

47+
* Fixed a type confusion vulnerability relating to X.400 address processing
48+
inside an X.509 GeneralName. X.400 addresses were parsed as an `ASN1_STRING`
49+
but subsequently interpreted by `GENERAL_NAME_cmp` as an `ASN1_TYPE`. This
50+
vulnerability may allow an attacker who can provide a certificate chain and
51+
CRL (neither of which need have a valid signature) to pass arbitrary pointers
52+
to a `memcmp` call, creating a possible read primitive, subject to some
53+
constraints. Refer to the advisory for more information. Thanks to David
54+
Benjamin for discovering this issue. ([CVE-2023-0286])
55+
56+
This issue has been fixed by changing the public header file definition of
57+
`GENERAL_NAME` so that `x400Address` reflects the implementation. It was not
58+
possible for any existing application to successfully use the existing
59+
definition; however, if any application references the `x400Address` field
60+
(e.g. in dead code), note that the type of this field has changed. There is
61+
no ABI change.
62+
63+
*Hugo Landau*
64+
4765
### Changes between 3.0.6 and 3.0.7 [1 Nov 2022]
4866

4967
* Fixed two buffer overflows in punycode decoding functions.
@@ -19431,6 +19449,7 @@ ndif
1943119449

1943219450
<!-- Links -->
1943319451

19452+
[CVE-2023-0286]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-0286
1943419453
[CVE-2022-2274]: https://www.openssl.org/news/vulnerabilities.html#CVE-2022-2274
1943519454
[CVE-2022-2097]: https://www.openssl.org/news/vulnerabilities.html#CVE-2022-2274
1943619455
[CVE-2020-1971]: https://www.openssl.org/news/vulnerabilities.html#CVE-2020-1971

crypto/x509/v3_genn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b)
9898
return -1;
9999
switch (a->type) {
100100
case GEN_X400:
101-
result = ASN1_TYPE_cmp(a->d.x400Address, b->d.x400Address);
101+
result = ASN1_STRING_cmp(a->d.x400Address, b->d.x400Address);
102102
break;
103103

104104
case GEN_EDIPARTY:

include/openssl/x509v3.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ typedef struct GENERAL_NAME_st {
154154
OTHERNAME *otherName; /* otherName */
155155
ASN1_IA5STRING *rfc822Name;
156156
ASN1_IA5STRING *dNSName;
157-
ASN1_TYPE *x400Address;
157+
ASN1_STRING *x400Address;
158158
X509_NAME *directoryName;
159159
EDIPARTYNAME *ediPartyName;
160160
ASN1_IA5STRING *uniformResourceIdentifier;

test/v3nametest.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,14 @@ static struct gennamedata {
644644
0xb7, 0x09, 0x02, 0x02
645645
},
646646
15
647+
}, {
648+
/*
649+
* Regression test for CVE-2023-0286.
650+
*/
651+
{
652+
0xa3, 0x00
653+
},
654+
2
647655
}
648656
};
649657

0 commit comments

Comments
 (0)