LWN.net Logo

Another approach to UEFI secure boot

By Jake Edge
October 17, 2012

On October 26, Microsoft will release Windows 8. Normally, a release of that kind would be largely uninteresting to Linux users, but Windows 8 branding brings with it a hardware requirement that will definitely impact those wanting to use Linux: UEFI secure boot. Distributions such as Fedora, SUSE, and Ubuntu have been working on their plans for supporting secure boot for more than a year now, so it may be something of a surprise that the Linux Foundation (LF) recently announced its own entrant into the secure boot derby. But the LF "pre-bootloader" is mostly meant as a stop-gap measure for those distributions that have yet to decide on their secure boot strategy.

Secure boot is meant to protect operating systems from pre-boot malware by cryptographically protecting the first step of the boot process. Only binaries signed by keys stored in the UEFI firmware will be allowed to run when secure boot is enabled—which must be the default for certified hardware. On Windows and other systems, the first-stage bootloader will check the signatures of the next steps, but that is not strictly required. Since the keys stored in the firmware are under the control of the hardware makers, it is likely that there will only be keys from Microsoft and the manufacturer stored there. That leads to the distasteful, but unavoidable, need to get bootloaders signed by Microsoft in order to boot on secure-boot-enabled systems.

Much of the hue and cry surrounding secure boot has been about the need for Microsoft-signed bootloaders, but there is little alternative. One could imagine some kind of "Linux certificate authority" that could get its key installed on systems, but that ship has sailed at this point—hardware will be available soon with just the keys from Microsoft and the vendor. Any solution for booting Linux on those systems requires a bootloader signed by Microsoft or disabling secure boot altogether. The solutions vary on exactly what that bootloader actually does.

The "pre-bootloader"

The LF approach is the "smallest piece of code we could think of" that would allow Linux to boot on Windows 8 systems, James Bottomley, member of the LF Technical Advisory Board (TAB), said in email. Bottomley did much of the work on what he calls the "pre-bootloader" that will boot any Linux—signed or unsigned—using a "present user" test. That test ensures that there is a user present at boot time. The pre-bootloader is, of course, signed by Microsoft, but instead of requiring a signature on the next stage of the boot process (typically a full-blown bootloader like GRUB2), it will load and run any code if the user at the keyboard allows it.

Beyond that, if the system is in "setup mode", the pre-bootloader will ask the user if they want the signature of the second-stage bootloader installed into the UEFI secure database. That will allow unattended booting of the system in the future. While it is mandatory under the certification requirements for hardware vendors to provide a way to put systems into setup mode (or to disable secure boot), the user interface to do so is left unspecified. That means there will be several—possibly many—different ways to put systems into setup mode. In order to collect information about these different mechanisms, the pre-bootloader will refer users to an LF web site that will be gathering and disseminating instructions for putting systems into setup mode.

The intent, Bottomley said, is "to ensure that smaller distributions [have] a policy free option they could turn to as an interim solution while they sorted our what their own security policy around secure boot would be". The pre-bootloader binary, once signed by Microsoft, will be available on the LF web site for anyone to use. Distributions that don't want to have their own bootloader signed or, indeed, participate in secure boot at all, will be able to use the pre-bootloader for both live distributions (on CD/DVD or USB devices) and for installations to the hard disk. However, users will either need to get their systems into setup mode and install the second-stage bootloader signature/hash—or be present on every boot.

Requiring users to find and enable setup mode has a minor side benefit, Bottomley said. The information on how to do that will be useful for others, to either permanently disable secure boot or to install their own keys (either in addition to the existing keys or supplanting them). For booting a live distribution, though, testing for user presence should not be that much of a burden.

Shim

