Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Delete System76 and Microsoft keys (Use your own)" doesn't actually delete them #40

Open
gentoo-root opened this issue Jun 25, 2023 · 1 comment

Comments

@gentoo-root
Copy link

After choosing "Delete System76 and Microsoft keys (Use your own)" in the firmware setup menu, both System76 and Microsoft keys can still be seen with sbkeysync from Linux.

The code hints that only PK is deleted and the computer is immediately rebooted, but the keys of System76 and Microsoft are not actually deleted:


case KEY_SECURE_BOOT_DELETE_PK:
Status = DeletePlatformKey();
break;

case KEY_SECURE_BOOT_DELETE_PK:
//GetVariable2 (EFI_SETUP_MODE_NAME, &gEfiGlobalVariableGuid, (VOID**)&SetupMode, NULL);
//if (SetupMode == NULL || (*SetupMode) == SETUP_MODE) {
// IfrNvData->DeletePk = TRUE;
// IfrNvData->HasPk = FALSE;
// *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
//} else {
// IfrNvData->DeletePk = FALSE;
// IfrNvData->HasPk = TRUE;
// *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
//}
//if (SetupMode != NULL) {
// FreePool (SetupMode);
//}
// XXX: Is this safe?
gRT->ResetSystem(EfiResetCold, Status, 0, NULL);
break;

I would expect all these steps to be performed to actually delete vendor keys:

// Clear all the keys and databases
Status = DeleteDb ();
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
DEBUG ((DEBUG_ERROR, "Fail to clear DB: %r\n", Status));
return Status;
}
Status = DeleteDbx ();
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
DEBUG ((DEBUG_ERROR, "Fail to clear DBX: %r\n", Status));
return Status;
}
Status = DeleteDbt ();
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
DEBUG ((DEBUG_ERROR, "Fail to clear DBT: %r\n", Status));
return Status;
}
Status = DeleteKEK ();
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
DEBUG ((DEBUG_ERROR, "Fail to clear KEK: %r\n", Status));
return Status;
}
Status = DeletePlatformKey ();
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
DEBUG ((DEBUG_ERROR, "Fail to clear PK: %r\n", Status));
return Status;
}

@crawfxrd
Copy link
Member

crawfxrd commented Jun 27, 2023

Yes, only the PK is deleted. The KEKs are still there.


State after clean flash, before enabling Secure Boot:

$ sbkeysync --verbose --dry-run
Filesystem keystore:
firmware keys:
  PK:
  KEK:
  db:
  dbx:
filesystem keys:
  PK:
  KEK:
  db:
  dbx:
New keys in filesystem:

State after restoring default keys:

(NOTE: Restoring default keys does not enroll the DBX; This doesn't seem to happen unless you enable Secure Boot. DBX should probably always be enrolled.)

$ sbkeysync --verbose --dry-run
Filesystem keystore:
firmware keys:
  PK:
    /C=US/ST=Colorado/L=Denver/O=System76/CN=System76 Secure Boot Platform Key
  KEK:
    /C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=Microsoft Corporation KEK CA 2011
    /C=US/ST=Colorado/L=Denver/O=System76/CN=System76 Secure Boot Key Exchange Key
  db:
    /C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=Microsoft Corporation UEFI CA 2011
    /C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=Microsoft Windows Production PCA 2011
    /C=US/ST=Colorado/L=Denver/O=System76/CN=System76 Secure Boot Database Key
  dbx:
filesystem keys:
  PK:
  KEK:
  db:
  dbx:
New keys in filesystem:

State after deleting default keys:

$ sbkeysync --verbose --dry-run
Filesystem keystore:
firmware keys:
  PK:
  KEK:
    /C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=Microsoft Corporation KEK CA 2011
    /C=US/ST=Colorado/L=Denver/O=System76/CN=System76 Secure Boot Key Exchange Key
  db:
    /C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=Microsoft Corporation UEFI CA 2011
    /C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=Microsoft Windows Production PCA 2011
    /C=US/ST=Colorado/L=Denver/O=System76/CN=System76 Secure Boot Database Key
  dbx:
    <snip>
filesystem keys:
  PK:
  KEK:
  db:
  dbx:
New keys in filesystem:

@crawfxrd crawfxrd self-assigned this Jun 28, 2023
@crawfxrd crawfxrd removed their assignment Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants