Démarrage sécurisé

From NixOS Wiki
Revision as of 21:16, 12 July 2024 by Nicolas-goudry (talk | contribs) (Created page with "Il est recommandé de définir un mot de passe BIOS et le chiffrement total du disque afin de se prémunir d'attaques contre l'UEFI et le démarrage sécurisé.")

Le démarrage sécurisé est habituellement associé à la capacité d'un micrologiciel de plateforme de vérifier les composants de démarrage et de s'assurer que seul votre propre système peut démarrer.

Le démarrage sécurisé est implémenté de multiple façons. La plus connue est le démarrage sécurisé UEFI qui repose sur le micrologiciel de plateforme UEFI, mais d'autres implémentations existent sur les systèmes embarqués.

On NixOS, Secure Boot can be enabled via the project Lanzaboote.

Lanzaboote dispose de deux composants: lzbt et stub.

lzbt est la ligne de commande qui signe et installe les fichiers de démarrage sur l'ESP.

stub est une application UEFI qui charge le noyau et initrd depuis l'ESP. Elle diffère de systemd-stub, voir plus bas pour des précisions.

Warning: Lanzaboote est en développement et nécessite de réunir des pré-requis et de prendre des précautions. Il est pour le moment uniquement disponible pour nixos-unstable. Pour plus d'informations, voir le dépôt GitHub ou le guide de démarrage rapide.

Pré-requis

L'implémentation du démarrage sécurisé de Lanzaboote nécessite un système installé en mode UEFI avec systemd-boot activé. Ceci peut être vérifier en exécutant bootctl status:

$ bootctl status
System:
     Firmware: UEFI 2.70 (Lenovo 0.4720)
  Secure Boot: disabled (disabled)
 TPM2 Support: yes
 Boot into FW: supported

Current Boot Loader:
      Product: systemd-boot 251.7
...

Il est recommandé de définir un mot de passe BIOS et le chiffrement total du disque afin de se prémunir d'attaques contre l'UEFI et le démarrage sécurisé.

Setup

Follow the instructions in the Quick Start guide.

Key management

At the time of writing, Lanzaboote offers only local storage of the keyring, otherwise, it is not possible to rebuild the system and sign the new resulting files.

In the future, Lanzaboote will offer two new signature backends: remote signing (an HTTP server which receives signature requests and answers with signatures) and PKCS#11-based signing (that is, bringing an HSM-like device, e.g. YubiKey, NitroKey, etc.).

Warning: Key management is a hard problem which is out of scope for Lanzaboote project, many recipes exist and there is no single perfect solution. Taking the time to learn how to key manage and figure out the right level of threat protection is crucial to achieve an effective boot protection.

Differences with `systemd-stub`

systemd and distribution upstream have an existing solution called `systemd-stub` but this is not a realistic solution for NixOS as there's too many generations on a system.

Using `systemd-stub`, a kernel and an initrd has to be duplicated for each generation, using Lanzaboote's stub, a kernel and initrd can be deduplicated without compromising on the security.

Tracking the feature parity with `systemd-stub` can be done in this issue: https://github.com/nix-community/lanzaboote/issues/94.