There is an alternative to requiring systems to be put into setup mode or for users to be at the keyboard when booting: a pre-bootloader being used by (at least) Fedora and SUSE, called "shim". Shim takes a different approach, but still allows distributions to set their own policies. There are two main differences between it and the LF pre-bootloader, though. Shim can contain an internal keyring for keys used to sign the second-stage bootloader (or just the cryptographic hash(es) of authorized bootloaders), which will be checked in addition to the factory-installed keys. In addition, in its present incarnation, shim will not provide a way to circumvent signature/hash checking with a present user test. According to shim developer Matthew Garrett, there is strong consideration of adding that kind of test for removable media in support of live distributions and installation media, though.

Even a shim that has an internal keyring can support booting binaries that are signed by keys that don't appear on that keyring (and are not present in the firmware). It does that by using an idea that SUSE came up with for storing keys and hashes without requiring users to find and enable setup mode: the "Machine Owner Key" (MOK). It turns out that the UEFI specification provides some secure storage locations that can only be accessed (and, importantly, changed) during the boot process. Shim uses that storage as a place to put keys or hashes if the user directs it to, which avoids requiring user presence on subsequent boots.

Both Fedora and SUSE will be releasing shim binaries that contain their distribution keys on the internal keyring and are signed by Microsoft. Because of the MOK storage idea, though, those binaries could be used by other distributions. Even distributions that are not planning to sign their second stage (and their kernel) could use one of the signed shims. A recently added shim feature will add hashes (rather than just signatures) to the MOK. So a distribution that wants to minimize its dealings with secure boot can simply ship one of those shims and instruct its users to store the second-stage hash in the MOK as prompted by shim. Or those distributions can use the LF pre-bootloader.

Pre-bootloader vs. shim

That last part is a bit of a sticking point, at least for Garrett. Because the pre-bootloader comes with an LF "stamp of approval", it may well be seen as "the Linux solution" for secure boot. But Garrett believes that the pre-bootloader isn't "terribly useful". All of the functionality that it provides is also available in shim, he said, except for the ability to "hit y and it'll run whatever you want". Instead, shim users can just use the interface to add keys or hashes to the MOK and boot unattended forevermore.

There are also some dangers in the LF approach, Garrett said. Because non-technical users are easily fooled into clicking through security warnings, the pre-bootloader could be used to attack Windows:

Users are trained to click through pretty much any security prompt that they see, and if an attacker replaces a legitimate bootloader with one that asks them to press "y" to make their computer work, they'll press "y". If that bootloader then launches a trojaned Windows bootloader that launches a trojaned Windows kernel, that's kind of a problem.

While trojaned Windows binaries aren't directly a problem for Linux, they could be a problem for signed first-stage bootloaders. Secure boot has a database of blacklisted keys and hashes that can be used to stop malware from running on the system. If the LF pre-bootloader is used by some form of malware, it could be blacklisted. That's also true of any shim similarly used, but shim's present user "test" is a bit more complicated than that of the pre-bootloader, so malware authors may be more inclined to target the simpler test.

In any case, signed Linux first-stage bootloaders are clearly at some level of risk of being blacklisted down the road. That risk is inherent in the fact that the secure boot requirements are set by Microsoft to further its own ends. One would guess it won't use its power over the contents of the blacklist indiscriminately, but there is no technical obstacle to it doing so.

An alternative that the LF could have taken would be to create a shim with an empty keyring and get that signed, shim developer Peter Jones said in email. A shim built that way would only run code signed by the keys in the firmware. Since a shim built that way wouldn't have the key or hash for the second-stage bootloader available in the databases it consults, it wouldn't run the second stage, but it would prompt users to add that key or hash to the MOK on first boot. That would allow smaller distributions or those uninterested in signing their binaries to use shim—and avoid the present user test (or setup mode) except for the first boot.

Garrett in particular seems irritated by the LF approach. Because of the uncertainty on how to get systems into setup mode, he believes the pre-bootloader risks making Linux a second-class citizen. In the comment linked above, he warned:

Linux becomes the OS that can't reboot itself. It's the OS that pops up an ugly text entry box every time you turn your computer on. It's the OS that asks you if you're sure you want to run potentially insecure code. 10 years of progress in making Linux accessible to users, gone.

