pk7_doit.c: Check return of BIO_set_md() calls
authorTomas Mraz <tomas@openssl.org>
Wed, 18 Jan 2023 08:27:53 +0000 (09:27 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 7 Feb 2023 16:02:47 +0000 (17:02 +0100)
commit4561dc7972ab08a25b1d91db3f99e0e7f72922bc
tree46dfc1fa8425cdffa29ac2181e2824e04f42d5d6
parent84d85fcabd6d8f3740ad015bda329512630799df
pk7_doit.c: Check return of BIO_set_md() calls

These calls invoke EVP_DigestInit() which can fail for digests
with implicit fetches. Subsequent EVP_DigestUpdate() from BIO_write()
or EVP_DigestFinal() from BIO_read() will segfault on NULL
dereference. This can be triggered by an attacker providing
PKCS7 data digested with MD4 for example if the legacy provider
is not loaded.

If BIO_set_md() fails the md BIO cannot be used.

CVE-2023-0401

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
crypto/pkcs7/pk7_doit.c