4

My Dell XPS 9310 has secure boot enabled and the BIOS is up to date and there are no manual keys added there.

Can I download a ubuntu .ISO from anywhere and flash into any computer without worrying about malwares? Will it boot the USB drive only if the image is correctly signed by Ubuntu?

I want to understand the thread modeling. I've been reading https://wiki.ubuntu.com/UEFI/SecureBoot

it looks like ubuntu is loaded by a windows shim, whatever it may mean:

On Ubuntu, all pre-built binaries intended to be loaded as part of the boot process, with the exception of the initrd image, are signed by Canonical's UEFI certificate, which itself is implicitly trusted by being embedded in the shim loader, itself signed by Microsoft.

this makes me think that I still need to trust the image to verify itself.

If that's the case, can I add Canonical keys directly to the BIOS and then it will never boot anything not from Canonical?

1
  • 1
    Most x86 firmware are enrolled only with a Microsoft certificate and thus only trust Microsoft signed binaries. Shim is small EFI application that act as a... shim. It just chain load another EFI application (your bootloader or kernel, in this case). It's magic consists in being signed by MS because it only load EFI applications that have been signed by a distro CA or whitelisted explicitly, at boot, by the user (it's a trust delegation). So if you have secure boot and don't enroll any new binary into shim, you can only load signed ISOs. If you need to enroll a new hash, you are on your own. Commented Nov 6, 2024 at 8:21

2 Answers 2

6
+150

You do need to verify the downloaded ISO image using Canonical-signed hashes as described on the Ubuntu website. Secure Boot has nothing to do with checking ISO files. It works at the UEFI level and can verify UEFI firmware like bootloaders or kernels. In a default setup with Ubuntu as the operating system, only parts of the boot procedure are integrity-protected when you use Secure Boot. If you install Ubuntu from a manipulate ISO image, then an attacker may very well plant malware which compromises the boot process – and of course the user space.

Ubuntu uses GRUB 2 as the default bootloader. Since Microsoft refuses to sign GPLv3-licensed firmware like GRUB 2 (see their UEFI Signing Requirements), it won't work directly with Secure Boot if Microsoft Keys are installed. Instead, Ubuntu uses shim as a prior bootloader whose only purpose it is to have embedded Canonical certificates and start UEFI applications signed with the corresponding keys. So Canonical solves the problem by signing GRUB 2 and then asking Microsoft to sign shim.

GRUB 2 in turn starts the Linux kernel which is also signed by Canonical. However, the kernel relies on an initramfs (initial RAM file system) or initrd (initial RAM disk) to provide an early root filesystem before the actual filesystem is available. The initramfs/initrd is not signed by default. This means an attacker can generally manipulate it and, for example, steal the keys used for disk encryption.

Replacing the Microsoft keys with the ones from Canonical doesn't solve the problem. You just no longer need shim. To protect the initramfs, you can, for example, use a signed Unified Kernel Image which is a single UEFI binary that contains both the kernel and an initramfs image. Or you use TPM to verify the integrity of the initramfs image. But this still only covers the boot process, not userspace programs. While there are also approaches for the latter like the Linux Integrity Measurement Architecture, none of this really replaces checking the ISO file.

Note that using HTTPS for the download doesn't guarantee the integrity of the ISO file, just that it hasn't been manipulated in transit. If the Ubuntu website is compromised, then the files may have been replaced at the source. This is exactly what happened with Linux Mint, so it's not just a theoretical risk.

1

Desktop Linux distros (including Ubuntu) don't sign most of their image. Generally, only the bootloader and maybe the kernel are signed. This allows the use of Secure Boot to block "bootkits" that replace pre-boot code to do something malicious (such as start a hypervisor that gives the attacker full control of the running OS without the OS knowing). However, it provides no other security guarantees.

Even on Windows, which signs far more parts of the operating system, signature validity is not generally enforced; aside from critical stuff like the security subsystem and kernel-mode code, you can tamper with system files and the OS won't even notice unless you specifically tell it to check. On Linux, most stuff isn't signed at all, so there's no signatures to check.

Now, with that said, the classic reason for verifying ISOs before flashing doesn't really apply anymore. All ISOs these days should be downloaded over secure (e.g. HTTPS) connections, where an attacker can't tamper with the download unless they can fully impersonate the server. If they can fully impersonate the server, then they can lie to you about what hash digest to expect, so attempting the verify the download integrity is mostly futile anyhow. Furthermore, HTTPS also validates that the traffic hasn't been tampered with accidentally (e.g. bit flips from cosmic rays or whatever). You might want to validate an ISO before writing it if you're worried that your RAM or storage isn't 100% reliable... but in that case, you really should repair your hardware before installing a new OS.

Verifying an image after writing the ISO is potentially still a good idea (though trickier than it was in the days of CDs/DVDs). Flashdrives have limited durability and can introduce errors. But that's still very low risk, and you'd only be worried about accidental errors (unless the computer you used for the flashing is compromised by an attacker, in which case you shouldn't use it for anything much less downloading and installing an OS).

2
  • 1
    Canonical offers GPG-signed hashes for their ISOs. This makes verification completely independent from the download source and provides far stronger security than HTTPS (which indeed becomes useless if the server is compromised). Commented Nov 10, 2024 at 10:15
  • Well, "far stronger" so long as you have it on good authority which public key is theirs. That might actually be a scenario where web-of-trust is useful, though; at the very least, probably a lot of people already have imported their key. Commented Nov 10, 2024 at 14:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.