Furthermore, he is unhappy that the LF went its own way, rather than working with Fedora and SUSE on shim. In another comment, Garrett is not particularly pleased with the decision to build a separate pre-bootloader after the TAB had been urged to work together on shim:

We encouraged them to, but they felt that it was too complicated and violated their understanding of the trust model. I obviously disagree, and I'm obviously not impressed by the Linux Foundation picking an approach that's at odds with 100% of the member companies who've voiced opinions on the topic, but the Technical Advisory Board is an autonomous group with no community oversight so there's little opportunity to influence them.

That's not quite the way Bottomley sees things, however. The LF and TAB were "exclusively concentrating on tools that keep linux booting and installing", with an emphasis on the simplest solution. As he noted, "Shim was originally designed as a solution to take advantage of secure boot and enforce a security policy rather than one that simply permits any linux distribution to boot". As a neutral party, at least with respect to distributions, the LF did not want to take sides on what kinds of secure boot policies distributions should choose:

Originally we weren't sure that the distributions would be ready (or at least that the non-major distributions would be ready) for secure boot. Later there were disagreements between distributions over what security policies should be enforced.

It may well turn out that the LF pre-bootloader is simply a temporary measure and that shim can handle all of the different use cases—the LF code uses some parts of shim, after all. Or perhaps the simplicity of the pre-bootloader code will be attractive to some distributions. The pre-bootloader requirement to get the system into setup mode might be attractive to some users or distributions that want to ensure their keys are the only ones present in the system, for example. Bottomley and the LF would be fine with any of the possible outcomes:

The only LF concern is that as an organisation enabling the Linux ecosystem, we don't want to be seen as mandating policy for taking advantage of secure boot. If all distributions decide to adopt shim + MOK, we'd be completely happy, but if some decide not to, that's fine with us too.

Booting Linux on new x86 hardware is clearly going to be a bit more difficult than it has been in the past. Due to a lot of hard work from various folks, though, it will be a lot easier than it could have been. In the end, there is room for both solutions, though there is merit to Garrett's concern that the LF solution will be taken as "the Linux solution" for secure boot. At last report, Ubuntu planned to use its own first-stage bootloader, and other options may arise, so the "one true Linux secure boot solution" may never really exist.


(Log in to post comments)

Another approach to UEFI secure boot

