From 17612bc3d782a97e95d66d08696fd71d0758c93e Mon Sep 17 00:00:00 2001 From: tb <> Date: Tue, 7 Feb 2023 15:46:58 +0000 Subject: Fix arbitrary memory read in GENERAL_NAME_cmp() The ASN.1 template for GENERAL_NAME and its corresponding C structure disagree on the type of the x400Address member. This results in an ASN.1 string to be considered as an ASN.1 type, which allows an attacker to read (essentially) arbitrary memory. Fix this by forcing comparison as strings. While the underlying type confusion has been present since time immemorial, this particular bug came with the EdiPartyName fix (6.8/008_asn1.patch.sig). Reported by David Benjamin, fix suggested by jsing. Release date for this was set to be January 31. Unilaterally pushed back to February 7 by OpenSSL by way of announcement of many completely unrelated embargoed issues, some of which they had been sitting on since July 2020. ok beck jsing --- src/lib/libcrypto/x509/x509_genn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/x509/x509_genn.c b/src/lib/libcrypto/x509/x509_genn.c index ce1fb6cc02..395d487f8f 100644 --- a/src/lib/libcrypto/x509/x509_genn.c +++ b/src/lib/libcrypto/x509/x509_genn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_genn.c,v 1.3 2022/11/14 17:48:50 beck Exp $ */ +/* $OpenBSD: x509_genn.c,v 1.4 2023/02/07 15:46:58 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -383,7 +383,8 @@ GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) return -1; switch (a->type) { case GEN_X400: - result = ASN1_TYPE_cmp(a->d.x400Address, b->d.x400Address); + result = ASN1_STRING_cmp((ASN1_STRING *)a->d.x400Address, + (ASN1_STRING *)b->d.x400Address); break; case GEN_EDIPARTY: -- cgit v1.2.3-55-g6feb