diff --git a/docs/SECURITY.md b/docs/SECURITY.md index 2754d088..459a546d 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -45,7 +45,7 @@ small, reversible controls and narrow exceptions; benchmark before adopting expe | Security keys | idols-ai/shoukei use a CanoKey for touch-based sudo (pam_u2f, password fallback; servers via pam_rssh and the forwarded agent), a resident `ed25519-sk` SSH key per CanoKey as the only user SSH keys for GitHub and all hosts, FIDO2 LUKS unlock on shoukei and on-card OpenPGP subkeys; key management happens only in the phone app ([setup](./security-keys.md)) | Touch-only sudo can be triggered by any same-user process, and on a server by root through the forwarded agent; losing both CanoKeys leaves only root logins with the `romantic` recovery key | | Secrets | agenix declarations here, encrypted data in the private nix-secrets repository | Recipients and plaintext file permissions must be reviewed; root on a recipient can read its decrypted secrets | | Supply chain | Locked flake inputs; explicit binary-cache trust keys on NixOS; normal user is not a Nix trusted-user | A trusted cache or imported Nix module can supply code executed as root; a lock file is not a security audit | -| Recovery | NixOS generations, btrbk/restic, hourly read-only snapshots of the REST store, and documented backup procedures | A rollback does not undo compromised data or secrets; backup configuration alone does not prove restore works; the offsite immutable copy is still planned | +| Recovery | NixOS generations with automatic boot fallback on the physical servers, btrbk/restic, hourly read-only snapshots of the REST store, and documented backup procedures | A rollback does not undo compromised data or secrets; backup configuration alone does not prove restore works; the offsite immutable copy is still planned | Sources: [host layout](../hosts/README.md), [k3s deployment](../hosts/k8s/README.md), [firewall](../modules/nixos/base/networking/firewall.nix), [SSH](../modules/nixos/base/ssh.nix), diff --git a/hosts/README.md b/hosts/README.md index 946902de..1a26f506 100644 --- a/hosts/README.md +++ b/hosts/README.md @@ -182,6 +182,15 @@ qemu-kvm path; there are none right now. / `br0` changes, nixpkgs updates, or any broad rebuild. - If a host loses VM networking, check `br0` and the VM taps, or reboot the host. +## Boot Recovery on Physical Servers + +`shoryu`, `shushou`, `youko` (systemd-boot) and `aquamarine` (Lanzaboote) write each new generation +with a boot counter. After 3 boots that never reach `boot-complete.target` (ordered after +`sysinit.target`), the entry is marked bad and the boot loader starts the newest good one. The root +LUKS volume unlocks through TPM2 alone, so retries need no console. Failures later in boot, such as +a broken `br0`, do not count, and a hung boot retries only after a reboot or power cycle. +`bootctl list` shows each entry's remaining tries. + ## Common Build Commands Use the Just recipes for host configuration checks and builds: diff --git a/hosts/idols-aquamarine/secureboot.nix b/hosts/idols-aquamarine/secureboot.nix index 9547e4e2..abe86d99 100644 --- a/hosts/idols-aquamarine/secureboot.nix +++ b/hosts/idols-aquamarine/secureboot.nix @@ -26,5 +26,7 @@ boot.lanzaboote = { enable = true; pkiBundle = "/etc/secureboot"; + # Retries need no console: root LUKS unlocks through TPM2 alone (hosts/README.md). + bootCounting.initialTries = 3; }; } diff --git a/lib/genVmHostModule.nix b/lib/genVmHostModule.nix index 60fc276e..16a21d58 100644 --- a/lib/genVmHostModule.nix +++ b/lib/genVmHostModule.nix @@ -30,6 +30,9 @@ in "nfs" ]; + # Retries need no console: root LUKS unlocks through TPM2 alone (hosts/README.md). + boot.loader.systemd-boot.bootCounting.enable = true; + # KVM for the microVMs and the libvirt domains. AMD-specific: an Intel VM host # would need kvm-intel instead (see hosts/idols-ai/hardware-intel.nix). boot.kernelModules = [ "kvm-amd" ];