Skip to content

Commit 929d1a2

Browse files
Jian J Wangmergify[bot]
authored andcommitted
SecurityPkg/DxeImageVerificationLib: avoid bypass in fetching dbx (CVE-2019-14575)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1608 In timestamp check after the cert is found in db, the original code jumps to 'Done' if any error happens in fetching dbx variable. At any of the jump, VerifyStatus equals to TRUE, which means allowed-by-db. This should not be allowed except to EFI_NOT_FOUND case (meaning dbx doesn't exist), because it could be used to bypass timestamp check. This patch add code to change VerifyStatus to FALSE in the case of memory allocation failure and dbx fetching failure to avoid potential bypass issue. Cc: Jiewen Yao <[email protected]> Cc: Chao Zhang <[email protected]> Signed-off-by: Jian J Wang <[email protected]> Reviewed-by: Jiewen Yao <[email protected]>
1 parent 9e56970 commit 929d1a2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,15 +1459,26 @@ IsAllowedByDb (
14591459
DbxDataSize = 0;
14601460
Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid, NULL, &DbxDataSize, NULL);
14611461
if (Status != EFI_BUFFER_TOO_SMALL) {
1462+
if (Status != EFI_NOT_FOUND) {
1463+
VerifyStatus = FALSE;
1464+
}
14621465
goto Done;
14631466
}
14641467
DbxData = (UINT8 *) AllocateZeroPool (DbxDataSize);
14651468
if (DbxData == NULL) {
1469+
//
1470+
// Force not-allowed-by-db to avoid bypass
1471+
//
1472+
VerifyStatus = FALSE;
14661473
goto Done;
14671474
}
14681475

14691476
Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid, NULL, &DbxDataSize, (VOID *) DbxData);
14701477
if (EFI_ERROR (Status)) {
1478+
//
1479+
// Force not-allowed-by-db to avoid bypass
1480+
//
1481+
VerifyStatus = FALSE;
14711482
goto Done;
14721483
}
14731484

0 commit comments

Comments
 (0)