|
|
Subscribe / Log in / New account

Supporting UEFI secure boot in Debian

By Jonathan Corbet
October 10, 2016

Kernel Recipes
The Debian project can be accused of many things, but jumping too quickly on leading-edge technology is not one of them. That can be seen in, among other things, the fact that there is still not a version of the distribution that supports the UEFI secure boot mechanism. But, as Ben Hutchings explained during his 2016 Kernel Recipes talk, such support is in the works, and it will be implemented in a uniquely Debian-like manner.

Hutchings started by reviewing how the secure boot technology works. On systems with secure boot, the UEFI firmware is able to validate the system's bootloader by checking its signature against a list of trusted [Ben Hutchings] keys; it can also validate UEFI drivers and firmware updates. This checking is intended to defend the system against persistent malware by ensuring that the system's low-level software has not been tampered with. Support for secure boot is mandatory for systems that will run Windows, so all desktop systems sold since 2012 have it. It is possible to build in trust for multiple signing keys but, in practice, the one key that is trusted by everybody is Microsoft's key.

To boot Linux on a system with secure boot enabled, the first stage bootloader must have a Microsoft signature; in the Linux world, that is usually the special "shim" utility. Distributors create their own signing key, which they then build into shim; that key is then used to verify the GRUB installation. GRUB, in turn, verifies the signature for the kernel image; the kernel must validate any modules that it loads. By checking for proper signatures at every stage of the boot process, the system can be protected against hostile software modifications.

Supporting secure boot requires some fundamental changes in how Linux systems work. Traditionally, the root account can run arbitrary code, but that cannot be allowed under secure boot; even root should be unable to fully take over the system. To keep that from happening, the module loader must check signatures on kernel modules. The "kexec" mechanism must be prevented from booting into an arbitrary, unsigned image. Various I/O devices that are capable of modifying arbitrary memory must be disabled. The hibernation mechanism must be disabled entirely, though future work could, by signing and verifying the hibernation image, make that work again. Debian will be using Matthew Garrett's patches that make these changes; the patches are still not upstream and may never be, though, since certain high-profile kernel developers dislike them.

The Debian way

The commonly-used approach of signing the kernel image creates some problems for Debian, though. The project's practice with signatures has been to sign metadata describing software, never the code itself. Debian does not want to put signing keys onto its "buildd" systems; those systems are distributed around the globe and present any number of ways in which the keys could be exposed. Debian is also committed to reproducible builds, which cannot depend on secrets (or they would no longer be reproducible).

As a result, Debian cannot automatically build signed kernel binaries in a single step. Instead, the process starts with the creation of an unsigned binary. The signature for that binary is then created offline and a second source package is created to contain it. A second-stage build then rebuilds the kernel binary and applies the signature to it, resulting in a new package with a fully signed kernel binary. As long as the build is truly reproducible, the signature will still apply to the recreated binary. This mechanism allows anybody to create a signed Debian kernel image — as long as it precisely matches the kernel that was created by Debian itself.

Some changes to the Debian Archive Kit (dak) software, which signs archive metadata, will be needed, since it now needs to be able to publish detached signatures too. It may be necessary to publish the signature without publishing the accompanying binary immediately; this could happen in response to an embargoed security issue, for example. There is a script that turns a tarball of EFI binaries (and kernel modules) into a tarball of signatures, which are then installed into the archive metadata. The source package for the initial build is changed to include this tarball, along with a preparation script used by the second-stage build.

Some might wonder whether Ubuntu had already done this sort of work. Ubuntu's solution doesn't work for Debian, though, for a number of reasons, starting with the fact that Ubuntu's package builder doesn't use dak. Ubuntu's signing script only covers EFI binaries, leaving modules unsigned; it also creates signed binaries directly instead of using the two-stage signing process that Debian requires. Ubuntu only supports the amd64 architecture; Debian wants to support all architectures where secure boot is relevant. One other little complication is that the Ubuntu and Debian kernel packages have diverged significantly over the last ten years. The two projects do share some of the utilities, though, including shim and the grub-signed bootloader.

