linuxboot / heads-wiki

Documentation for the Heads firmware project
84 stars 44 forks source link

Better explain Heads functionnings and limitation #62

Open tlaurion opened 3 years ago

tlaurion commented 3 years ago

Edit: best unbiased, user written doc at https://tech.michaelaltfield.net/2023/02/16/evil-maid-heads-pureboot/


The following should go into a wiki page.

Actual Heads security mechanisms are:

  1. Measured /boot, requiring a USB Security dongle to offload GPG operations (signing with private key in smartcard). The verification of detached signed /boot digest is automatic on each boot, verified against public key injected in firmware (and measured by TPM).

  2. Firmware remote attestation (TOTP, HOTP) of measured firmware components, including GPG public key into PCR7, used to provide validation of detached signed digest of precedent step.

  3. Disk Unlock Key, using NV TPM reserved space to release Disk Unlock Key when (1) (2) and LUKS header + Disk Unlock Key passphrase are valid, while rate limiting passphrase attempts by the TPM. (Note that if going into recovery shell, measurements are invalidated and this won't be successful)

Let's focus on (1) here.

  1. On each boot, Heads verifies that the detached signed digest (/boot/kexec.sig) matches the digest(/boot/kexec_hashes.txt). (Verified authenticity and integrity with public key matching private key in USB Security dongle's smartcard).
  2. Heads generates a new sha256sum digest of /boot found files (sha256sum of /boot files) and compares its result against signed one (/boot/kexec_hashes.txt)
  3. If there is a mismatch of integrity of past signed digest, the difference of integrity are showed. If there are new files not in digest, those are shown as errors. Both are different. For example, grub.cfg having changed (grub.cfg) and a new file (xen or kernel) gives hints of what changed in case the user forgot to reboot his computer directly after a core upgrade to sign related changes and keep his workflow worry free.

For more information, please read: https://www.linuxjournal.com/content/why-smart-cards-are-smart

tlaurion commented 3 years ago

Should be considered in limitations when implementing https://github.com/osresearch/heads/issues/921

tlaurion commented 3 years ago

Another note of interest here is that Heads does not implement dmverity checks as of now (was in before, never really documented, could have worked with patches to QubesOS 3.2 but never happened for QubesOS, where I cannot find link to past discussions as of right now.)

For QubesOS to support such setup (as safeboot goal) QubesOS disk layout and keeping QubesOS from constantly writing into the rootfs layer (which should not change outside of updates) needs to be implemented.

tlaurion commented 3 years ago

The best Heads implements, as of right now, in my opinion, is:

  1. /boot detached signed digest from USB Security dongle's private key (Yubikey, Nitrokey Pro/Nitrokey Storage, Librem Key, other GPG tokens). Verified on each boot against public key counterpart, injected in ROM and measured by....
  2. TPM-based measured boot, verifying ROM components, including User's customizations (read here /etc/config.user which is customizations of board deployed config exports under /etc/config, and GPG public key as part of PCR7). Sealed under...
  3. Remote attestation over Qr Code to be scanned by OTP application over smartphone, for which OTP code can be verified manually at each boot (OTP) and/or through HOTP compliant USB Security dongle (currently supported: Nitrokey Pro/Nitrokey Storage/Librem Key)
  4. Disk Unlock Key released by the TPM only if /boot detached signed digest is valid, if provided with proper Disk Unlock Key passphrase (passphrase attempts rate limited by TPM) which would release Disk Unlock Key only if TPM measurements are valid (including public key, user config, that Heads did not come back from recovery shell, that LUKS header is valid)

Any other implementation proposed previously would lower the security offered.

The above implementation comes with limits as well. In theory, it would be totally possible to:

On TPM-less USB Security dongle-only enforced remote attestation (firmware integrity remote attestation on USB Security dongle through HOTP):

On LUKS encrypted backup of key generation:

On LUKS encrypted partition replacing USB Security dongle:

tlaurion commented 3 years ago

For documentation purposes, a long discussion happened on slack from here to here

Thrilleratplay commented 3 years ago

@tlaurion More detail and better explanations are needed in the wiki but how would this be organized? This, when all together, seems like it lead to more questions from new users.

Diagrams laying out where everything is stored and a glossary may be useful but seem like they are outside of the scope of this ticket. I'll open new ones.

tlaurion commented 2 years ago

Sandy and Ivy bridge (xx20/xx30) get platform locking (no SPI write outside of Heads) through https://github.com/osresearch/heads/pull/326

tlaurion commented 8 months ago

Take into consideration https://github.com/linuxboot/heads-wiki/issues/116 when updating docs to differenciate measuring and sealing operations.

tlaurion commented 5 months ago

Detailed again what kexec*.txt files are for, as detached signed under kexec.sig under https://github.com/linuxboot/heads/issues/1620#issuecomment-2023315107

Time to work on docs!

tlaurion commented 3 months ago
  1. Firmware remote attestation (TOTP, HOTP) of measured firmware components, including GPG public key into PCR7, used to provide validation of detached signed digest of precedent step.

Discussion on bootguard vs bootblock RoT at https://matrix.to/#/!GzefHyBKGoKjOgarWV:matrix.org/$Fa2nJy6D0W0mNELnNzUJVYAXhZoVGn1Dw4Mqtmax9qg?via=dreamless.one&via=matrix.org&via=tchncs.de