Posted Oct 18, 2012 2:21 UTC (Thu) by mjg59 (subscriber, #23239) [Link]

Ubuntu is currently shipping using shim, albeit an older branch without the MOK functionality (I . The only real difference in security policy is that Ubuntu don't insist on signed modules, which is a policy decision that's made after the bootloader stage.

Another approach to UEFI secure boot

Posted Oct 18, 2012 7:06 UTC (Thu) by ncm (subscriber, #165) [Link]

It seems worth noting that making users answer "are you sure you want to run this possibly insecure thing?" closely resembles the way MS succeeded in killing DR-DOS. Of course nowadays few labor under any illusions about how secure or reliable MS products are. Such a question might only lead people to make sure they weren't accidentally about to start up windos.

Are you sure you want to run this possibly insecure thing?

Posted Oct 20, 2012 3:32 UTC (Sat) by giraffedata (subscriber, #1954) [Link]

I'm not aware of how this killed DR-DOS.

To me, that wording is just pointless because it translates to, "do you want me to do what you just told me to do?" I get that from web browsers all the time - do you want to see the web page you requested or not? Followed by technical jargon that couldn't possibly help any but the most dedicated nerd determine whether there is a security issue with looking at that page.

But I have no doubt we'll see wording like that, and people will just automatically hit "please proceed." The proper wording would be, "You're about to boot something not distributed by Microsoft. If that wasn't your intent, stop now because someone is trying to take over your computer. Otherwise, carry on."

Are you sure you want to run this possibly insecure thing?

Posted Oct 20, 2012 3:52 UTC (Sat) by dlang (✭ supporter ✭, #313) [Link]

Microsoft added text very similar to this warning that running on DR-DOS was unsupported and may cause windows to do bad things.

Per later lawsuits, we learned that Microsoft did this to try and kill of DR-DOS, and to all appearances (including from the Microsoft viewpoint) it worked.

Are you sure you want to run this possibly insecure thing?

Posted Oct 29, 2012 0:13 UTC (Mon) by JanC_ (guest, #34940) [Link]

Well, DR-DOS/OpenDOS is still around as an embedded OS, and some versions are open source even (although FreeDOS is probable more popular as an open source DOS clone).

It's true that they practically killed DR-DOS as a desktop OS to run underneath Windows 9x though. Not sure why, as it was in Digital Research/Novel's best interest to keep it as compatible with Windows as possible, and in any case, the DOS-based line of "Windows" was nearing EOL anyway (in favour of NT-kernel based OSs), so IMNSHO this wasn't a real treat to MS...

Are you sure you want to run this possibly insecure thing?

Posted Oct 29, 2012 9:09 UTC (Mon) by khim (subscriber, #9252) [Link]

Microsoft's fight against DR-DOS started from the beginning (when it undercut prices of CP/M-86 and in 1991-1992 (that's when beta versions of Windows 3.1 which refused to run under DR-DOS were released) DRI was quite alive and well. If course the final blow happened in 1995 (do you know that Windows 95 can be run under DR-DOS with a few patches?), but the "final NT solution" only happened in 2001 when XP was released.

Think about it: ten years! More then enough time for the DRI to push GEM as a "GUI of choice". Sure, this humble message was one tiny episode of said fight, but it was quite real fight, not a staged one.

Another approach to UEFI secure boot

Posted Oct 18, 2012 12:59 UTC (Thu) by and (subscriber, #2883) [Link]

Would it not be easy to extend shim to detect if setup-mode is enabled and place the keys into the UEFI key database in this case, otherwise just keep useing the MOK?

this way, we could get the best of both solutions: people who only want their own keys in the database can have it, the rest of us does not get annoyed too much with the boot process...

Another approach to UEFI secure boot

Posted Oct 18, 2012 14:20 UTC (Thu) by nix (subscriber, #2304) [Link]

I note that the BIOS on my new P8H61-MX Asus-motherboarded desktop machine (which came with a prominent Windows 8 Ready sticker) has a secure boot option but has no visible way to enroll new keys. None. Maybe there is one, but it's not obvious, and the only documentation for this motherboard is a thick manual written in such extreme Chinglish that it is almost entirely incomprehensible, and which is so sketchy that major Asus-specific options you can flip in the BIOS are entirely undocumented (the help for the features in the BIOS itself is also incomprehensible). Naturally secure boot and key enrollment go entirely unmentioned. Thankfully I can turn all this ferociously overcomplicated EFI nonsense off and just boot in BIOS mode, but I don't know if that'll work on the next machine I buy.

(The motherboard's sensors are also unsupported by Linux, so all I get is temperature, even though the sensors can do some sort of intricate variable-speed thing. Apparently Asus refers people asking for programming information to the sensor chip manufacturer, who says it was special for Asus and refers them straight back to Asus again. Great. Asus used to make Linux-friendly motherboards... :( )

So mjg59's feelings about trusting firmware vendors to get this right are quite correct. They won't. They don't.

Another approach to UEFI secure boot

Posted Oct 18, 2012 20:16 UTC (Thu) by Jonno (subscriber, #49613) [Link]

The Windows 8 logo requirements only require the ability to *either* (a) disable secure boot entirely, *or* (b) add your own keys to the DB. Your motherboard seems to support (a) but not (b), which is perfectly all right for Windows 8 logo compliance.

Another approach to UEFI secure boot

Posted Oct 18, 2012 20:35 UTC (Thu) by sfeam (subscriber, #2841) [Link]

Does the requirement make a distinction between "disable secure boot" and "disable UEFI"? It sounds like nix had to do the latter.

How does blacklist get updated?

Posted Oct 18, 2012 15:58 UTC (Thu) by paulj (subscriber, #341) [Link]

Presumably that needn't affect existing machines running Linux? It'd be new machines, shipped with updated blacklists?

How does blacklist get updated?

Posted Oct 18, 2012 16:48 UTC (Thu) by mjg59 (subscriber, #23239) [Link]

Blacklists can be updated at runtime, but if you never install the blacklist package then your machine won't change.

How does blacklist get updated?

Posted Oct 19, 2012 16:22 UTC (Fri) by paulj (subscriber, #341) [Link]

The blacklist has to be signed by MS presumably before it can be installed? You can still just disable SecureBoot though, right? (Until the day MS specify "SecureBoot must be mandatory")

How does blacklist get updated?

Posted Oct 19, 2012 16:32 UTC (Fri) by mjg59 (subscriber, #23239) [Link]

Blacklist updates have to be signed by a key that's present in KEK - in the common case, that'll be Microsoft. And yes, disabling Secure Boot will mean that the blacklist is ignored.

Another approach to UEFI secure boot

Posted Oct 18, 2012 16:22 UTC (Thu) by ballombe (subscriber, #9523) [Link]

Can one build a bootable USB key which also register as an USB keyboard and answer y for you at boot time ?

Another approach to UEFI secure boot

Posted Oct 19, 2012 17:52 UTC (Fri) by sarah (subscriber, #49619) [Link]

That's totally evil, but technically do-able if you have a programmable USB device. However, most USB mass storage devices aren't reprogrammable at that level. Requiring users to buy some random dev board off of sparkfun in order to install their new Linux OS is just not going to work, socially.

Another approach to UEFI secure boot

Posted Oct 19, 2012 21:23 UTC (Fri) by alonz (subscriber, #815) [Link]

On the other hand, getting people to boot off random USB sticks (e.g. found on the subway) is not hard… And with a bit of innovative engineering, these sticks may now be more than they seem.

Another approach to UEFI secure boot

Posted Oct 18, 2012 17:58 UTC (Thu) by Jandar (subscriber, #85683) [Link]

Is there a way for network-boot with shim or pre-bootloader? In http://www.intel.com/technology/itj/2011/v15i1/pdfs/UEFI-... a PXE-boot is mentioned but I'm not sure if shim et al. can load the next stage from network.

Another approach to UEFI secure boot

Posted Oct 18, 2012 18:10 UTC (Thu) by mjg59 (subscriber, #23239) [Link]

Another approach to UEFI secure boot

Posted Oct 19, 2012 11:20 UTC (Fri) by wookey (subscriber, #5501) [Link]

Has anyone done any work in all this to address the core issue of microsoft being the only one to put 'core keys' (whatever EUFI calls those) on systems?

If I am manufacturing hardware and don't care about running Windows on it (lets say it's not supported), but would like to be able to do Linux secure boot - can I go to the Linux Foundation for a standard key? Presumably I could add my own, but then I have to get distros to include that key in their bootloaders/kernels? Or can I just provide a corresponding signed version of shim which then separates the rest of the boot process into a different key-space.

What is the time overhead of all this dicking about through multiple bootloaders? If I'm making automotive linux I'm very interested in having secure boot working, but I also have really harsh boot-time requirements. These things seem likely to be in conflict.

Another approach to UEFI secure boot

Posted Oct 19, 2012 16:05 UTC (Fri) by mjg59 (subscriber, #23239) [Link]

> Has anyone done any work in all this to address the core issue of microsoft being the only one to put 'core keys' (whatever EUFI calls those) on systems?

Yes.

> can I go to the Linux Foundation for a standard key?

No. It turns out to be expensive to run a CA.

> Presumably I could add my own, but then I have to get distros to include that key in their bootloaders/kernels?

The loaders don't contain keys (at least not in the sense you're talking about), but unless you've signed those loaders your firmware isn't going to boot them.

> What is the time overhead of all this dicking about through multiple bootloaders?

Minimal.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds