From 044e8c5a2af86481bbd03766d1ef5ede4727a615 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Tue, 17 Nov 2026 20:40:36 +0800 Subject: [PATCH] feat(nixos): open the initrd emergency shell with the root password Assisted-by: DeepSeek Harness (claude-opus-5-5) --- docs/SECURITY.md | 6 ++++++ hosts/idols-aquamarine/default.nix | 3 +++ lib/genVmHostModule.nix | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/SECURITY.md b/docs/SECURITY.md index 459a546d..6341d6f9 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -102,6 +102,12 @@ an advisory and affected kernel versions before adding CVE claims; search snippe key enrollment and actual Secure Boot state with `sbctl status`; do not assume all hosts have it. - Secure Boot, signed boot images, kernel lockdown and module signature enforcement are distinct controls. Test custom kernels and NVIDIA/out-of-tree modules before extending enforcement. +- A failed initrd on the physical servers opens a root shell after the root password + (`boot.initrd.systemd.emergencyAccess`, the public hash in [vars](../vars/default.nix)). It adds + no protection on shoryu, shushou and youko: Secure Boot is off, the systemd-boot editor is on and + TPM2 unlocks LUKS on PCRs 0+7 alone, so console access already grants root through a kernel + command-line edit. aquamarine's Lanzaboote stub ignores command-line edits while Secure Boot is + on. - AppArmor is enabled, but the only explicit policy, sudo's, is in complain mode. Complain mode logs rather than blocks. Existing FHS-oriented abstractions need Nix store path review; this is not broad enforced application confinement. diff --git a/hosts/idols-aquamarine/default.nix b/hosts/idols-aquamarine/default.nix index ecebf4ed..1c6a5bfa 100644 --- a/hosts/idols-aquamarine/default.nix +++ b/hosts/idols-aquamarine/default.nix @@ -39,6 +39,9 @@ in ./idle-suspend.nix ]; + # A failed initrd drops to a root shell behind the root password (docs/SECURITY.md). + boot.initrd.systemd.emergencyAccess = myvars.initialHashedPassword; + # Bind the board's NCT6798D SuperIO, otherwise fan RPM and board temperatures # are missing. boot.kernelModules = [ "nct6775" ]; diff --git a/lib/genVmHostModule.nix b/lib/genVmHostModule.nix index c9e8b5cc..11097e07 100644 --- a/lib/genVmHostModule.nix +++ b/lib/genVmHostModule.nix @@ -9,7 +9,12 @@ let inherit (networking.hostsAddr.${hostName}) iface ipv4; ipv4WithMask = "${ipv4}/24"; in -{ config, lib, ... }: +{ + config, + lib, + myvars, + ... +}: { # CPU policy belongs to physical hosts; guests do not control hardware frequency. imports = [ @@ -34,6 +39,9 @@ in # Retries need no console: root LUKS unlocks through TPM2 alone (hosts/README.md). boot.loader.systemd-boot.bootCounting.enable = true; + # A failed initrd drops to a root shell behind the root password (docs/SECURITY.md). + boot.initrd.systemd.emergencyAccess = myvars.initialHashedPassword; + # 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" ];