What about the ARM architecture? The upstream kernel has EFI stub support for both 32-bit and 64-bit ARM systems. Debian has out-of-tree securelevel patches that work for arm64; other tools, including sbsigntool, [Julian Cristau] shim, and the GRUB EFI code, also work there. So it should be possible to support arm64 systems under secure boot, at least. The smaller ARM systems that feature secure boot are locked down and will only run Microsoft software, but that should be less of a problem in the server space.

Julien Cristau stepped up briefly to talk about how signing keys will be managed as this whole thing goes into production. Once again, the Ubuntu example is only so helpful for Debian. Ubuntu has its own data center, under its control, with the result that it has relatively good security for its machines. Debian lacks this data center, depending instead on machines hosted in various places around the world; it can thus never have as good a handle on the security of those machines. Signing keys will need to be kept in a hardware token, such as a YubiKey device. Patches are in the works to make all of this work in a secure manner.

Where things stand

Hutchings came back to summarize the status of this work; the current state of affairs can also be found in the Debian bug tracker as bug #820036. The changes to dak are in progress, and can be expected soon. The shim package is done, and is in review; there is still a need to put together a signed GRUB build. The signed build for the kernel is ready to go, but a signed build for the fwupdate utility is not ready yet. The installer and live images are ready to work with signed binaries, as is the support to actually install it all. The target for this work is the Debian 9 ("Stretch") release, which goes into freeze in January. More information can be found on the Debian secure boot wiki page.

The first question from the audience had to do with the UEFI signing key: would it be possible to use a separate key and avoid the need for Microsoft's signature? There is some appeal to that approach, but it has a big disadvantage: users would would have to install the new key in their firmware. There are a lot of different firmware implementations out there, each of which has its own horrible interface for key installation. Creating documentation to get Debian users through that process would not be fun.

Why is Debian only coming out with secure boot support now? Hutchings responded that the project has wanted this support all along, but has obviously been slow in implementing it. There has been a lot of talk about how to do it, but nobody actually got the work done. As a result, it's still not possible to install Debian without disabling secure boot in the firmware. That is about to change, though, now that support for secure boot is almost ready.

The final question suggested that, if Debian were to continue to not support secure boot, that might force vendors to make the feature easier to do without. Hutchings's response there was a dry "it's still not the year of the Linux desktop"; he does not believe that Linux distributors can push desktop hardware vendors around in that way.

[Your editor thanks Kernel Recipes for supporting his travel to this event.]

Index entries for this article
SecurityDistribution security
SecuritySecure boot
ConferenceKernel Recipes/2016


to post comments

Supporting UEFI secure boot in Debian

