From a86ea249bd19af635bd319e71f7383b28a3831b5 Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Tue, 24 Nov 2026 21:37:01 -0800 Subject: [PATCH] docs(heimdall): a host firewall, a console that asks for the password, no radio and no unused apps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A full re-check of heimdall found the first audit's fixes in place and five gaps a second audit could raise: an empty nftables ruleset, an autologin shell on tty1, a getty on the debug UART, the Bluetooth radio still up, and Firefox and VLC installed for nothing. build-heimdall.md §2 now closes each, with the firewall loaded live before it is enabled at boot, and §9 undoes them. Co-Authored-By: Claude Opus 5.5 --- docs/changelog.md | 24 +++++++++ docs/runbooks/build-heimdall.md | 90 ++++++++++++++++++++++++++++++++- docs/security.md | 9 ++-- 3 files changed, 118 insertions(+), 5 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 5f9a914b..4d920c3c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,30 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-25 +- **`build-heimdall.md` closes what a second audit of `heimdall` could + still raise.** A full re-check on 2026-11-24 at 21:25 found every + finding of the first audit still fixed, and five hardening gaps nobody + had raised. None is reachable from the network today. §2 now: + - **Adds a host firewall.** `nftables` was installed with an empty + ruleset, so only the absence of other listeners kept the Pi at 22 and + 9100. The ruleset drops everything but SSH, the scrape from + `10.0.99.20` alone, ICMP and DHCP replies. It is loaded live first, and + enabled at boot only after a new SSH login and the scrape both work. + - **Ends the `tty1` shell.** The Imager's desktop autologin also logged + the user into a text shell on `tty1`. Since 2026-11-23 sudo asks for a + password, so a keyboard gave the user and not root, but the kiosk only + needs lightdm's autologin on `vt7`. + - **Masks the serial console** on `ttyAMA10`, the debug UART, which + nothing uses. + - **Turns the radio off** with `dtoverlay=disable-bt`. Masking + `bluetooth.service` had left `hci0` up. + - **Purges Firefox and VLC.** On 2026-11-24, 16 of the Pi's 18 pending + upgrades were VLC's. About 40 packages go with them. + + `security.md`'s paragraph on the Hicks pass now names the firewall. The + steps need the operator's password at the Pi, so they are written here + and not yet applied. + - **The `pre449weaknesses` snapshots on 150–153 are deleted.** This follows the entry below on `harden-saruman.md`, which left them unchanged for the operator to decide. Taken on 2026-10-07 as #449's baseline, diff --git a/docs/runbooks/build-heimdall.md b/docs/runbooks/build-heimdall.md index 4a33dc6e..5d133385 100644 --- a/docs/runbooks/build-heimdall.md +++ b/docs/runbooks/build-heimdall.md @@ -218,8 +218,8 @@ After §3's reboot, `journalctl --list-boots` lists more than one boot. ### Only 22 and 9100 listen -The desktop brings services a kiosk does not use, and the Pi has no host -firewall, so anything on Hicks reaches what they publish. rpcbind, from +The desktop brings services a kiosk does not use, and until the firewall +below, anything on Hicks reached what they publish. rpcbind, from `nfs-common`, listens on 111, and avahi on 5353. Bluetooth is on and pairable, CUPS listens locally, and three remote-desktop packages are installed. The desktop's metapackages depend on `nfs-common` and `cups`, so @@ -235,6 +235,85 @@ sudo apt autoremove --purge -y # the libraries they leave behind sudo ss -tulnH | awk '{print $1, $5}' | sort -u # tcp 22 and 9100, nothing else ``` +### No radio and no unused desktop apps + +Masking `bluetooth.service` leaves the radio itself on. The overlay turns it +off at boot. Firefox and VLC come with the desktop, and the kiosk uses +neither. They are most of the Pi's updates: on 2026-11-24, 16 of its 18 +pending upgrades were VLC's. The desktop's `rpd-applications` only +recommends them, so purging them removes nothing else the Pi uses. +`--autoremove` takes their libraries with them, about 40 packages: + +```bash +sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.bak +printf '\ndtoverlay=disable-bt\n' | sudo tee -a /boot/firmware/config.txt # last section is [all] +sudo apt purge -y --autoremove firefox vlc +``` + +After §3's reboot, `ls /sys/class/bluetooth` prints nothing. + +### Nothing at the console but a login + +The Imager's desktop autologin also logs the user into a text shell on +`tty1`. The kiosk only needs the desktop's autologin, which is lightdm's on +`vt7`. With the shell, a keyboard at the Pi and Ctrl+Alt+F1 is a logged-in +shell. Without it, `tty1` asks for the password. The serial console on +`ttyAMA10`, the Pi 5's debug UART, asks for it already. Nothing uses it, so +mask that too: + +```bash +sudo rm /etc/systemd/system/getty@tty1.service.d/autologin.conf +sudo systemctl daemon-reload +sudo systemctl restart getty@tty1.service # ends the tty1 shell, not the desktop +sudo systemctl mask --now serial-getty@ttyAMA10.service +loginctl list-sessions --no-legend # no session on tty1; lightdm's is still there +``` + +### A firewall that admits only those two + +Only 22 and 9100 listen, but nothing holds it there: a service that starts +listening later is open to all of Hicks. `nftables` is installed and empty. +This ruleset admits SSH, the scrape from `prometheus` alone, and what the +Pi's own traffic needs to come back: + +```bash +sudo tee /etc/nftables.conf >/dev/null <<'NFT' +#!/usr/sbin/nft -f +flush ruleset +table inet filter { + chain input { + type filter hook input priority filter; policy drop; + iif lo accept + ct state established,related accept + ct state invalid drop + meta l4proto { icmp, ipv6-icmp } accept + udp sport 67 udp dport 68 accept # DHCPv4 replies + udp sport 547 udp dport 546 accept # DHCPv6 replies + tcp dport 22 accept + ip saddr 10.0.99.20 tcp dport 9100 accept + } + chain forward { + type filter hook forward priority filter; policy drop; + } + chain output { + type filter hook output priority filter; + } +} +NFT +sudo nft -c -f /etc/nftables.conf # parses, changes nothing +sudo nft -f /etc/nftables.conf # live, but not yet at boot +``` + +Keep this session open, and from the Mac open a new one with +`ssh -o ControlPath=none @10.0.50.15`. From `prometheus`, +`curl -s 10.0.50.15:9100/metrics | grep -c ^node_` is more than 0. If either +fails, power-cycle the Pi: the ruleset is not loaded at boot yet, so it comes +back open. Once both work: + +```bash +sudo systemctl enable nftables.service +``` + ## 3. The reservation On `morpheus`, under Services → DHCP Server → Hicks, add a static mapping: @@ -433,5 +512,12 @@ the roadmap's *Everything still to buy* and an ADR of its own. - **The masked services:** `sudo systemctl unmask` the units §2 masked, then `enable --now` them. The purged remote-desktop packages are reinstalled with `apt`. +- **The firewall:** `sudo systemctl disable --now nftables.service`, then + `sudo nft flush ruleset`. +- **The console:** `sudo systemctl unmask --now serial-getty@ttyAMA10.service`. + `sudo raspi-config nonint do_boot_behaviour B4` writes the `tty1` + autologin back, along with the desktop's. +- **The radio and the apps:** restore `/boot/firmware/config.txt.bak`, and + `sudo apt install firefox vlc`. - **sudo without a password, and the seed files:** neither comes back. A fresh card from the Imager has both. diff --git a/docs/security.md b/docs/security.md index 0b1a6822..86d466a9 100644 --- a/docs/security.md +++ b/docs/security.md @@ -502,9 +502,12 @@ unprivileged datagram socket, not a raw one. ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md)): `prometheus` to `heimdall`, the office wall dashboard, at `10.0.50.15:9100/tcp`, for `node_exporter`. It carries the same residual as -`smaug`'s below. The endpoint is unauthenticated, so anything on Hicks can -read the Pi's own counters. The Pi itself holds no credentials: the pages it -shows are served by `trinity`, and their tokens are added there. +`smaug`'s below. The endpoint is unauthenticated, but the Pi's own +`nftables` admits 9100 from `10.0.99.20` alone, and drops everything but SSH +besides (`build-heimdall.md` §2), once that step is applied. Until then, +anything on Hicks can read the Pi's own counters. The Pi itself holds no +credentials: the pages it shows are served by `trinity`, and their tokens are +added there. One of CasaBonita's passes is a monitoring pass, and it carries a residual worth naming. `10.0.99.20 → 10.0.40.30:9100` lets Prometheus scrape `node_exporter`