summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/Pkcs7Verify
diff options
context:
space:
mode:
authorLong Qin <qin.long@intel.com>2017-05-03 17:25:48 +0800
committerLong Qin <qin.long@intel.com>2017-05-05 14:58:47 +0800
commit76b35710b955fbba087d7e2c9029e2d78dbd0e7b (patch)
treeab577b11dc06ce50ffc4633dd1e1868fe1a0d3cd /SecurityPkg/Pkcs7Verify
parentde8e4dc4dfc228def7e270d43db6d0eff0cff1d4 (diff)
downloadedk2-76b35710b955fbba087d7e2c9029e2d78dbd0e7b.tar.gz
edk2-76b35710b955fbba087d7e2c9029e2d78dbd0e7b.tar.bz2
edk2-76b35710b955fbba087d7e2c9029e2d78dbd0e7b.zip
SecurityPkg/Pkcs7VerifyDxe: Add format check in DB list contents
Add the size check for invalid format detection in AllowedDb, RevokedDb and TimeStampDb list contents. Cc: Chao Zhang <chao.b.zhang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
Diffstat (limited to 'SecurityPkg/Pkcs7Verify')
-rw-r--r--SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c66
1 files changed, 60 insertions, 6 deletions
diff --git a/SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c b/SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c
index 07fdf552be..3776f903d4 100644
--- a/SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c
+++ b/SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c
@@ -5,7 +5,7 @@
verify data signed using PKCS7 structure. The PKCS7 data to be verified must
be ASN.1 (DER) encoded.
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -801,11 +801,13 @@ VerifyBuffer (
IN OUT UINTN *ContentSize
)
{
- EFI_STATUS Status;
- UINT8 *AttachedData;
- UINTN AttachedDataSize;
- UINT8 *DataPtr;
- UINTN DataSize;
+ EFI_STATUS Status;
+ EFI_SIGNATURE_LIST *SigList;
+ UINTN Index;
+ UINT8 *AttachedData;
+ UINTN AttachedDataSize;
+ UINT8 *DataPtr;
+ UINTN DataSize;
//
// Parameters Checking
@@ -818,6 +820,58 @@ VerifyBuffer (
}
//
+ // Check if any invalid entry format in AllowedDb list contents
+ //
+ for (Index = 0; ; Index++) {
+ SigList = (EFI_SIGNATURE_LIST *)(AllowedDb[Index]);
+
+ if (SigList == NULL) {
+ break;
+ }
+ if (SigList->SignatureListSize < sizeof (EFI_SIGNATURE_LIST) +
+ SigList->SignatureHeaderSize +
+ SigList->SignatureSize) {
+ return EFI_ABORTED;
+ }
+ }
+
+ //
+ // Check if any invalid entry format in RevokedDb list contents
+ //
+ if (RevokedDb != NULL) {
+ for (Index = 0; ; Index++) {
+ SigList = (EFI_SIGNATURE_LIST *)(RevokedDb[Index]);
+
+ if (SigList == NULL) {
+ break;
+ }
+ if (SigList->SignatureListSize < sizeof (EFI_SIGNATURE_LIST) +
+ SigList->SignatureHeaderSize +
+ SigList->SignatureSize) {
+ return EFI_ABORTED;
+ }
+ }
+ }
+
+ //
+ // Check if any invalid entry format in TimeStampDb list contents
+ //
+ if (TimeStampDb != NULL) {
+ for (Index = 0; ; Index++) {
+ SigList = (EFI_SIGNATURE_LIST *)(TimeStampDb[Index]);
+
+ if (SigList == NULL) {
+ break;
+ }
+ if (SigList->SignatureListSize < sizeof (EFI_SIGNATURE_LIST) +
+ SigList->SignatureHeaderSize +
+ SigList->SignatureSize) {
+ return EFI_ABORTED;
+ }
+ }
+ }
+
+ //
// Try to retrieve the attached content from PKCS7 signedData
//
AttachedData = NULL;