Matthew Garrett ([personal profile] mjg59) wrote2012-08-16 12:12 pm
Entry tags:

Building personal trust with UEFI Secure Boot

The biggest objection that most people have to UEFI Secure Boot as embodied in the Windows 8 certification requirements is the position of Microsoft as the root of trust. But we can go further than that - putting any third party in a position of trust means that there's the risk that your machine will end up trusting code that you don't want it to trust. Can we avoid that?

It turns out that the answer is yes, although perhaps a little more complicated than ideal. The Windows 8 certification requirements insist that (on x86, at least) the key databases be completely modifiable. That means you can delete all the keys provided by your manufacturer, including Microsoft's. However, as far as the spec is concerned, a system without keys is in what's called "Setup Mode", and in this state it'll boot anything - even if it doesn't have a signature.

So, we need to populate the key database. This isn't terribly difficult. James Bottomley has a suite of tools here, including support for generating keys and building an EFI binary that will enrol them into the key databases. So, now you have a bunch of keys and the public half of them is in your platform firmware. What next?

If you've got a system with plug-in graphics hardware, what happens next is that your system no longer has any graphics. The firmware-level drivers for any plug-in hardware also need to be signed, and won't run otherwise. That means no graphics in the firmware. If you're netbooting off a plug-in network card, or booting off a plug-in storage controller, you're going to have similar problems. This is the most awkward part of the entire process. The drivers are all signed with a Microsoft key, so you can't just enrol that without trusting everything else Microsoft have signed. There is a way around this, though. The typical way to use Secure Boot is to provide a list of trusted keys, but you can also provide trusted hashes. Doing this involves reading the device ROM, generating a SHA256 hash of it and then putting that hash in the key database.

This is, obviously, not very practical to do by hand. We intend to provide support for this in Fedora by providing a tool that gets run while the system is in setup mode, reads the ROMs, hashes them and enrols the hashes. We'll probably integrate that into the general key installation tool to make it a one-step procedure. The only remaining problem is that swapping your hardware or updating the firmware will take it back to a broken state, and sadly there's no good answer for that at the moment.

Once you've got a full set of enrolled keys and the hashes of any option ROMs, the only thing to do is to sign your bootloader and kernel. Peter Jones has written a tool to do that, and it's available here. It uses nss and so has support for using any signing hardware that nss supports, which means you can put your private key on a smartcard and sign things using that.

At that point, assuming your machine implements the spec properly everything that it boots will be code that you've explicitly trusted. But how do you know that your firmware is following the spec and hasn't been backdoored? That's tricky. There's a complete open implementation of UEFI here, but it doesn't include the platform setup code that you'd need to run it on any x86 hardware. In theory it'd be possible to run it on top of Coreboot, but right now that's not implemented. There is a complete port to the Beagleboard hardware, and there's instructions for using it here. The remaining issue is that you need a mechanism for securing access to the system flash, since if you can make arbitrary writes to it an attacker can just modify the key store. On x86 this is managed by the flash controller being switched into a mode where all writes have to be carried out from System Management Mode, and the code that runs there verifies that writes are correctly authenticated. I've no idea how you'd implement that on ARM.

There's still some work to be done in order to permit users to verify the entire stack, but Secure Boot does make it possible for the user to have much greater control over what their system runs. The freedom to make decisions about not only what your computer will run but also what it won't is an important one, and we're doing what we can to make sure that users have that freedom.

ARM TrustZone

(Anonymous) 2012-08-16 05:57 pm (UTC)(link)
There's this feature on ARM called TrustZone, which divides the CPU in a secure and non-secure world. However, it's up to the SoC vendor to decide whether to implement it or not and AFAIK it's hard (if not impossible) to use it as an end-user without modifying the bootloader (which is in ROM).

[misposted this to 16387.html, please delete the other one | also, your OpenID coupling seems to be giving problems with the captcha validation]

Good, but complicated

(Anonymous) 2012-08-16 06:32 pm (UTC)(link)
The possibility of enrolling ROM keys would be great. It will still
be a PITA, just another administrative task in the best case and a real PITA if anything goes wrong, and it sometimes will.

Is there any slightest chance of buying hardware for Ubuntu (was it Ubuntu that made their own hardware requirements?) and somehow getting Fedora bootable by their keys? Not that it really sounds like a viable option for many reasons (like actually obtaining a needed hardware with the Ubuntu keys)

The anticipated unanticipated

(Anonymous) 2012-08-16 06:54 pm (UTC)(link)
I somehow have a strong feeling that when the hardware is available there will be a huge box of surprises.

Both the UEFI spec and Microsoft's hardware requirements look good on paper, but I already know some HP BIOSes, EFI ones, that did not quite implement the standard, or rather implemented some "additional features". That did make booting almost anything other than preinstalled problematic - there were workarounds for that, but anything short of wiping the whole drive for a fake container partition did not have a chance to boot. On laptops.

We'll see I guess.

Linux Foundation

(Anonymous) 2012-08-16 07:04 pm (UTC)(link)
I don't understand why the Linux Foundation (or some other equally trusted, respected, independent group) doesn't step up and provide signing. I doubt Dell, HP, Lenovo, etc want to deal with a dozen distributions, but I'm sure they would be happy to include a root CA cert from the Linux Foundation as well as Microsoft. Then said foundation could provide signing services to all the distributions. Sadly I think we're out of time for this to happen. Or am I missing something?

Code signing for anyone - it just does not make sense

(Anonymous) 2012-08-16 07:39 pm (UTC)(link)
Please, tell me what I am missing:

Microsoft will sing code for anyone. This cannot ever be secure. First, I don't buy the argument that they can track who signed it. There will be a market of signed loaders, with the person whose code was submitted either non-existing or not knowing anything about it.
So, Microsoft will blacklist them: when? When there is a known exploit? It seems a little late for a cryptographically "safe" feature. No one else has the list of keys that were signed. Maybe they will blacklist everything they sign except own - there are two problems with that. Space overflow in blacklists will limit the count of keys they can sign. Second: this would mean that the Fedora shim loader would be useless.

My point is that the signing service will either be insecure - also for Fedora - or will be limited or will be terminated. I now value what you just described for making own keys, otherwise the whole feature is pretty useless.

Signing the firmware

(Anonymous) 2012-08-16 09:57 pm (UTC)(link)
Why is it a problem that the firmware binaries are signed by Microsoft? If you can insert your own key as a trusted key, couldn't you just discard the Microsoft signature and sign the firmware blobs yourself with the key whose public half you have added?

Or you can ...

(Anonymous) 2012-08-17 03:33 am (UTC)(link)
File a complaint with the US Justice Department's Anti-Trust division. They seemed to be already aware based on the personal response letter I got but I'm sure more complaints will keep the fire hot.

Here's the link

(Anonymous) 2012-08-17 03:34 am (UTC)(link)
Forgot the link to file a complaint: http://www.justice.gov/atr/contact/newcase.html