-
Notifications
You must be signed in to change notification settings - Fork 22
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
pcks#7(.p7a) format signature authenticate issue #12
Comments
Hello,
Look at the line above, SELoader here actually didn't verify the file itself; it asked your UEFI Secure Boot implementation to do the MOK2 verify on it. The MOK2 Verify Protocol is standard and part of UEFI itself. So SELoader first did what your firmware cannot do itself, verifying whether you want to also validate the signatures of non-PE files during boot. If you just ask the MOK2 Verify Protocol to verify files with any certificate (no whitelist verification), then I can just put a fake bzImage file with a correct p7a file for it using my own fake certificate.
And then you say that SELoader still correctly validated your bzImage even if you replaced it later with a different (modified) one? Can you try running a third-party PKCS#7 signature verification utility on the modified bzImage file to make sure that other tools say that it's an invalid signature?
Here you will see that SELoader manually handled the verification of your PKCS#7 file (.p7a) and it was a correct whitelisted certificate inside. But the only thing SELoader didn't do itself was verifying the bzImage file itself, which it instead asked your firmware to do on its behalf (using MOK2 Verify unlike your .p7a file). So, the things you should do are:
It it still works then it's an error in SELoader which wouldn't correctly handle rare MOK2 failure scenarios, but if it fails on a different computer then your manufacturer's UEFI implementation for MOK2 Verify is faulty and you will need to replace it (by using a third-party DXE driver & replacing it in your firmware with UEFITool 0.27) |
I can also suggest you to modify some code in SELoader then recompile it for better debugging:
This is the function that gets called to verify your bzImage file, it simply tries to do a FileLoad then the MOK2 Verify hook handles the verification. But now look at this function:
That function however uses EfiConsolePrintError() to display error in the logs when verification fails, and EfiConsoleTraceDebug() only gets called when the MOK2 Verify Protocol installation is successful. So if your UEFI firmware had a bug in installing the MOK2 Verify protocol and didn't support displaying EfiConsolePrintError() output during boot, then you would never be informed that the MOK2 Verify protocol couldn't be installed. I also don't see in your logs the line And since SELoader works by using MOK2 Protocol hooks instead of direct verification of files, if the MOK2 protocol cannot be installed then all calls to EfiFileLoad() with an averagely correct file will succeed (because there will be no hook available to intercept its loading for verification). So more things you can do are to change the EfiConsolePrintError() calls to EfiConsoleTraceDebug() even if they're not for errors, incase your UEFI firmware doesn't correctly display error output (basically stderr on common operating systems). Then retry the same SELoader boot scenario and compare your logs to make sure that all the needed protocols & hooks were sucessfully installed, and yet SELoader somehow accepted to load your bzImage file. |
Hi @gdmeunier , I tried to verify it again with the grub.cfg file, grub.cfg.p7a is the signature file of grub.cfg.
I attached the full boot log for your reference. please help to check. thanks in advance~ |
Hello, The compressed version of your log is as below (without the other log messages):
So from your log I guess that you have a 2024 up-to-date BIOS by AMI. This line says that you have an up-to-date BIOS: These ones give your Shim version number:
Your SELoader build is 0.4.6 from 2018 (commit 8b90f76)
It's this line that tells which exact version of SELoader you have: An update was released in 2022 (commit 7df5b30):
In the commits list you can see the differences between the 2018 & 2022 version of SELoader: You need to pull the latest revision of SELoader named So you just have to rebuild SELoader from the latest commit and retry booting the files, but afterwards make sure to keep using Shim 15.x versions only:
The Secure Boot Setup Mode is correctly exited in your firmware, but that's something to remember when you will configure other computers for SELoader:
Basically exiting Setup Mode means removing the manufacturer's Platform Key and using your own, but also generating your own 'DB' & 'DBX' and enrolling them in your firmware (adding atleast one file hash or cert inside 'DB'). If there's still any problem with SELoader then downgrade Shim to 15.4 since it's the exact version that was tested to work with the latest SELoader from 2022 (latest commit). |
Dear Developer,
I am trying to use SEloader to authenticate the non-PE files in the UEFI secure boot process, but found that SEloader only authenticate the signature file (*.p7a) but not verify the original file.
I'd like to verify the zipped kernel file bzImage via pkcs#7(p7a) signatures, I generated a signature file bzImage.p7a for it. But when I replace a new kernel file and keep using the previous signature file(bzImage.p7a). SEloader also authenticate successfully.
seems SELoader did not verify the original file with .p7a format signature.
signing command:
selsign --key MOK.key --cert MOK.der --content-attached bzImage
logs:
The text was updated successfully, but these errors were encountered: