audk/CryptoPkg/Library
Jian J Wang 26442d11e6 CryptoPkg/BaseCryptLib: fix NULL dereference (CVE-2019-14584)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1914

AuthenticodeVerify() calls OpenSSLs d2i_PKCS7() API to parse asn encoded
signed authenticode pkcs#7 data. when this successfully returns, a type
check is done by calling PKCS7_type_is_signed() and then
Pkcs7->d.sign->contents->type is used. It is possible to construct an asn1
blob that successfully decodes and have d2i_PKCS7() return a valid pointer
and have PKCS7_type_is_signed() also return success  but have Pkcs7->d.sign
be a NULL pointer.

Looking at how PKCS7_verify() [inside of OpenSSL] implements checking for
pkcs7 structs it does the following:
- call PKCS7_type_is_signed()
- call PKCS7_get_detached()
Looking into how PKCS7_get_detatched() is implemented, it checks to see if
p7->d.sign is NULL or if p7->d.sign->contents->d.ptr is NULL.

As such, the fix is to do the same as OpenSSL after calling d2i_PKCS7().
- Add call to PKS7_get_detached() to existing error handling

Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
2020-10-21 06:32:46 +00:00
..
BaseCryptLib CryptoPkg/BaseCryptLib: fix NULL dereference (CVE-2019-14584) 2020-10-21 06:32:46 +00:00
BaseCryptLibNull CryptoPkg/BaseCryptLib: Retire HMAC SHA1 algorithm 2020-05-15 07:22:36 +00:00
BaseCryptLibOnProtocolPpi CryptoPkg/BaseCryptLib: Add MARCO to disable the deprecated SHA1 2020-06-29 05:25:55 +00:00
BaseHashApiLib CryptoPkg/BaseHashApiLib: Rename BaseHashApiLib by HashApiLib 2020-04-08 01:12:36 +00:00
Include CryptoPkg/OpensslLib: Upgrade OpenSSL to 1.1.1g 2020-07-25 06:27:14 +00:00
IntrinsicLib CryptoPkg IntrinsicLib: Make _fltused always be used 2019-10-24 09:41:34 +08:00
OpensslLib CryptoPkg: OpensslLib: Use RngLib to generate entropy in rand_pool 2020-09-18 02:19:21 +00:00
TlsLib CryptoPkg: Add RISC-V architecture for EDK2 CI. 2020-04-03 17:09:12 +00:00
TlsLibNull CryptoPkg: Add RISC-V architecture for EDK2 CI. 2020-04-03 17:09:12 +00:00