Skip to content

Commit 8252ee4

Browse files
committed
Fix Null pointer deref in X509_issuer_and_serial_hash()
The OpenSSL public API function X509_issuer_and_serial_hash() attempts to create a unique hash value based on the issuer and serial number data contained within an X509 certificate. However it fails to correctly handle any errors that may occur while parsing the issuer field (which might occur if the issuer field is maliciously constructed). This may subsequently result in a NULL pointer deref and a crash leading to a potential denial of service attack. The function X509_issuer_and_serial_hash() is never directly called by OpenSSL itself so applications are only vulnerable if they use this function directly and they use it on certificates that may have been obtained from untrusted sources. CVE-2021-23841 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org>
1 parent d029cd3 commit 8252ee4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: crypto/x509/x509_cmp.c

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ unsigned long X509_issuer_and_serial_hash(X509 *a)
8787

8888
EVP_MD_CTX_init(&ctx);
8989
f = X509_NAME_oneline(a->cert_info->issuer, NULL, 0);
90+
if (f == NULL)
91+
goto err;
9092
if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL))
9193
goto err;
9294
if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f)))

0 commit comments

Comments
 (0)