Posted Oct 10, 2016 15:33 UTC (Mon) by rahvin (guest, #16953) [Link]

It's good to see this finally coming but I'm one of the people that appreciates that Debian is methodical about these type of changes even if it takes longer.

Supporting UEFI secure boot in Debian

Posted Oct 10, 2016 16:16 UTC (Mon) by josh (subscriber, #17465) [Link] (2 responses)

> Debian lacks this data center, depending instead on machines hosted in various places around the world; it can thus never have as good a handle on the security of those machines.

This seems like a misleading statement, especially in the context of buildd systems that build software for Debian.

The problem is *not* with keeping those systems secure from malicious attacks; if that were a problem, users couldn't count on the resulting packages.

The problem is that the information on those systems can't be kept *secret*. Too many people would have access to the signing keys.

Hence the solution of the Debian kernel maintainers creating the signatures offline, using keys on hardware crypto tokens.

Supporting UEFI secure boot in Debian

Posted Oct 10, 2016 20:26 UTC (Mon) by xtifr (guest, #143) [Link]

Ah, thanks. I was a little confused about that part. But when you put it that way, it makes perfect sense.

Supporting UEFI secure boot in Debian

Posted Oct 10, 2016 21:30 UTC (Mon) by jcristau (subscriber, #41237) [Link]

No, that's not what I was talking about. The kernel maintainers creating the signatures is a temporary stopgap while we sort out signing by the archive software. The key Ben currently uses is not trusted by any firmware, and doesn't cover grub and other packages. But before we go and sign bootloaders automatically we want to make reasonably sure we notice any tampering with the key, which having the key unencrypted on-disk on a host connected to the internet (ftp-master.debian.org) wouldn't provide, hence the HSM.

Supporting UEFI secure boot in Debian

Posted Oct 10, 2016 21:58 UTC (Mon) by micka (subscriber, #38720) [Link] (6 responses)

So if I understand...

> Instead, the process starts with the creation of an unsigned binary.

So one unsigned kernel package, the same as currently (?). Reproducible provided we can find all variation sources.

>The signature for that binary is then created offline and a second source package is created to contain it

So one second package. If the first was kernel-image_XXXX, this one would be kernel-image-sig_XXXX or whatever.
What is the 'reproducible' status of this one? Do we abandon the reproducibility?

> A second-stage build then rebuilds the kernel binary and applies the signature to it, resulting in a new package with a fully signed kernel binary

I'm begining ot be a bit lost. This is a new package which source(?) are the other previous binary(?) packages?

>As long as the build is truly reproducible, the signature will still apply to the recreated binary.

So we have reproducibility provided the second package (signature) is reproducible?

(I'm sorry if there are so many question marks, those are the points that wasn't able to clear by myself)

Supporting UEFI secure boot in Debian

Posted Oct 11, 2016 0:18 UTC (Tue) by BenHutchings (subscriber, #37955) [Link] (5 responses)

So one unsigned kernel package, the same as currently (?). Reproducible provided we can find all variation sources.

Same source package, linux. The reproducible builds project now shows it as unreproducible, but only because they now vary the source directory. We can make it insensitive to the source directory once gcc supports path remapping in the preprocessor.

So one second package. If the first was kernel-image_XXXX, this one would be kernel-image-sig_XXXX or whatever.

The second source package is linux-signed. It contains the detached signatures for all the binary packages that get signed.

What is the 'reproducible' status of this one? Do we abandon the reproducibility?

It's reproducible.

Supporting UEFI secure boot in Debian

Posted Oct 11, 2016 22:18 UTC (Tue) by st (guest, #96477) [Link] (4 responses)

To clarify, is the signature itself reproducible without possession of the necessary secret, or is the signature not reproducible, but the package that gets built from the signature source package the part that's reproducible?

Supporting UEFI secure boot in Debian

Posted Oct 11, 2016 22:23 UTC (Tue) by BenHutchings (subscriber, #37955) [Link] (3 responses)

The latter.

Supporting UEFI secure boot in Debian

Posted Oct 12, 2016 7:09 UTC (Wed) by micka (subscriber, #38720) [Link] (2 responses)

So anyone can't validate that the build is reproducible?

Supporting UEFI secure boot in Debian

Posted Oct 12, 2016 7:25 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link]

You can do a local rebuild and validate that you have the same bits as in the signed kernel. But you will not be able to replicate the signature itself.

Supporting UEFI secure boot in Debian

Posted Oct 12, 2016 7:26 UTC (Wed) by chirlu (guest, #89906) [Link]

You can verify the signature, can’t you? You can’t reproduce it yourself, though, as you lack the key.

Supporting UEFI secure boot in Debian

Posted Oct 14, 2016 3:02 UTC (Fri) by giraffedata (guest, #1954) [Link] (8 responses)

I've been trying to figure out UEFI secure boot since LWN started writing about it in 2011.
Support for secure boot is mandatory for systems that will run Windows, so all desktop systems sold since 2012 have it.

What is "support for"? Does it mean the system must refuse to run an unsigned boot loader? Or maybe that it must be possible for the user to configure it so?

Have there been any computers made since 2012 that can run both Windows and Debian, and if so, will they run Debian out of the box?

Supporting UEFI secure boot in Debian

Posted Oct 14, 2016 12:33 UTC (Fri) by tao (subscriber, #17563) [Link] (7 responses)

No, it means that the BIOS/Firmware must have *support for* (not exactly hard to figure that one out) secure boot. Not that it has to *only* support secure boot.

My current laptop, purchased this spring, is a ThinkPad 13. Works perfectly with Debian out of the box (and seeing as it came installed with Windows I'm gonna assume that Windows works on it too). My collection of Intel NUCs work just fine with Debian out of the box. The ThinkPad X1 Carbon I have at the office works just fine with Debian. etc..

TLDR:

That it gives the option to use secure boot, no, yes, yes.

Supporting UEFI secure boot in Debian

Posted Oct 14, 2016 15:17 UTC (Fri) by giraffedata (guest, #1954) [Link] (6 responses)

OK, then what is the point? If your computer came with Windows, but willing to run Debian once you installed it, and according to this article, Debian today does not spring from anything signed by Microsoft, then what is to stop a worm running on Windows from changing the boot loader to something malicious and running a compromised Windows?

"Support," by the way, is used to mean half a dozen things in the computer world, most not consistent with the traditional dictionary definition of that word. One has to ask.

Supporting UEFI secure boot in Debian

Posted Oct 14, 2016 17:03 UTC (Fri) by zlynx (guest, #2285) [Link] (5 responses)

First enter the firmware configuration and disable Secure Boot. Every machine I've used lately supports this.

On a brand new system you may need to boot Windows in order to reboot to firmware configuration because Fast Boot is on. If you can't get to options even then you can download software to directly edit EFI variables.

Supporting UEFI secure boot in Debian

Posted Oct 14, 2016 17:20 UTC (Fri) by giraffedata (guest, #1954) [Link] (3 responses)

First enter the firmware configuration and disable Secure Boot.

OK, I understand that. (But it's not what I meant when I asked about "out of the box.")

There was talk when UEFI secure boot was new that computers would not have that option, i.e. that Microsoft would not let its products run on machines that let the user disable it.

I am glad to hear it ended up this way. The world makes more sense now.

If you can't get to options even then you can download software to directly edit EFI variables

But this gets back to the "what's the point" area, depending on what exactly it means. If you can download and run software under Windows to directly edit EFI variables and turn off secure boot, then that's exactly what a virus would do.

Supporting UEFI secure boot in Debian

Posted Oct 14, 2016 17:44 UTC (Fri) by zlynx (guest, #2285) [Link]

I was thinking of disabling Fast Boot. If the firmware lets you edit Secure Boot that would be a problem.

Supporting UEFI secure boot in Debian

Posted Oct 14, 2016 19:40 UTC (Fri) by jem (subscriber, #24231) [Link]

>There was talk when UEFI secure boot was new that computers would not have that option, i.e. that Microsoft would not let its products run on machines that let the user disable it.

On x86 you are able to disable Secure Boot, on ARM you are not. Both are requirements from Microsoft for Windows logo certification.

>But this gets back to the "what's the point" area, depending on what exactly it means. If you can download and run software under Windows to directly edit EFI variables and turn off secure boot, then that's exactly what a virus would do.

That's not possible. The firmware must be implemented so that "physical presence" is required to disable secure boot.

Supporting UEFI secure boot in Debian

Posted Oct 17, 2016 17:43 UTC (Mon) by pjones (subscriber, #31722) [Link]

Just directly editing variables won't let you disable Secure Boot unless you happen to know the system vendor's (or Microsoft's) private RSA2048 key.

Supporting UEFI secure boot in Debian

Posted Oct 31, 2016 19:08 UTC (Mon) by JanC_ (guest, #34940) [Link]

Also, usually you can get into the the firmware configuration even when Fast Boot is on if it can't find a bootable disk (otherwise you would be in trouble if your hard disk ever fails).


Copyright © 2016, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds