-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Secure boot support #4371
Comments
See this message the further down the thread. In short: just signing bootloader and/or Xen isn't enough, and would result in something trivial to bypass (for example using kernel parameters). |
@marmarek so the bootloader should check the next piece in the boot-chain as well as as all the parameters. Wouldn't it be possible to enforce code signing throughout dom0 similar to Windows 10S? |
Parameters are different for each installation, so you need to sign them yourself. Read that thread. And BTW just setting up SecureBoot as a protection against someone with physical access (replacing /boot etc) isn't enough. One can simply disable SecureBoot and you'll most likely not notice. On some systems it might be non-trivial without a BIOS password (re-flashing BIOS etc), but still very much doable with physical access. On the other hand, AEM-like solution guard against this kind of attacks too, because it doesn't rely on BIOS to prevent the boot if something goes wrong. Instead, TPM will not release keys if you boot different binary. While there are different ways to bypass BIOS refusal to boot, you can't fake to the user data decryption if you don't have a key. Anyway, those mechanisms are not excluding each other. Right now AEM is not compatible with UEFI, so getting either of them implemented would be an improvement. |
Indeed a TPM would be necessary to provide meaningful protection. It measures the UEFI firmware data, settings, secure boot state and provisioned signing keys prior to releasing (part of) the decryption key. |
Notes how kernel signing is done in Fedora build infrastructure:
PESign tool (including
In short: kernel build environment is given access to the signing key through a bind-mounted unix socket. It may be doable to replicate similar setup in our build infrastructure (with appropriate logging what gets signed). |
As part of adding Qubes support to safeboot, I have a preliminary patch for Xen to build a unified With this modification there is no need for grub -- the UEFI firmware can validate the signature on the hypervisor bundle using the SecureBoot PK/KEK/db key chain and directly invoke it if-and-only-if the signature is valid. Although, as @marmarek pointed out in #4371 (comment), it is also necessary to use a TPM sealed secret that includes the platform key and secure boot DB to be able to prevent a local attacker from reflashing with Secure Boot disabled. The tpm2-attest part of safeboot can likely be ported to dom0 for remotely attesting this, although I haven't gotten that far yet in the Qubes support. |
Thanks, this looks very promising! I have two main issues with using xen.efi in general:
Those two are UX and stability related issues, not necessary security related. But for anything to be considered into default installation, those are also very important. Although for non-default, for power-users only solution those are less critical. As for security concerns mentioned earlier in this thread, I understand your approach requires each installation to use unique, user-owned keys to sign boot files and have them included into secure boot DB, right? With this assumption it should be fine. Just to be sure I haven't missed anything - there is no way to stretch this approach into something compatible with standard secure boot DB keys (MS-signed shim), right? |
Bundling definitely avoids having to figure out the file system APIs and also makes it possible to embed in a ROM firmware volume, if you're lucky enough to have that option. Choosing between versions can be done with the UEFI boot manager, although this doesn't allow changing parameters. Modifying the boot parameters is challenging, although that is somewhat intentional - since the kernel parameters and xen config are critical to security, allowing arbitrary changes by a local user/attacker is dangerous. On the (non-Qubes) safeboot systems, the configuration is to have separate EFI boot manager entries for This does require a bit more space on the ESP since the recovery and normal kernel can't share bzImage or initrd files, although that hasn't yet been a problem for the machines I've configured. |
For the general use case, it might be workable to have the install image signed with the distribution key and to have that key signed by Microsoft so that the installer can boot. If they don't change the defaults, they can continue to use the official kernel, initrd and config as signed by the Qubes key. If they do want to use their own keys, perhaps during the setup the user could be prompted to setup a software or hardware key and point them towards the steps for enrolling these keys in their firmware. Then they would need to use to sign any new kernels or initrd images that they build for the dom0, as well as any xen upgrades. With safeboot it isn't seamless right now; you can boot into recovery, install updates, and then have to run a separate command to re-sign everything. This would likely only be beneficial for very |
Yes, definitely. I'd imagine modifying those would change some measurement and require disk recovery key (in case TPM unseal is used later) or require disabling SB in the firmware. But still possible without external tools. Primary + recovery boot images should solve most of it, I think. As long as the user have real option to choose which one to boot - note many UEFI do not expose such menu, notably default UEFI in Thinkpads do not have it. In that case, some extra boot manager is needed.
This is a bit problematic, because dom0 kernel cmdline and initrd (currently) do contain system-specific configuration. At least UUID of LUKS partitions to unlock and where to look for root filesystem. Remember we (currently) allow quite a bit of flexibility in disk layout (lvm/btrfs etc) so we can't easily hardcode defaults and in some cases even runtime detection may be challenging and lead to not finding the right partition.
How would that work with distribution key? The distribution-signed blob can't possibly include sealed secrets for particular TPM and PCR values... Or perhaps the sealed keys are included in the signed part? How are they loaded then? |
My Thinkpad X1 (gen 5 and 6) and T490 offer EFI boot manager support -- hit F12 when the Lenovo screen is displayed to bring it up, or hit Enter and then select Boot Manager from the menu. I haven't looked deeply at other systems, so I'm not sure how common it is to have it hidden. With Handling the TPM sealed secrets in the distribution key case is a little trickier; the signed PCR technique wouldn't work since you don't know what the PCRs are supposed to be other than the unified xen file. There is a fall back technique of sealing based on the current PCRs and storing the sealed data in the TPM NVRAM, however, it would require the disk recovery key to be available for every update since the new xen/kernel/initrd will change the measurements. That's not wonderful from a user perspective since they will need both the UEFI key (hardware token) as well as the disk recovery key in order to do an update. If dom0 is running without lockdown, then potentially the current key can be retrieved from the running kernel, although that opens up some other security concerns... |
Qubes uses LVM names too. I'm referring to the LUKS partition UUID. |
As a proof of concept I have Qubes 4.1 booting with a unified Xen 4.13 on real hardware, where the hypervisor, vmlinuz, initrd, and configuration are signed with my own Yubikey. The
For the initial install I signed my own version of the DVD, which worked for the first phase, but the reboot to finalize the install failed since the xen it installed into the boot partition was not signed. So I turned off secure boot, booted into Qubes to finish the install, then rebooted into running Qubes, unified+signed the resulting kernel and initrd, and then turned secure boot back on. Not the easiest workflow... I think it can be made doable for casual users if there is a way to not include the |
I don't think IOMMU parameters to the dom0 kernel makes any difference - IOMMU is managed by Xen.
Theoretically we can configure installer to use constant UUID. But we risk collisions then... Another thing that is installation-dependent (either on kernel cmdline, or built into initramfs) is the keyboard layout to use during LUKS passphrase prompt. There can be few more similar options.
Currently yes (includes a bunch of configs from the target system), but I think it can be made generic quite easily (at least
Have you booted it from real DVD, or USB stick? I guess the latter. The ISO9660 format has limitation of 32MB for EFI boot partition. Fitting Xen+Linux+initramfs there was a major PITA. Now we can use grub2-efi to load some of the files from other place. Can you confirm the unified efi binary will also work this way (with either signed grub2-efi or shim+grub2-efi)? |
I've only booted from a USB stick; haven't had a physical DVD in years... The EFI executable should work from grub, although I don't have an easy way to test that on my system. The additional configuration could go into EFI variables if they are not sensitive (in either sense), with some well tested parsers in the initrd. For instance with the change to add signed PCR policy, safeboot stores the signature in a UEFI variable (osresearch/safeboot#58). If an attacker changes it, the worst they can do is prevent the TPM from unsealing the disk key (the size is limited and the data is a raw binary signature). There are other things that are nice to have, like rollback protection, which required storing counters in the NVRAM (so that the secrets can be unsealed by newer signed images, but not by older ones) (osresearch/safeboot#62). If the configuration values are sensitive, putting sealed blobs into NVRAM variables and using the TPM to unseal them is another option, although that does add an additional hardware dependency into the mix. |
The unified Xen patches are making their way through the xen-devel mailing list after several revisions and comments from the developers. https://lists.xenproject.org/archives/html/xen-devel/2020-08/msg01735.html Backporting the fixes to the Xen used in Qubes 4.1 (and even 4.0) is quite easy since there isn't a huge amount of churn in the EFI boot path. Even if the Qubes distribution doesn't use the UEFI Secure Boot aspects, having the unified patches built into the mainline Qubes xen-vmm module would make it possible for advanced users to enable it for their own machines without having to rebuild the hypervisor. Also, there was quite a bit of discussion about what Secure Boot compliance would mean for Xen overall. There are quite a few features that need to be turned off in order to avoid a local attacker from modifying the hypervisor. Andrew Cooper wrote in https://lists.xenproject.org/archives/html/xen-devel/2020-08/msg00290.html:
I think the Qubes audience doesn't need or want a strict Microsoft-definition of Secure Boot, and hope that with these patches plus some configuration updates it will be possible for users to better protect their systems. |
Yes, if there are no major incompatibilities, we can definitely do that.
Yes, exactly. While having Microsoft-signed boot binary (whether with shim or some other solution) would ease installing Qubes on UEFI-enabled systems, it doesn't much affect the security aspect compared to your own keys - in fact, using own keys may be even better option (for example without grub and trusting MS keys we avoid issues like BootHole). |
The unified Xen hypervisor patches have finally made it through the mailing list and have almost all been pushed to staging! https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=8a71d50ed40bfa78c37722dc11995ac2563662c3 For a backport, do you prefer the individual commits (there are six patches in total) or is a single squashed patch easier? |
Congratulation! |
There were a few modifications required to back port it due to |
@osresearch @marmarek :
And then we compare the content of the filesystems, we see that:
Would need to be out of root fs to be able to have a RO QubesOS dom0 with dmverity |
@marmarek @osresearch input on #4371 (comment) ? |
Personally I would be fine with moving these off of the root filesystem. |
I've submitted PR with initial Qubes OS support. Tested with Lenovo X1C6/C7 |
Question: will the installer of Qubes also support secureboot? when I try to boot from an usb-stick (made with the iso-image of qubes-4.1) grub on the usb-stick doesn't get started; when I try it with a non-secureboot-laptop it starts fine. since I want to use it an a secureboot-laptop I'd very much interested in having this feature ;) I am willing to test it too, so if you have a modified ISO I shall test I am happy to do this. I already installed Debian on that system which kernels (and apparently installer) are secure-boot able if you choose "Microsoft and 3rd party certificates" as parameter. |
I'm not sure if this is the correct issue for the question about signed binaries. We integrated the new UEFI Secure Boot menu layout, according to @marmarta suggestions, in Dasharo. Documentation is here. It most likely will be part of Dasahro for FidelisGuard and NitroPC v1.1.3. As we discussed during Qubes OS Summit 2023, we would like to include Qubes OS Certificates in the release when you are ready to deliver signed binaries. My point is to align the Dasharo release (I assume it will be something after v1.1.3) with the date when the Qubes OS Team will have provided a certificate, which we would be able to use for UEFI Secure Boot of Qubes on Dasharo-supported hardware. Are there any known/planned dates when that may happen? |
There are two ways to to frame Secure Boot:
More videos on the topic of measured boot:
Secure Boot is trust anchored in the EFI firmware. User's adding custom keys cannot be automated unless hardware would be sold with Qubes' key added by default to the firmware. Measured Boot is trust anchored in the TPM. I don't specifically trust either chip. Coreboot, TrustedGRUB, Evil Maid, TPM, Secure Boot, Boot Guard, Heads, Librem Key, PureBoot... Confused? Rightfully so. Check out this blog post which explains them all: [1] BIOS replacement that comes by default nowadays. |
Measured boot with an SRTM chain is very complex and hard to prove; what is more, it is as good as the first measurement. Code-making, the first measurement, has to be trustworthy, maybe even immutable, and protected by some root of trust (Intel Boot Guard?). A measured boot with DRTM could be much better, but it also has some limitations.
The mechanism of UEFI Secure Boot is implemented in UEFI BIOS, but if that mechanism is implemented correctly (Dasharo OSFV) can validate that, then the best use of UEFI Secure Boot is to give power to the users and give them tools to own their boot process by signing kernel and all relevant parts. Of course, that may be too complex for many, and we can make shortcuts like shipping hardware with Qubes OS keys. Or shipping hardware with keys allows the reprovision of UEFI Secure Boot from OS by the person who ordered hardware, which is probably available only for Qubes OS Certified Hardware.
I like this article, but as you can read my comment, there are some misconceptions. I would love to discuss this issue more during Dasharo Developers vPub in March. CfP is here, so if anyone could help me drive the discussion I would appreciate that. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Friendly reminder to everyone that this issue tracker (qubes-issues) is not intended to serve as a discussion venue. Instead, we've created a designated forum for discussion and support. By contrast, this issue tracker is more of a technical tool intended to support our developers in their work. Comments on this issue (#4371), in particular, should be focused on actionable information regarding Secure Boot support in Qubes OS. Thank you for your understanding. |
Since f0f51c86ab7dfbab52ba4b840392bffbe93c6530 commit in grub2 repository, the grub2 package includes default "BOOTX64.efi" file, which conflicts with the shim package. For now simply skip installing shim, as it is unused, but when implementing UEFI SecureBoot support (QubesOS/qubes-issues#4371), this (and the grub change) will need to be reverted.
I downloaded 4.2.3-rc1, moved the content to a *.img file, signed error: shim_lock protocol not found.
error: you need to load the kernel first.
error: you need to load the kernel first.
Press any key to continue... This is expected because there is no shim in the image. When I tried to use the Ubuntu one in hand, I noticed Shim could not correctly chain to Grub, stating a security violation despite DB having a key that signed Grub, and Grub loads directly without problems. I'm not an expert here, but the shim I'm using supports SBAT, but apparently, Qubes OS GRUB2 does not. Chainloading by Shim Grub from Ubuntu signed with my key works without issues. Of course, I'm stripping signatures first with There are essentially two main issues:
|
The default installation loads multiboot2 binary (xen.gz) that doesn't support signing. There are some attempts to pack MB2 binary into PE binary to be signed, but that's not what we decided to do. Our current plan is to build an unified xen.efi binary and sign that (see #8206). |
I would be glad to experiment to deliver status at the summit and continue during the hackathon. I guess it is closely related to trying queso-builderv2. Would it be sufficient to build just that one package, or is there some dependency hell I cannot see right now? The second question is still open. Does it make sense to return to open safeboot contribution, assuming I have installed Qubes OS with disabled UEFI Secure Boot and would like to convert it to enabled UEFI Secure Boot as Trammel did with 4.1? |
According the secure boot specification, users can enroll their own keys for secure boot.
If the QOS bootloader were signed, users could manually enroll the signing key within the UEFI. That would be a better anti evil maid system since it doesn't require the use of potentially untrusted USB keys.
Since dom0 doesn't contain any 3rd party applications, we can enforce code signing on anything that runs within it.
This blog post mentions secure boot being problematic due to running CA's etc but providing the user with a public key they can enroll manually would be doable.
Edit: I'm aware the developers are generally not very fond of secure boot. Could anyone explain why?
Alternatively a TPM could be used to unseal the drive encryption key.
The text was updated successfully, but these errors were encountered: