Revision: 13701
          http://edk2.svn.sourceforge.net/edk2/?rev=13701&view=rev
Author:   sfu5
Date:     2012-09-06 02:15:59 +0000 (Thu, 06 Sep 2012)
Log Message:
-----------
Check the value of Hdr.dwLength for signed EFI image before image validation.

Signed-off-by: Fu Siyuan <[email protected]>
Reviewed-by: Ye Ting  <[email protected]>
Reviewed-by: Dong Guo <[email protected]>

Modified Paths:
--------------
    
trunk/edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c

Modified: 
trunk/edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
===================================================================
--- 
trunk/edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
    2012-09-05 08:46:51 UTC (rev 13700)
+++ 
trunk/edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
    2012-09-06 02:15:59 UTC (rev 13701)
@@ -1276,6 +1276,9 @@
     // Authenticode specification.
     //
     PkcsCertData = (WIN_CERTIFICATE_EFI_PKCS *) WinCertificate;
+    if (PkcsCertData->Hdr.dwLength <= sizeof (PkcsCertData->Hdr)) {
+      goto Done;
+    }
     AuthData   = PkcsCertData->CertData;
     AuthDataSize = PkcsCertData->Hdr.dwLength - sizeof(PkcsCertData->Hdr);
     
@@ -1290,7 +1293,8 @@
     // The certificate is formatted as WIN_CERTIFICATE_UEFI_GUID which is 
described in UEFI Spec.
     //
     WinCertUefiGuid = (WIN_CERTIFICATE_UEFI_GUID *) WinCertificate;
-    if (!CompareGuid(&WinCertUefiGuid->CertType, &gEfiCertPkcs7Guid)) {
+    if (!CompareGuid(&WinCertUefiGuid->CertType, &gEfiCertPkcs7Guid) ||
+        (WinCertUefiGuid->Hdr.dwLength <= OFFSET_OF(WIN_CERTIFICATE_UEFI_GUID, 
CertData))) {
       goto Done;
     }
     AuthData = WinCertUefiGuid->CertData;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to