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:05:10 +0000 (17:05 +0100)
commit6eebe6c0238178356114a96a7858f36b24172847
tree3f5c4c13b58cac8d867aafe7ce3d2b4f6344b62f
parent7880536fe17c2b5450e279155bedd51771d28c9f
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: Richard Levitte <levitte@openssl.org>
crypto/pkcs7/pk7_doit.c