CVE-2023-0286: Fix GENERAL_NAME_cmp for x400Address (1.1.1)
authorHugo Landau <hlandau@openssl.org>
Tue, 17 Jan 2023 17:45:42 +0000 (17:45 +0000)
committerRichard Levitte <levitte@openssl.org>
Fri, 3 Feb 2023 10:22:47 +0000 (11:22 +0100)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
CHANGES
crypto/x509v3/v3_genn.c
include/openssl/x509v3.h
test/v3nametest.c

diff --git a/CHANGES b/CHANGES
index 7d5f10da6ddfa3ac284a1e75e3dad03c139345b6..ff82b6957d9a28b8459b850b52faea85e3508f9c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -9,7 +9,23 @@
 
  Changes between 1.1.1s and 1.1.1t [xx XXX xxxx]
 
-  *)
+  *) Fixed a type confusion vulnerability relating to X.400 address processing
+     inside an X.509 GeneralName. X.400 addresses were parsed as an ASN1_STRING
+     but subsequently interpreted by GENERAL_NAME_cmp as an ASN1_TYPE. This
+     vulnerability may allow an attacker who can provide a certificate chain and
+     CRL (neither of which need have a valid signature) to pass arbitrary
+     pointers to a memcmp call, creating a possible read primitive, subject to
+     some constraints. Refer to the advisory for more information. Thanks to
+     David Benjamin for discovering this issue. (CVE-2023-0286)
+
+     This issue has been fixed by changing the public header file definition of
+     GENERAL_NAME so that x400Address reflects the implementation. It was not
+     possible for any existing application to successfully use the existing
+     definition; however, if any application references the x400Address field
+     (e.g. in dead code), note that the type of this field has changed. There is
+     no ABI change.
+
+     [Hugo Landau]
 
  Changes between 1.1.1r and 1.1.1s [1 Nov 2022]
 
index 87a5eff47cd99a61d7a5e00ad1c5a1c35626dba5..e54ddc55c957aa3ca9fce64d3eafaf4dc931b84e 100644 (file)
@@ -98,7 +98,7 @@ int 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(a->d.x400Address, b->d.x400Address);
         break;
 
     case GEN_EDIPARTY:
index 90fa3592ce58f7bdf6e1757519a6ec223f380e76..e61c0f29d4b4de249e04eda183699bf37e946eb3 100644 (file)
@@ -136,7 +136,7 @@ typedef struct GENERAL_NAME_st {
         OTHERNAME *otherName;   /* otherName */
         ASN1_IA5STRING *rfc822Name;
         ASN1_IA5STRING *dNSName;
-        ASN1_TYPE *x400Address;
+        ASN1_STRING *x400Address;
         X509_NAME *directoryName;
         EDIPARTYNAME *ediPartyName;
         ASN1_IA5STRING *uniformResourceIdentifier;
index d1852190b84eb948de8b5665762021b23b2c7766..37819da8fd78361785f01421fb44066208a532cb 100644 (file)
@@ -646,6 +646,14 @@ static struct gennamedata {
             0xb7, 0x09, 0x02, 0x02
         },
         15
+    }, {
+        /*
+         * Regression test for CVE-2023-0286.
+         */
+        {
+            0xa3, 0x00
+        },
+        2
     }
 };