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

Feature Request: Warn if media will no longer be bootable after Q1 2024. #2244

Open
4 of 10 tasks
rcmaehl opened this issue May 12, 2023 · 77 comments
Open
4 of 10 tasks
Assignees
Labels

Comments

@rcmaehl
Copy link

rcmaehl commented May 12, 2023

Checklist

  • I looked at https://github.com/pbatard/rufus/wiki/FAQ to see if my question has already been answered.
  • I performed a search in the issue tracker for similar issues using keywords relevant to my problem, such as the error message I got from the log.
  • I clicked the 'Log' button or pressed Ctrl-L in Rufus, or used DebugView, and copy/pasted the log into the section that says <FULL LOG> below.
  • The log I am copying is the FULL log, starting with the line Rufus version: x.y.z - I have NOT removed any part of it.

Additionally (if applicable):

  • I ran a bad blocks check, by clicking Show advanced format options then Check device for bad blocks, and confirmed that my USB is not defective.
  • I also tried one or more of the following:
    • Using a different USB drive.
    • Plugging the USB into a different port.
    • Running Rufus on a different computer.
  • If using an image, I clicked on the (✓) button to compute the MD5, SHA1 and SHA256 checksums, which are therefore present in the log I copied. I confirmed, by performing an internet search, that these values match the ones from the official image.

Issue description

Due to changes to the Windows Boot Manager from CVE-2023-24932. Previously created boot media will no longer be able to boot once enforcement begins Q1 of 2024. If possible, detect this issue and provide a warning.

https://support.microsoft.com/en-us/topic/kb5025885-how-to-manage-the-windows-boot-manager-revocations-for-secure-boot-changes-associated-with-cve-2023-24932-41a975df-beb2-40c1-99a3-b3ff139f832d#avoidissues5025885

Log

N/A

@Hrxn
Copy link

Hrxn commented May 12, 2023

Yikes...

Do I get that right, any official ISOs past a given date will be good, then?
But they have not released anything yet, right?

@pbatard pbatard self-assigned this May 12, 2023
@pbatard
Copy link
Owner

pbatard commented May 12, 2023

Aha, I was wondering how long Microsoft would try to swipe that CVE under the carpet until they had no choice but to take action.

If possible, detect this issue

Yeah, that's the major issue here. Microsoft have some kind of revocation list, but of course, they didn't make it downloadable as a standalone (because, why would they? Security through obscurity has always worked WONDERS for everybody....), so it's going to be a PITA.

and provide a warning.

I'll try to do that. But I'm not going to rush into it, and spend time that I don't have being a trailblazer. So I'm going to tag this as deferred for now.

@rcmaehl
Copy link
Author

rcmaehl commented May 12, 2023

Aha, I was wondering how long Microsoft would try to swipe that CVE under the carpet until they had no choice but to take action.

If possible, detect this issue

Yeah, that's the major issue here. Microsoft have some kind of revocation list, but of course, they didn't make it downloadable as a standalone (because, why would they? Security through obscurity has always worked WONDERS for everybody....), so it's going to be a PITA.

and provide a warning.

I'll try to do that. But I'm not going to rush into it, and spend time that I don't have being a trailblazer. So I'm going to tag this as deferred for now.

Sounds good! I mean there's essentially an entire year to work on this

@rcmaehl
Copy link
Author

rcmaehl commented May 22, 2023

Looks like checking for

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Secureboot\AvailableUpdates dword >= 0x10 may work. I'll need to apply the revocation steps myself later to verify that the registry value doesn't change after applying the list.

@pbatard
Copy link
Owner

pbatard commented May 22, 2023

I saw the registry key, but I don't think it's enough, because it only tells if the current machine might have been upgraded to reject old MS bootloaders, but not if the ISO contains one.

In other words, if we only check for the registry key, we will warn the user regardless of whether the ISO they selected uses an old or new bootloader, whereas we obviously don't want to warn about ISOs that use the new bootloaders.

So, again, to properly display the warning, we need to check the bootloader's hash against the revoked hashes.

From my understanding, the registry key is just a switch to tell the system to update the UEFI revocation list with the hashes of the old bootloaders since, understandably, Microsoft does not yet want to apply revocation wholesale and leave users booting older Windows ISOs facing a Secure Boot validation error. They only want to do that for users who opt-in.

Now, another potential workaround I am considering, provided we can actually download the new bootloaders from Microsoft's servers without having to extract a whole ISO (the issue being that I can't just store a copy of these bootloaders on a server somewhere for Rufus to download, without committing copyright infringement, so we have to hope that they're in a small enough .cab/.msi downloadable directly from Microsoft) would be for Rufus to replace the old soon-to-be-revoked bootloaders with the new non-revoked version, since these should be fully interchangeable.

The problem with this workaround however is that this would potentially only work for the initial USB boot (pre-installation phase) and not for the post file-copy (re)boot, as my current assumption is that during initial file copy, Microsoft picks the bootloaders from install.wim/install.esd rather than the ones from the USB (if you look at the wim/esd you'll find bootmgr.efi in Windows\Boot\EFI\), and therefore we'd have to replace them there for things to work, which will be very costly as manipulating the full >4 GB .wim is a very time consuming operation. If we are lucky however, the bootmgr.efi Microsoft installs in the file copy phase is the one found in boot.wim, which, on the other hand, we should be able to replace, as we are already performing boot.wim image manipulation to add the registry keys for the TPM/Secure Boot bypass, and thus, changing a file there would be a no brainer (well, except for people who get Rufus from the Windows Store, because the Windows Store version cannot mount .wim files, so users there will be screwed).

I am obviously planning to test this when I have a chance (which may not be before a couple of month or worse) and when I have upgraded a system to the new revoked hashes (which I will need to do carefully and make sure to keep a copy of the revocation list before and after, since I need to isolates these bloody hashes that Microsoft SHOULD provide publicly but, no matter where I looked so far, doesn't!)...

@stdin82
Copy link

stdin82 commented May 23, 2023

and when I have upgraded a system to the new revoked hashes (which I will need to do carefully and make sure to keep a copy of the revocation list before and after, since I need to isolates these bloody hashes that Microsoft SHOULD provide publicly but, no matter where I looked so far, doesn't!)...

https://uefi.org/revocationlistfile
https://uefi.org/sites/default/files/resources/dbx_info.csv

@pbatard
Copy link
Owner

pbatard commented May 23, 2023

Aha! Since we're talking about an upcoming revocation, and Microsoft is the sole entity that controls the revocation list, I didn't think they would have started to add DBX entries prior to Q1 2024, since it means that we're definitely going to see Secure Boot validation errors with Windows media long before that date (because motherboard manufacturers are not going to cherry pick what goes in the DBX they apply but pick the most recent).

Their process to decide whether a bootloader should be flagged as vulnerable or not is less than straightforward though, per https://uefi.org/sites/default/files/resources/dbx_release_info.pdf:

The following is a summary of Microsoft’s revocation techniques used for the Black Lotus vulnerability:
• Boot Managers from Windows 8 to Windows 10, version 1507: revoked by DBX entries
• Boot Managers from Windows 10, version 1507 to Windows 10, version 1607: revoked by hash by SKU SiPolicy
• Boot Managers from Windows 10, version 1703 to today: revoked by version number by SKU SiPolicy

So, we do not have a complete list of hashes of vulnerable bootloaders, and we're going to have deal with this mess to decide whether a bootloader has been revoked or not, which, and I very much hope I can be proved wrong here, Microsoft is providing no explicit details about. Especially, it does not say what version numbers are being revoked, and it is also my impression that the hashes revoked by SKU SiPolicy are not in the UEFI CSV...

@pbatard
Copy link
Owner

pbatard commented May 23, 2023

Indeed, Microsoft explicitly state here:

We have released the DbxUpdate.bin file for this issue on UEFI.org. These hashes include all revoked Windows boot managers released between Windows 8 and the initial release of Windows 10 that do not respect the Code Integrity Policy.

So, everything that is meant to be rejected after Windows 10 1507 has not been made public by Microsoft, and, as much as I'd very much like it to be otherwise, my initial comment about Microsoft not publishing information that they should provide still stands (and is made worse by the fact that we can't just rely on getting our hands on a list of hashes).

@pbatard
Copy link
Owner

pbatard commented May 23, 2023

I guess the other option we have, since we're going to have to deal with a version whatershed anyway, is to not bother with hashes and just check the version number from the EFI bootloader to display a warning if it's anything below the 22H2 v2's version (which appears to be 10.0.2261.1702 vs 10.0.2261.1 for 22H2 v1). Of course it would be nice to have the actual version that acts as the separator from Microsoft themselves...

Note that there is an additional SECURITYVERSION variable in the resource file of the EFI bootloaders, which is probably tied to the new SiPolicy feature, but for those who might be wondering if the 2.0.0.2 VersionEx referenced here has anything to do with the actual version filtering, and could be used against SECURITYVERSION, that latter variable is set to 1.0.0.0 in all the bootloaders I see, and considering that the UEFI variable is described as Set’s the code integrity boot policy version, it seems to be more about defining the minimum version of the SiPolicy environment than defining the actual minimum version of the bootloaders that should be rejected (else, I'd expect Microsoft to describe it as Sets the minimal version of bootloaders accepted by the boot policy). In short, this seems to be a version number that applies when you want to replace a an existing SkuSiPolicy.p7b and not something that give us a precise idea of the bootloader version below which a EFI bootloader should be considered vulnerable.

@pbatard
Copy link
Owner

pbatard commented May 23, 2023

Interestingly, if we need to download a bootmgfw.efi replacement, we may end up using the same method as the actual Black Lotus malware (See "1. An installer deploys files to the ES") to download the file from Microsoft by fetching the executables straight from https://msdl.microsoft.com/download/symbols/.

It does seem however that Microsoft might have taken steps to try to prevent these kind of downloads as I can't seem to manage to get this to work.

For instance, the following to retrieve a PDB will work just fine (symbols for the latest bootmgfw.efi from 22H2 v2 ISOs):

wget -c -U="Microsoft-Symbol-Server/10.0.0.0" https://msdl.microsoft.com/download/symbols/bootmgfw.pdb/F2B888C9A171A1FC2F9587649411BFD12/bootmgfw.pdb

But trying to do the same for the associated binary, which should resolve to https://msdl.microsoft.com/download/symbols/bootmgfw.efi/B647817D2ba000/bootmgfw.efi and should be served in the same manner as the PDB by Microsoft's symbol servers, just doesn't seem to work (and the same is true for a similar-but-not-the-exact-same URL that Black Lotus uses to download its own bootmgfw.efi, though of course, we want to be careful relying on this one to tell us anything as Microsoft may have deliberately chosen to remove it to stop the spread of the malware).

Using the same method I used to generate the bootmgfw.efi URL for notepad.exe (method is basically described here) yields https://msdl.microsoft.com/download/symbols/notepad.exe/E798EFB45a000/notepad.exe which downloads just fine through wget -c -U="Microsoft-Symbol-Server/10.0.0.0"

Goddammit, this is so annoying! What the hell does one have to do (besides becoming a full blown malware author) to be able to download a simple executable from Microsoft??

@pbatard
Copy link
Owner

pbatard commented May 23, 2023

Even more interestingly, since it appears that we can easily download Windows 8.1's diskcopy.dll from https://msdl.microsoft.com/download/symbols/diskcopy.dll/54505118173000/diskcopy.dll, that Black Lotus trick may help us restore the MS-DOS installation functionality, that we had to remove from Windows 10 or later on account that Microsoft had removed this DLL (which contains a full blown MS-DOS floppy disk image) from recent Windows version. 😉

@pbatard
Copy link
Owner

pbatard commented Jun 2, 2023

Gotta also leave https://support.microsoft.com/en-us/topic/kb5025885-how-to-manage-the-windows-boot-manager-revocations-for-secure-boot-changes-associated-with-cve-2023-24932-41a975df-beb2-40c1-99a3-b3ff139f832d#updatebootable5025885 here. Of course, it would be A LOT better if Microsoft did bother to check the "content" they provide an have an actual working hyperlink for:

If you use a bootable disk image (ISO), a CD-ROM, or DVD media, update the media by following the instructions here.

In short, Microsoft needs to provide a direct download for the non-vulnerable bootmgfw.efi for all archs, if they want their efforts against Black Lotus to be taken seriously, because they have to consider the case of customers updating boot media for a different arch than the current system (e.g. ARM64 from x86_64) that doesn't force folks to go through a full blown multi GB ISO/ESD download just to extract a 2 MB file...

@pbatard
Copy link
Owner

pbatard commented Jun 6, 2023

What a load of crap this whole thing is!

So I updated a system following the 3. APPLY the revocations steps from Microsoft, doing everything as described (double reboot, wait 5 minutes, confirm in Event Viewer that there's an entry that says that DBX has been updated) and then created a Windows 8.1 bootable media (from en-gb_windows_8.1_with_update_x64_dvd_4048142.iso, SHA-1 1F18420D65956DFE56E2359DA71AB6C363146570), fully expecting Secure Boot to produce a validation error, as indicated by Microsoft... but the media boots just fine in a Secure Boot environment...

So much for:

• Boot Managers from Windows 8 to Windows 10, version 1507: revoked by DBX entries

Unless both Microsoft and Linux are lying, my system should have the latest DBX applied:

root@debian:~# fwupdmgr get-devices
(...)
├─System Firmware:
│ │   Device ID:          a45df35ac0e948ee180fe216a5f703f32dda163f
│ │   Summary:            UEFI ESRT device
│ │   Current version:    53
│ │   Minimum Version:    53
│ │   Vendor:             Intel(R) Client Systems (DMI:Intel Corp.)
│ │   Update State:       Success
│ │   GUIDs:              f4cd40f8-4947-4069-bd4d-d5987adefc79
│ │                       230c8b18-8d9b-53ec-838b-6cfc0383493a ← main-system-firmware
│ │   Device Flags:       • Internal device
│ │                       • Updatable
│ │                       • System requires external power source
│ │                       • Needs a reboot after installation
│ │                       • Cryptographic hash verification is available
│ │                       • Device is usable for the duration of the update
│ │
│ └─UEFI dbx:
│       Device ID:        362301da643102b9f38477387e2193e57abaa590
│       Summary:          UEFI revocation database
│       Current version:  423
│       Minimum Version:  423
│       Vendor:           UEFI:Linux Foundation
│       Install Duration: 1 second
│       GUIDs:            c6682ade-b5ec-57c4-b687-676351208742 ← UEFI\CRT_A1117F516A32CEFCBA3F2D1ACE10A87972FD6BBE8FE0D0B996E09E65D802A503
│                         f8ba2887-9411-5c36-9cee-88995bb39731 ← UEFI\CRT_A1117F516A32CEFCBA3F2D1ACE10A87972FD6BBE8FE0D0B996E09E65D802A503&ARCH_X64
│       Device Flags:     • Internal device
│                         • Updatable
│                         • Needs a reboot after installation
│                         • Device is usable for the duration of the update
│                         • Only version upgrades are allowed
│                         • Signed Payload
(...)

And I can tell that Secure Boot is really enabled and enforcing validation, since I do get a big fat Secure Boot validation error when I try to boot the unsigned UEFI Shell...

Someone, somewhere, is not telling the truth...

@stdin82
Copy link

stdin82 commented Jun 8, 2023

Maybe the efi files from that iso are not revoked?
i checked SHA-256 of bootx64.efi & bootmgfw.efi from en_windows_8.1_with_update_x64_dvd_6051480.iso, they are not listed in dbx_info.csv

@pbatard
Copy link
Owner

pbatard commented Jun 8, 2023

i checked SHA-256 of bootx64.efi & bootmgfw.efi from en_windows_8.1_with_update_x64_dvd_6051480.iso, they are not listed in dbx_info.csv

The thing is, if you try to lookup plain SHA-256's in the CSV, from a revoked executable, you will not find it either.

That's because the "flat" SHA-256's provided by Microsoft are not the SHA-256 you get by computing the hash for the whole file (because, of course, that would be too straightforward, and who wants to be straightforward and non-obtuse when dealing with matters of security...), but the hash you get by Frankenstein's Monstering only a selection of sections from it (and, yeah, technically, that might make sense as the Secure Boot signature does not apply to all the PE data in the first place, so one could defeat the DBX by altering one of these sections, as they wouldn't invalidate the signature, but would change the hash from the DBX, though I would counter with WHO IN THEIR RIGHT MIND DECIDED THAT HASHING A FILE FOR FRIGGING DIGITAL SIGNATURE VALIDATION SHOULD NOT BE ON THE WHOLE ORIGINAL SOURCE BINARY BUT INSTEAD ON SECTIONS CHERRY PICKED AT RANDOM?!? HOW HARD WOULD IT HAVE BEEN TO DESIGN A NEW PE CONTAINER EXTENSION THAT COULD EMBED THE ORIGINAL BINARY WHOLESALE + DIGITAL SIGNATURE INTO A SIGNED PE FILE INSTEAD OF THIS COMPLETE SECURITY ABOMINATION THAT ULTIMATELY FORCES EVERYONE TO HAVE DEAL WITH THIS MICROSOFT INDUCED BULLSHIT?). So, if all you have is a EFI binary, and you want to find out if it's in the Microsoft published DBX, well, better be ready to code your own SHA-256 hashing application, because good luck finding a standalone SHA-256 computation application that can deal with the intricacies of PE hashing for Secure Boot...

Thankfully, after much searching and sieving through bullshit, I found that the obscure PE256 value that Microsoft also does provide in the CSV is actually the SHA-256 "hash" that Get-AppLockerFileInformation reports when you feed it a Secure Boot signed UEFI executable.

For instance, if you issue Get-AppLockerFileInformation bootx64.efi from PowerShell for the bootx64.efi of en-gb_windows_8_x64_dvd_915412.iso, you get Hash: SHA256 0xCF7F9E7D091023A1A1C3F5CBF7DDACF7B18F03A4D07961F71506FE9DF4388EEE, and you will find that this last value is in the CSV under PE256, whereas the standard SHA-256 for that file is BEA5931767DCA4C46EF7D6AD73E6913A592860138D3FC82056289B8DFF337940 and does not match the 196243A87389B47FC9033AF3884F3FF0A5C891D80E22C82D2ECD5B9A3434186E SHA-256 that Microsoft expects for that file in the CSV.

All this to say that, whereas Microsoft were supposed, and have indicated, that all their Windows 8, 8.1 and 10 UEFI bootloaders prior to 1507 should have been entered in the DBX, the bootx64.efi from en-gb_windows_8.1_with_update_x64_dvd_4048142.iso certainly has not been, because its PE256, as computed by Get-AppLockerFileInformation is CD2CFDA64B9D6DB3CA88D27B3F90453ABCD842844A3B45696B90BE54E58AAE04, and that value is NOT in the bloody DBX.

And I guess that, now that you know how to validate whether a Windows UEFI bootloader executable is in the DBX, you too can play the game of "What other bootx64.efi/bootmgfw.efi did Microsoft forgot to register for DBX exclusion when they said it should be excluded?

Oh and incidentally, trying to boot a USB media created from en-gb_windows_8_x64_dvd_915412.iso on my updated test machine does produce a Secure Boot security violation as expected...

@stdin82
Copy link

stdin82 commented Jun 8, 2023

I see
the standard SHA-256 of bootmgfw.efi (both x86/x64) from Windows 8.1 update KB3084905 are listed though, and Get-AppLockerFileInformation result match the listed PE256 Authenticode

neither values are listed for 6051480.iso files

the list might have glitches, or they forgot to revoke some files

@pbatard
Copy link
Owner

pbatard commented Jun 8, 2023

Yeah, my worry here is that those missed EFI bootloaders, which the DBX does let through (it's not a list issue, it's a DBX issue, as I did validate that these bootloaders are being let through on a fully updated system), might be compatible with newer Windows (whilst ignoring the SKUSiPolicy.p7b which is how Windows 10 1507+ bootloaders are being filtered out), meaning that the Black Lotus team may just have to install one of these, and folks who went through all the steps to prevent Black Lotus might still get infected with Black Lotus regardless...

@pbatard
Copy link
Owner

pbatard commented Jun 8, 2023

Note: I have just e-mailed the UEFI Forum administrators as well as the Microsoft Secure Boot signing team with my concerns about these missing Windows 8.1 bootloaders from the DBX.

Oh, and for the record, these bootloaders were built in 2014.03, and look a bit too early to have benefited from the post 2015.07 revocation features...

UPDATE: On advice from Microsoft, I have also created a new vulnerability report (VULN-102832) at https://msrc.microsoft.com/report/vulnerability.

@pbatard
Copy link
Owner

pbatard commented Jun 9, 2023

A few more random notes, for those who might be interested in this whole thing:

  1. If you copy %systemroot%\System32\SecureBootUpdates\SKUSiPolicy.p7b to the efi\microsoft\boot\ directory of boot media created from a post 1507, pre 2305 Windows ISO (tested with a Windows 10 1703 bootable USB created with Rufus), you get the expected Microsoft equivalent of a Secure Boot Security Violation with the Recovery screen below, with a The digital signature for this file could not be verified / Error code: 0xc0000428 message:
    Sany4910
  2. In an unexpected Microsoft did the right thing for once, it appears that the SKUSiPolicy.p7b file is universal, which means that the version you get from an x86_64 Windows installation contains the revocations for ARM64, and vice versa. This is of interest to us if we plan to automatically add SKUSiPolicy.p7b to Windows media created by Rufus (see below).
  3. Windows 7 has never been Secure Boot compatible (the bootloaders are signed by Microsoft... but not with the UEFI Secure Boot credentials), so there's no need to revoke anything there as you'll get a Security Violation regardless.
  4. It appears that Microsoft Hyper-V looks at the host system's SKUSiPolicy.p7b to check if the UEFI bootloader should be trusted, meaning that, even if the virtual disk you boot from does not have an SKUSiPolicy.p7b present, you will get a standard Secure Boot Security Violation (rather than the 0xc000042 Recovery screen) if that bootloader happens to have been revoked in the host's SKUSiPolicy.p7b.
  5. Adding SKUSiPolicy.p7b to USB media created from the en_windows_8.1_with_update_x64_dvd_6051480.iso or en-gb_windows_8.1_with_update_x64_dvd_4048142.iso ISOs (the two Windows 8.1 ISOs whose bootloaders appear to have been "forgotten" by Microsoft for exclusion) still results in media that boots in an updated system, meaning that Microsoft did not voluntarily exclude these bootloaders from the DBX on account that they were modern enough for SKUSiPolicy.p7b to apply...

At this stage, considering that trying to secure systems of unaware users is something that applications should strive for (rather than let unaware users potentially get infected through known easily patchable security holes), I am planning to have Rufus automatically copy the system's SKUSiPolicy.p7b to the boot media when a efi\microsoft\boot\ is detected there and either SKUSiPolicy.p7b does not exist, or one exists but it is older than the system's.

My reasoning is that, in an ideal world, all the bootloaders for which SKUSiPolicy.p7b applies would have been added to the DBX, but they haven't been because the DBX is actually running out of space and Microsoft (as well as the Shim folks) devised alternate methods that mirror what the DBX does without actually using the DBX. So, in an ideal world, these Microsoft bootloaders should generate a Security Violation on up to date Secure Boot enabled systems regardless of whether a SKUSiPolicy.p7b exists or not, and we really don't want users to get the idea that everything is fine and dandy when they are booting a media that is known to be potentially problematic and/or used as vector of infection. Especially, it needs to be hammered to users that, if they get a Security Violation and still want to boot that media, they can always disable Secure Boot. But then that decision to boot known insecure bootloaders becomes their explicit choice and is not something they'll be able to dismiss with a "Well, I didn't know I was potentially putting my system at risk..."

And this is where we might for once be helped by SKUSiPolicy.p7b appearing to be universal, as my one worry was that trying to use the SKUSiPolicy.p7b from an x86_64 system to create an ARM64 boot media would leave that ARM64 media open, on account that Microsoft may have chosen to produce arch-specific SKUSiPolicy.p7b's...

@stdin82
Copy link

stdin82 commented Jun 10, 2023

Doesn't KB5025885 article state that SKUSiPolicy.p7b should not be copied to the boot media (ISO, USB, DVD..)?

@pbatard
Copy link
Owner

pbatard commented Jun 10, 2023

Doesn't KB025885 also not provide any instructions on how one should update ISO/USB/DVD media ("update the media by following the instructions here." with no hyperlink)?

Again, there are no two ways of going on about bootloaders that should be revoked because they can potentially be used to infect one's system: They must be filtered out with an obvious security violation on a Secure Boot enabled system, so that users are clear about what they are about to do.

Now, of course, in a context where you either created your own media (which is the context of the KB) or you are using media that came from Microsoft themselves, it does make little sense to try to filter the bootloaders because that media should be considered safe, and SKUSiPolicy.p7b should be applied to the installed system either directly (post 2305 images) or through Windows update pre (2305). Plus, because that statement is extraordinarily "blanket" and does not provide even a hint of why, I'm half convinced that this note is really about not copying SKUSiPolicy.p7b to media that use non Microsoft bootloaders (such as GRUB, etc).

However, in the context of Rufus, I have no way of telling if the source media is safe (and I am not going to add a very costly SHA-1 validation to check for retail ISOs, especially as a lot of folks are going to use MCT ISOs anyway which should be considered safe but cannot be validated for safety). Furthermore, the creation of boot media using Rufus from a Black Lotus infected ISO (or a Black Lotus derivative) is a real scenario that I expect to happen, so, again, I do want users to make their own explicit decision (especially if they are using dodgy-sourced ISOs) when it comes to potentially lowering the security of their system as well as nudge them towards using a more up to date ISO. And, yeah, I am well aware this will annoy a lot of people, but that's how security works, and the minute you attempt to compromise security for convenience (which, IMO, is what Microsoft are doing by not advising people to copy SKUSiPolicy.p7b to post 1507 bootable media), you lose security.

So, I am just going to re-state what I just said above, regardless of what Microsoft states (who, as we have seen, are not impervious to botching security): In an ideal world, all the Microsoft EFI bootloaders prior to 2305 should have been added to the UEFI DBX and should generate a Security Violation in a Secure Boot enabled environment. As such, so that the majority of users remain safe, especially if they are using ill-sourced ISOs, I want Rufus to create media that behaves as close as possible to that ideal situation, and this entails going against Microsoft's "recommendations" and copying the system's SKUSiPolicy.p7b to the media.

@pineapple63
Copy link

4. It appears that Microsoft Hyper-V looks at the host system's `SKUSiPolicy.p7b` to check if the UEFI bootloader should be trusted, meaning that, even if the virtual disk you boot from does not have an `SKUSiPolicy.p7b` present, you will get a standard Secure Boot Security Violation (rather than the `0xc000042` Recovery screen) if that bootloader happens to have been revoked in the host's `SKUSiPolicy.p7b`.

Seems as though Microsoft Surface devices also look at that file to decide what should trigger a secure boot violation
Just now i was doing some experementing with a Surface Go 3 (which i have applied the revocations to, its the same device that i made the discovery with microsofts annoying "more secure than normal secure boot" thing), i downloaded the latest recovery image for it, only to find that microsoft hadn't released an updated (post 9th of May) recovery image, the files in the image were showing as last modified in April (so out of curiosity i tried booting the image (which i copied to a USB, as the recovery images are supplied as a ZIP file), and with secure boot enabled (both "Microsoft only" and standard secure boot settings), it was doing exactly what it does for a secure boot violation, it only booted when i temporarally disabled secure boot (and yes, i did re-enable secure boot afterwards))

@pbatard
Copy link
Owner

pbatard commented Jun 12, 2023

@pineapple63, thanks for the report.

That's actually part of the reason why I think Microsoft's "advice" about not copying SKUSiPolicy.p7b to Windows bootable media is something that can/should safely be ignored, because if you don't copy that file then any non-Microsoft machine you boot from will pretend that everything is fine and dandy, whereas, on Microsoft controlled hardware, be it virtual or real, if you boot the same media, even without SKUSiPolicy.p7b, you get an explicit UEFI Security Violation.

So, clearly, Microsoft, in its actions (rather than in its words) is telling us that any of their pre 2305 EFI bootloaders should generate a Security Violation. And the only way to get that on non-Microsoft controlled hardware, for post 1507 media, is to manually copy the system's SKUSiPolicy.p7b, which is why, if there's no other possibility (such as replacing pre 2305 bootloaders with more recent ones, which, even if we were to have direct download access to such bootloaders from Microsoft, is not guaranteed to be viable if we also have to replace these bootloaders in install.wim), I am planning to do just that in Rufus...

@pbatard
Copy link
Owner

pbatard commented Jun 13, 2023

Update from Microsoft with regards to the missing DBX entries MSRC case:

Thank you again for reporting this behavior. Microsoft is working on a comprehensive fix that will update the DBX to include additional boot loaders. However, due to the complexity of the fixes involved, we are targeting January 2024 for the next update.

So, yeah, they acknowledged that their DBX update is currently incomplete, which I'm going to assume means that you might still be able to get infected by Black Lotus, on a fully up to date system, until January 2024...

@pbatard
Copy link
Owner

pbatard commented Jun 14, 2023

Tonight, on the ongoing saga of whatever the heck Microsoft is doing to try to mitigate Black Lotus we attempt to take a closer look at:

• Boot Managers from Windows 10, version 1507 to Windows 10, version 1607: revoked by hash by SKU SiPolicy

The idea is that, since I am planning to detect EFI bootloaders that have been revoked by the DBX in Rufus and warn the user about them (hence why I just added PE256 hash support), I also wouldn't mind being able to do that for bootloaders that have been revoked in the .p7b.

That's because, as one would expect, SKUSiPolicy.p7b does contain a bunch of hashes, which you can plainly see by looking at the binary and also can (more or less) nicely convert to the kind of Security Policy XML file they fed to WDAC Wizard to create the .p7b.

You can download the converted XML below:
SKUSiPolicy.zip

Allegedly, all of the ID_DENY_D_#### hashes you can see in the file are the PE256's of the Windows 10 'bootloaders' that Microsoft wants to flag (that sure is a lot for just 1 year of Windows 10 releases, even if you factor in that it's for x86_32, x86_64, ARM64 and(?) ARM. Oh, and don't ask me why some of these hashes are duplicated: it's the .p7b that's duplicating them)... except none of these hashes appear to match the PE256 of Windows 1511's bootx64.efi or bootmgr.efi and I did find some information that, yes, it is really a PE256 that is being used in the .p7b, so it's not a matter of using the wrong hash algorithm (by the way, if you want to compute the PE256 without using PowerShell, I found that you can also use sigcheck with option -h).

Soooo, the question now becomes: What the hell is Microsoft hashing then???

I guess it makes a modicum of sense that Microsoft would not use the EFI hashes, since SKUSiPolicy.p7b is actually referenced from these bootloaders and ideally anything EFI that should be revoked should be handled by the DBX, though of course, if the point is to spare space of the DBX, then by all means WDAC revocation policies should start at the EFI level, including the EFI bootloader that performs WDAC denial.

I have tried to see if winload.exe from boot.wim was the file being hashed, since it's allegedly the first exe that gets executed after exiting EFI, but this appears not to be the case either. And I haven't found any .exe/.dll/.efi on en_windows_10_multiple_editions_version_1511_x64_dvd_7223712.iso itself with a PE256 that appears in SKUSiPolicy.p7b.

So, if anyone wants to pick a post 1507 pre 1607 Windows 10 ISO to play the "What the hell is Microsoft actually hashing in SKUSiPolicy.p7b?" game, feel free to join the "fun"...

@stdin82
Copy link

stdin82 commented Jun 14, 2023

1607 ISO is the oldest i still keep 😀
and i did find PE256 hash for bootx64.efi / bootmgfw.efi / bootmgr.efi in SKUSiPolicy.xml

@pineapple63
Copy link

Been using a 1511 ISO, and haven’t had any luck so far

(And i did verify my Surface Go 3 rejects that ISO when extracted to a USB drive (i copied the files across manually, rather than using Rufus), and in the process of verifying that i screwed up, i wanted to make sure it booted with secure boot turned off, and the device froze when i did that, after force powering it off, and re-enabling secure boot, i was met with a bitlocker recovery screen)

@pbatard
Copy link
Owner

pbatard commented Jun 15, 2023

Goddammit! Why do I always pick the ISOs that Microsoft forgot to add to their deny list?

Can confirm that en_windows_10_multiple_editions_version_1607_updated_jan_2017_x64_dvd_9714399.iso contains bootx64.efi / bootmgr.efi that are in the SkuSiPolicy list. But en_windows_10_multiple_editions_version_1511_x64_dvd_7223712.iso or en_windows_10_multiple_editions_version_1511_updated_feb_2016_x64_dvd_8379634.iso don't.

The thing is, since I wasn't sure whether Microsoft's list was inclusive or not, I deliberately picked 1511 as the "safer" bet, since it's right between 1507 and 1607. And I tested multiple 1511 ISOs I had.

So, once again, it looks like Microsoft screwed up their Black Lotus filtering, even though, in the case of SkuSiPolicy, they don't have to worry about limiting the bootloaders they pick so as not to run out of space.

I sure am starting to grow tired of having to tell Microsoft how to do their job. But at any rate, many thanks to @stdin82 for finding at least one ISO that Microsoft did properly filter out...

@GurliGebis
Copy link

@pbatard since Authenticode was announced back in 1996, I think it is safe to say that the approach to development has changed since then - back then signatures and cryptography was pretty new to most developers.

@Wack0
Copy link

Wack0 commented Sep 8, 2023

Microsoft updated their page about bootloader revocation a couple of weeks ago.

Another round of bootloader revocation will happen in January, with mandatory enforcement starting six months later.

@pbatard
Copy link
Owner

pbatard commented Sep 8, 2023

Thanks. In the meantime, I updated the UEFI:NTFS bootloader (just got the Secure Boot signed binaries today) to detect if we're launching Windows bootmgr and report a more explicit error than No mapping on security issues:

Image1

@Wack0
Copy link

Wack0 commented Sep 8, 2023

Yeah, that message makes sense, there's a function to convert NTSTATUS to EFI_STATUS (as boot application main() returns NTSTATUS) and any NTSTATUS not in the list returns EFI_NO_MAPPING. No NTSTATUS code converts to EFI_SECURITY_VIOLATION, I think this function was written during Vista dev and never touched again.

@pbatard
Copy link
Owner

pbatard commented Sep 8, 2023

any NTSTATUS not in the list returns EFI_NO_MAPPING

I kinda ran into the same issue with the NTFS driver used by UEFI:NTFS where I mapped errno to EFI_STATUS and returned EFI_NO_MAPPING for anything that I didn't know how to map.

As a matter of fact, for some time, I though that Microsoft's EFI_NO_MAPPING might have something to do with bootmgr inheriting an unmapped UEFI error code from the NTFS driver and then returning it as is, which left me wondering if I had screwed up something there...

@Drygord
Copy link

Drygord commented Sep 28, 2023

Umm. So where do I find a bootable ISO that doens't have this error? Windows official download of windows server 2019 gives me this warning in Rufus, and I don't want to deal with this in Q1 2024

@pbatard
Copy link
Owner

pbatard commented Sep 28, 2023

You need to use an ISO that was released after May 2023.

If Microsoft released a Windows Server 2019 ISO after May 2023, just like they re-released Windows 10 and Windows 11 22H2 ISOs, then you should use that. If not, then you need to ask Microsoft if they are planning to release one or temporarily disable Secure Boot during install on a system where the UEFI lock has been enabled, and reenable it after the system has been updated.

From what I could see from testing with the pre 2023.05 Windows 11 ISO, Microsoft seems to ensures that the very first update that gets automatically installed on a newly installed Windows system is updated UEFI bootloaders, so you should usually be able to re-enabled Secure Boot very quickly and temporarily disabling Secure Boot is not the end of the world if you are working with images that you downloaded from a trusted source.

@Ar5had07
Copy link

Thanks. In the meantime, I updated the UEFI:NTFS bootloader (just got the Secure Boot signed binaries today) to detect if we're launching Windows bootmgr and report a more explicit error than No mapping on security issues:

Image1

I just bricked 5 x Surface Laptop 4 (i7/16GBRAM/512GBSSD) that was on Windows 11 and was wiped using the Surface recovery media and now none of them would boot up any OS. I get the following error
image

I tried brand new (just released) versions of both Windows 10 and 11 and neither worked.
SW_DVD9_Win_Pro_10_22H2.12_64BIT_English_Pro_Ent_EDU_N_MLF_X23-61953
SW_DVD9_Win_Pro_11_22H2.13_64BIT_English_Pro_Ent_EDU_N_MLF_X23-59340
image

Does anyone have any suggestions to assist me please? 5 bricked laptops sitting here, can't do anything with it.

@pbatard
Copy link
Owner

pbatard commented Oct 27, 2023

Hmmm, I'm surprised the Oct 2023 updated ISOs would produce that message.
Unfortunately, these are only available for MSDN subscribers, so I cannot test them.

Does anyone have any suggestions to assist me

Temporarily disable Secure Boot before trying to install Windows, and let Windows Update install the updated Windows bootloader (this will come as a priority update after you installed the OS). Once that is done, you can re-enable Secure Boot. Your screen says Secure Boot is in Setup mode though, so I'm not sure about your current Secure Boot status...

@Ar5had07
Copy link

Hmmm, I'm surprised the Oct 2023 updated ISOs would produce that message.

Unfortunately, these are only available for MSDN subscribers, so I cannot test them.

Does anyone have any suggestions to assist me

Temporarily disable Secure Boot before trying to install Windows, and let Windows Update install the updated Windows bootloader (this will come as a priority update after you installed the OS). Once that is done, you can re-enable Secure Boot.

The thing is secure boot is completely turned off. In the screenshot it says 'secure boot : setup'.

I've completely ran out of ideas.

@pbatard
Copy link
Owner

pbatard commented Oct 27, 2023

Maybe, if you haven't tried that, you want to enable Secure Boot then (for third-party CA, not Microsoft CA - you should have 3 options in the menu). UEFI:NTFS is Secure Boot compatible, and I'm curious about whether you get a different message then.

@Ar5had07
Copy link

Maybe, if you haven't tried that, you want to enable Secure Boot then (for third-party CA, not Microsoft CA - you should have 3 options in the menu). UEFI:NTFS is Secure Boot compatible, and I'm curious about whether you get a different message then.

Secure Boot is completely turned off. It's a Surface Laptop, I don't have the options to turn off Microsoft CA. Only the following options:

image
image
image

@pbatard
Copy link
Owner

pbatard commented Oct 27, 2023

Yes, that's what I mean, try with Secure Boot set to Microsoft & 3rd party CA.

@Ar5had07
Copy link

Ar5had07 commented Oct 27, 2023

Yes, that's what I mean, try with Secure Boot set to Microsoft & 3rd party CA.

Tried that as well, same error. :(

image

@pbatard
Copy link
Owner

pbatard commented Oct 27, 2023

Hmmm, I wonder why your Secure Boot status still says "Setup" though... I know some UEFI firmwares are weird, but this means that the EFI Secure Boot variable SetupMode is set on your system, which shouldn't be the case once Secure Boot has been enabled...

@Ar5had07
Copy link

Hmmm, I wonder why your Secure Boot status still says "Setup" though... I know some UEFI firmwares are weird, but this means that the EFI Secure Boot variable SetupMode is set on your system, which shouldn't be the case once Secure Boot has been enabled...

I just tried rufus 4.1p instead of the latest one and this is the new error

image

@pbatard
Copy link
Owner

pbatard commented Oct 27, 2023

From Microsoft's own documentation about Secure Boot:

(When Secure Boot is enabled) Variables must be set to SecureBoot=1 and SetupMode=0

So, if you really did enable Secure Boot, then it looks like Microsoft does not follow its advice to OEMs on their own hardware, because the only way UEFI:NTFS will report Setup is if SetupMode is set.

I just tried rufus 4.1p instead of the latest one and this is the new error

Don't. This is expected, and, as explained above, I changed the nondescriptive [17] No mapping error of previous Rufus versions to something more descriptive. So it is really the same error, with Windows' bootmgr returning code 17, and us, in newer versions of Rufus, translating that error to something more palatable to the user.

By the looks of it, you may want to check if your Secure Boot environment has been properly initialised on your system and if it has, the ask Microsoft why the heck, when enabling Secure Boot on a surface device, it appears that the SetupMode variable is set despite their explicit specification to Secure Boot enabled device manufacturers that it should not be set when Secure Boot is on.

@Ar5had07
Copy link

From Microsoft's own documentation about Secure Boot:

(When Secure Boot is enabled) Variables must be set to SecureBoot=1 and SetupMode=0

So, if you really did enable Secure Boot, then it looks like Microsoft does not follow its advice to OEMs on their own hardware, because the only way UEFI:NTFS will report Setup is if SetupMode is set.

I just tried rufus 4.1p instead of the latest one and this is the new error

Don't. This is expected, and, as explained above, I changed the nondescriptive [17] No mapping error of previous Rufus versions to something more descriptive. So it is really the same error, with Windows' bootmgr returning code 17, and us, in newer versions of Rufus, translating that error to something more palatable to the user.

By the looks of it, you may want to check if your Secure Boot environment has been properly initialised on your system and if it has, the ask Microsoft why the heck, when enabling Secure Boot on a surface device, it appears that the SetupMode variable is set despite their explicit specification to Secure Boot enabled device manufacturers that it should not be set when Secure Boot is on.

Maybe I was wrong when explaining, when SecureBoot is turned off, I get SETUP when I boot from the USB. But when it's turned on (and 3rd party CA enabled) I get ENABLED.
image

@pbatard
Copy link
Owner

pbatard commented Oct 27, 2023

Ah that makes more sense. But then please don't reuse an old picture when attaching an image to state that the behaviour hasn't changed. Either don't attach a picture at all, or, if you do, make sure you do take a new picture.

At any rate, without being able to test this issue, I have no more advice to provide. And to be honest, whereas the message you do get is a message that was added as a result of this topic, your issue, appears to have to do with specific Surface behaviour and should be considered off-topic.

@never-unsealed
Copy link

Are you sure that the hashes in SkuSiPolicy represent PE256 hashes of the revoked binaries? I tried Get-AppLockerFileInformation to get the hashes for some Win 8.1 bootmgr.efi's but couldn't get a match

@pbatard
Copy link
Owner

pbatard commented Oct 30, 2023

The 8.1 bootloader hashes are revoked through the standard UEFI Revocation DBX, on account that revocation through SkuSiPolicy was not yet implemented in 8.1.

As pointed out above, and from the official UEFI documentation:

• Boot Managers from Windows 8 to Windows 10, version 1507: revoked by DBX entries
• Boot Managers from Windows 10, version 1507 to Windows 10, version 1607: revoked by hash by SKU SiPolicy
• Boot Managers from Windows 10, version 1703 to today: revoked by version number by SKU SiPolicy

@never-unsealed
Copy link

never-unsealed commented Oct 30, 2023

Ah my bad, thank you. I still struggle to understand how they managed to get a list of over 2300 binaries for only these few versions (even if the list contains x86\_64 and ARM)

@Wack0
Copy link

Wack0 commented Oct 31, 2023

The skusipolicy indeed contains PE256 hashes.

I checked for example some rs1 bootmgfw hashes and they were in there.

skusipolicy was first implemented in th1 (and originally for applying Surface Hub-specific restrictions), so of course no win8/winblue binaries would be in there!

@Wack0
Copy link

Wack0 commented Dec 25, 2023

MS updated their page again and pushed the third deployment phase back to 2024-04-09, and mandatory enforcement to 2024-10-08 (six months later), thus marking the second time they pushed back the next round of revocation.

@rcmaehl
Copy link
Author

rcmaehl commented Dec 25, 2023

MS updated their page again and pushed the third deployment phase back to 2024-04-09, and mandatory enforcement to 2024-10-08 (six months later), thus marking the second time they pushed back the next round of revocation.

Joy!

@Wack0
Copy link

Wack0 commented Feb 19, 2024

I decided to reverse the dll that does the db/dbx updates, since the new UEFI cert recently appeared in latest Insider builds (dbupdate2024.bin).

It also can handle a dbxupdate2024.bin, currently not present (will probably appear in April updates). Debug strings suggest this would revoke the old PCA 2011 cert entirely.

(the debug strings in question are: "SecureBootNotEnabledForPCA2011RevokeDBX", "GetSecureBootUpdateFilePathPCA2011RevokeDBX", "InsertSecureBootEntryDbxPca2011")

This is gated behind a (registry?) flag. It's currently unknown whether all systems will end up getting the old cert revoked, or whether it'll just be new systems (with preinstalled Germanium), especially considering MS talk (slides, video) which mentions problems like bad OEM implementations not implementing db update correctly (where updating db either does not work at all, or can even brick the system).

@stdin82
Copy link

stdin82 commented Feb 20, 2024

All supported versions got it
https://support.microsoft.com/help/5036210

@Wack0
Copy link

Wack0 commented Feb 21, 2024

All supported versions got it https://support.microsoft.com/help/5036210

This is referring to the db update, not a future dbx update where code is present but the actual update file is not (yet).

@Wack0
Copy link

Wack0 commented Apr 4, 2024

Windows 11 build 26100 now contains dbxupdate2024.bin, which indeed does revoke the PCA 2011 cert (by including the entire cert, not the TBS hash as was done for previous cert revocations to save space).

The interesting thing is that this build is still signed by the old cert (for the most part - a copy of bootmgfw signed by the new cert is present, but it does load and use dbx so the following still applies) - applying this dbxupdate2024 manually would ensure that with Secure Boot enabled, Windows cannot boot at all (for now). (and yes, I'm very much aware that this would be considered a feature to some people, but surely they added relevant certs to dbx manually already?)

I missed that the cert revocation checks in the windows boot environment only checks for hash of cert, and not the cert itself, so the boot environment would ignore the entire cert in dbx and still allow binaries signed by PCA 2011! Which seems incomplete to me, maybe additional revocation lists (skusipolicy, boot.stl etc) will get released on Tuesday...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants