From 2ab6bc1cbb3258789be518960a7fc045eb7e63fc Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Sun, 22 Nov 2026 17:23:44 -0800 Subject: [PATCH 1/4] docs(range): write gandalf's 2026-11-22 audit fixes into the runbook The second read-only audit found containment holding and four gaps. build-the-playground.md gains: - section 2: ip-forward off on vmbr0, and a netdev ingress table on vmbr1 so the host takes nothing from the range, ARP included; - section 4: X11 and TCP forwarding off in the keys-only drop-in, and "Nothing else on gandalf", which removes the dotfiles install and the third-party apt repos; - section 7: a read-back for each; - section 8: check four proves the ingress table, and the stale "until 902 is rebuilt" note is updated. security.md gains the row. The changelog records the audit, including the credential cleanup nothing had recorded. None of it is applied on gandalf yet. Refs #421. Co-Authored-By: Claude Opus 5.5 --- docs/changelog.md | 39 ++++++ docs/runbooks/build-the-playground.md | 163 ++++++++++++++++++++++++-- docs/security.md | 1 + 3 files changed, 192 insertions(+), 11 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index e98475da..f67b4ce4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,45 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-22 +- **A second read-only audit of `gandalf` finds containment holding, and + writes four fixes into the runbook.** It was run from Hicks after a power-on + and a full upgrade. Holding: + - `vmbr1` had no port and no address after a cold boot; + - the host and `ragnarok` had no NAT, and only `ragnarok` was dual-homed; + - all three targets had `clean`; + - the firewall read back as §4 writes it, and `morpheus` saw 22, 8006 and + the six AMT ports closed; + - `ragnarok` was started for the read and shut down after. Its + `range_scope` tables were loaded at boot as `finish-attack-vm.sh` writes + them, and a send to `1.1.1.1` was refused with `EPERM`. + + Of the 2026-11-13 findings, these were found fixed: + - keys-only SSH and the NFS services; + - template 902, rebuilt that day after #1341; + - the old kernel; + - the GitHub token, the Claude Code credentials and the HomeLab checkout, + removed from `root` before this audit. No entry had recorded that. + + New, and written into `build-the-playground.md`: + - `vmbr0` read IPv4 and IPv6 `forwarding = 1` while the global flag was + `0`. Nothing in `sysctl.d` sets it, so it is most likely ifupdown2's + default for an interface that carries an address. §2 adds `ip-forward off` and `ip6-forward off`. + - Nothing but the host firewall stopped a rooted target from reaching the + host: Linux answered ARP for `10.0.30.30` on `vmbr1`. §2 adds a netdev + `ingress` table on `vmbr1`, and §8 check four proves it. + - `sshd` still allowed X11 and TCP forwarding. §4's drop-in turns both off. + - `root` carried a dotfiles install, `1password-cli`, `gh`, Go and the + 1Password and Charm apt repositories. §4's new *Nothing else on + `gandalf`* removes them. `security.md` adds the row. + + §7's read-back checks all four. None is applied on `gandalf` yet. + + The audit also found that the box had not been powered off between + sessions. `ragnarok` ran from 2026-11-12 to 2026-11-22, and the host was up + from 2026-11-07, nine days past the audit that reported it. ADR-0017's + "no monitoring" rests on that discipline, and what replaces it is left to + its own decision. + - **`vmbr1`'s `post-up` holds across a boot.** This completes the entry below that moved the line to `post-up`, which left the proof outstanding. The line was applied on `gandalf`, and the box rebooted at 15:53. After the boot, diff --git a/docs/runbooks/build-the-playground.md b/docs/runbooks/build-the-playground.md index d5c14235..2adec90f 100644 --- a/docs/runbooks/build-the-playground.md +++ b/docs/runbooks/build-the-playground.md @@ -203,6 +203,8 @@ iface vmbr0 inet static bridge-ports nic0 bridge-stp off bridge-fd 0 + ip-forward off + ip6-forward off auto vmbr1 iface vmbr1 inet manual @@ -210,10 +212,25 @@ iface vmbr1 inet manual bridge-stp off bridge-fd 0 post-up sysctl -q -w net.ipv6.conf.vmbr1.disable_ipv6=1 + post-up /usr/sbin/nft -f /etc/network/vmbr1-host-in.nft source /etc/network/interfaces.d/* ``` +`/etc/network/vmbr1-host-in.nft`, which the last line loads: + +```text +table netdev vmbr1_host_in +delete table netdev vmbr1_host_in +table netdev vmbr1_host_in { + counter dropped { } + chain ingress { + type filter hook ingress device "vmbr1" priority filter; policy drop; + counter name "dropped" drop + } +} +``` + Two things in there are load-bearing and neither is obvious: - **`bridge-ports none` on `vmbr1`.** This is the isolation. It is not a filter @@ -233,6 +250,32 @@ Two things in there are load-bearing and neither is obvious: `ifupdown2` has created the bridge, so the key does not exist yet, the `sysctl` fails, and the boot carries on with IPv6 on. +Two more lines close what the address alone does not: + +- **`ip-forward off` and `ip6-forward off` on `vmbr0`.** The host routes for + no one. The global `ip_forward` is `0`, but IPv4 decides per interface, + on the one a packet arrived on. On 2026-11-22 `vmbr0` read + `forwarding = 1` in both families while everything else read `0`. Nothing + in `sysctl.d` set it, which points at ifupdown2's default for an + interface that carries an address. These two lines are ifupdown2's own way + to turn it off. There is no route to the range, so it was + never a path in, but the host would route between VLAN 30 hosts that sent + it a packet to pass on. +- **The `vmbr1_host_in` table.** No address on `vmbr1` is not the same as + nothing from `vmbr1` reaching the host. Linux answers ARP for any of its + addresses on any interface, and it accepts a packet for `10.0.30.30` on + whichever interface it arrives (`arp_ignore` `0`, and `rp_filter` `2`, which + `pve-firewall` sets host-wide). So a target someone has rooted can add an + on-link route to `10.0.30.30`, and its packets are delivered to the host. + Until this table, the host firewall was what dropped them, and nothing + watches that on `gandalf` (§7). The table sits on `vmbr1`'s netdev + `ingress` hook. That hook sees only frames the bridge passes up to the host + itself, never frames it forwards between two guests. So it drops everything + addressed to the host, ARP included, and the targets still reach + `ragnarok`. It is loaded from `post-up` because a netdev chain needs its + device to exist, and `nftables.service` runs before the bridges do. The + first two lines make a reload start clean. + The `post-up` line on `nic0` is not isolation. It is the usual workaround for the I219's e1000e transmit hang under load, which would take the range's one link down mid-session. @@ -241,11 +284,15 @@ link down mid-session. ip -br addr show ip addr show dev vmbr1 | grep -c inet ethtool -k nic0 | grep -E 'tcp-segmentation-offload|generic-segmentation-offload' +sysctl net.ipv4.conf.vmbr0.forwarding net.ipv6.conf.vmbr0.forwarding +nft list chain netdev vmbr1_host_in ingress | grep -c 'policy drop' ``` **You should see** `vmbr0` with `10.0.30.30/24`, and **`vmbr1` with no address at all**: the `grep -c` prints `0`, so no `inet` and no `inet6`. -`UNKNOWN` is what an empty bridge reports. Both offloads should read `off`. +`UNKNOWN` is what an empty bridge reports. Both offloads should read `off`, +both `vmbr0` forwarding flags `0`, and the last line `1`. §8 check four +proves the table drops what a target sends to the host. Then reboot once, which also picks up §1's kernel, and run the same commands again, with @@ -264,6 +311,9 @@ fault. Applied on `gandalf` the same day, then proved by a reboot at 15:53. After it, `disable_ipv6` read `1`, the `grep -c` read `0`, and the boot's networking log had no failed `sysctl`. +The `ip-forward` lines and the `vmbr1_host_in` table were written later on +2026-11-22, from the audit that day. **Not yet applied on `gandalf`.** As with +the `sysctl` line, only a reboot followed by the commands above proves them. Then add the reservation for `10.0.30.30` on `morpheus` alongside the other ImaginationLAN statics. `.30` is below `.100` and therefore outside the Kea @@ -657,14 +707,22 @@ printf '%s\n' \ 'PermitRootLogin prohibit-password' \ 'PasswordAuthentication no' \ 'KbdInteractiveAuthentication no' \ + 'X11Forwarding no' \ + 'AllowTcpForwarding no' \ > /etc/ssh/sshd_config.d/10-keys-only.conf sshd -t && systemctl reload ssh -sshd -T | grep -E '^(permitrootlogin|passwordauthentication|kbdinteractiveauthentication) ' +sshd -T | grep -E '^(permitrootlogin|passwordauthentication|kbdinteractiveauthentication|x11forwarding|allowtcpforwarding) ' ``` **You should see** `permitrootlogin without-password` (`sshd -T`'s name for -`prohibit-password`), `passwordauthentication no` and -`kbdinteractiveauthentication no`. The drop-in wins over the main file's +`prohibit-password`), `passwordauthentication no`, +`kbdinteractiveauthentication no`, `x11forwarding no` and +`allowtcpforwarding no`. The last two keep a root session on the range's +isolation host from becoming a tunnel. Nothing here needs one, because +`8006` is reached directly from Hicks. The drop-in applied on 2026-11-22 had +the first three lines only. The audit that day found both forwardings on +(Debian's `X11Forwarding yes` and the `AllowTcpForwarding` default), so the +step is rerun with all five. **Not yet applied on `gandalf`.** The drop-in wins over the main file's `PermitRootLogin yes` because `Include` comes first in `sshd_config` and `sshd` keeps the first value it reads. Then, from Hicks, a password login must be refused while a key login still works: @@ -708,6 +766,60 @@ The `ss` output should list `22`, `8006` and `3128` on all addresses, and Nothing on `111` should remain. If NFS storage is ever added, unmask and enable them first, or the mount will fail. +### Nothing else on `gandalf` + +`gandalf` is the box that keeps the attacker's segment away from the estate. +It shares layer 2 with `ragnarok`, and nothing watches it (ADR-0017). So it +holds no estate credential, no GitHub login, no personal tooling and no apt +repository but Debian's and Proxmox's. Repository work and anything that needs +a login are done from a Hicks workstation or `phoenix`, never from a shell +here. Every apt source can install a package that runs as root on the +isolation host, so a third-party repository is a supply chain the range +does not need. + +The 2026-11-13 audit found a GitHub token, Claude Code credentials and a +HomeLab checkout here. They were removed before the 2026-11-22 audit, which +found none of them. It did find a dotfiles install for `root`: + +- zsh as the login shell, and `~/.ssh/config` linked into the checkout; +- an `atuin` daemon, Go toolchains, and tools under `~/.local`; +- the packages `1password-cli` (signed out), `gh` (logged out), `glow`, + `gum`, `netavark` and `skopeo`; +- the 1Password and Charm apt repositories, and Claude Code's remote-session + files under `/root/.claude`. + +Remove them, as root on `gandalf`, from a shell opened with `bash` (the login +shell changes first): + +```bash +chsh -s /bin/bash root +pkill -x atuin || true +rm -f /etc/apt/sources.list.d/1password.list /etc/apt/sources.list.d/charm.list \ + /etc/apt/keyrings/1password.gpg /etc/apt/keyrings/charm.gpg +apt purge 1password-cli gh glow gum netavark skopeo zsh zsh-common \ + golang-go golang-src golang-1.24-go golang-1.24-src \ + golang-github-containers-common golang-github-containers-image +apt autoremove --purge && apt update +find /root -maxdepth 3 -lname '*dotgibson*' -print -delete +rm -rf /root/code /root/.local /root/.config/atuin /root/.config/gh /root/.config/go \ + /root/.claude /root/.claude.json /root/.ssh/config.d /root/.ssh/sockets \ + /root/.ssh/config.pre-dotfiles.* +``` + +The `find` removes the dotfiles' symlinks before the checkout goes, so none +is left dangling. Keep `/root/.ssh/id_rsa`, `id_rsa.pub` and `known_hosts`: +they are Proxmox's own node key. Then read it back: + +```bash +ls /etc/apt/sources.list.d/ +getent passwd root | cut -d: -f7 +pgrep -a atuin; command -v gh op zsh +``` + +**You should see** only `ceph.sources`, `debian.sources`, `proxmox.sources` +and `pve-enterprise.sources`, the shell `/bin/bash`, and nothing from the last +line. **Not yet run on `gandalf`.** + --- ## 5. The attack VM @@ -973,13 +1085,18 @@ that keep `Saruman`'s firewall on do not reach `gandalf`, because ADR-0017 gives it no agent. So the check §4 hands to Prometheus on `Saruman` is a step here, once per session. `pve-firewall status` should read `enabled/running`, and §4's probe from `morpheus`, aimed at `10.0.30.30`, should give `8006 exit=1` and -`control exit=0`. `sshd -T | grep -E '^(permitrootlogin|passwordauthentication) '` -should read `without-password` and `no`, because an upgrade that replaces +`control exit=0`. `sshd -T | grep -E '^(permitrootlogin|passwordauthentication|x11forwarding|allowtcpforwarding) '` +should read `without-password` and three `no`s, because an upgrade that replaces `sshd_config.d` would be as silent as one that rewrites the firewall. Any other answer means the session does not start until §4 has been rerun. `ip addr show dev vmbr1 | grep -c inet` should print `0` (§2): the host has -no address on the range. Anything else means the session does not start until -§2's `sysctl` has been rerun and its line in `/etc/network/interfaces` checked. +no address on the range. `sysctl net.ipv4.conf.vmbr0.forwarding +net.ipv6.conf.vmbr0.forwarding` should read `0` twice, and +`nft list chain netdev vmbr1_host_in ingress | grep -c 'policy drop'` should +print `1`. Anything else means the session does not start until §2's lines +have been rerun and checked in `/etc/network/interfaces`. +`ls /etc/apt/sources.list.d/` should list Debian's and Proxmox's sources +only (§4, *Nothing else on `gandalf`*). **Then check Proxmox's own updates.** `unattended-upgrades` covers Debian's packages only (§4, *Services on `gandalf`*). `apt update && apt list @@ -1016,9 +1133,10 @@ by anything else in this repository. > and dhcpcd stopped, the guest had no default route, and both pings gave > `Network is unreachable` while `172.30.30.10` answered. `ragnarok` is not > affected, because its `eth0` takes a real lease. Since #1341 the build -> removes the stanza before templating. **Until 902 is rebuilt, a -> static-only clone of it on `vmbr1` needs that file removed before this -> check passes.** +> removes the stanza before templating. 902 was rebuilt on 2026-11-22, +> after #1341 merged (`range/base-902-disk-1` is dated that day), so a new +> clone should not carry the file. The next check four on a static clone +> is what proves it. **One — `gandalf` is single-homed, and `vmbr1` has no port.** On the host: @@ -1079,6 +1197,29 @@ unreachable* rather than timing out. A timeout means a default route exists and something is swallowing the packets, which is a different and much worse state: it is a filtered target rather than an unrouted one. +Then prove that the host takes nothing from the range, which is what a rooted +target would try next (§2, `vmbr1_host_in`). On `gandalf`, read the counter: + +```bash +nft list counter netdev vmbr1_host_in dropped +``` + +On the target, give it the route an attacker would add, send once, and take +the route away: + +```bash +ip route add 10.0.30.30/32 dev eth0 +ping -c2 -W1 10.0.30.30 +ip route del 10.0.30.30/32 dev eth0 +``` + +The pings should get no reply, and `ip neigh show 10.0.30.30` on the target +should read `FAILED` or `INCOMPLETE`: the host never answered ARP. The +counter on `gandalf` should have risen. A reply, or a `REACHABLE` neighbour, +means the table is not loaded. The target should still answer `ragnarok`'s +ping, which shows that the table drops traffic to the host and not traffic +between guests. + --- ## 9. Prove that a leak reports itself diff --git a/docs/security.md b/docs/security.md index de7ffb2c..a10b246c 100644 --- a/docs/security.md +++ b/docs/security.md @@ -30,6 +30,7 @@ What this network is actually built to survive: | Someone on the lab segment reaching `eden`'s SSH | **Key-only, unfenced, and accepted.** `eden` holds the map of the weak domain's attack paths, and its `sshd` answers all of VLAN 30, the six domain guests included: the guest runs with `firewall=0` and no host firewall, and nothing in this repository fences `sshd` on any Linux lab guest. What bounds it is the key. `sshd` refuses passwords, and `garnet` takes two keys, the operator's and `phoenix`'s, which `tofu/` installs; `root`'s copies are command-restricted by cloud-init. `garnet`'s sudo is `NOPASSWD`, from the default user Proxmox's cloud-init makes on every Linux guest `tofu/` builds, and is accepted with it: on `eden` `garnet` is in the `docker` group, which is root already. A fence by source address, as the domain's six have for `phoenix`, would be its own decision for every Linux guest, not `eden`'s alone | | Someone on the lab segment reaching the lab's Grafana or BloodHound, or a detonation reaching `diabolos`'s UIs | **Scoped by address, as the SOC's are.** `alexander`'s Grafana (`3000`) is published by the lab stack's `caddy`, and `eden`'s BloodHound (`8443`) by the bloodhound stack's own `caddy`; each answers Hicks's `10.0.50.0/24` and refuses the rest of VLAN 30, the six domain guests included. `diabolos`, not yet built, has soc's fence for its dashboard and GUI. Until then Grafana and BloodHound answered all of VLAN 30, where BloodHound's graph is the domain's attack-path map ([#1428](https://github.com/Gerrrt/HomeLab/issues/1428)). The residuals are the SOC row's: Hicks is a whole /24, and an address on VLAN 30 can be spoofed for a one-way packet but not for the TLS session the UIs need | | A range target with a path out | It has none — `gandalf`'s targets sit on a bridge with no physical port, on `172.30.30.0/24`, which the firewall does not route and on which nothing has a default route at all ([ADR-0014](adr/0014-put-ifrit-on-imaginationlan-and-give-the-targets-no-route.md), [ADR-0017](adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md)) | +| A rooted range target reaching `gandalf` itself | **Dropped at `vmbr1`, before the host firewall, once applied.** The host has no address on the range bridge, but Linux answers ARP for its addresses on any interface and accepts a packet for them on any interface. So a target that adds an on-link route to `10.0.30.30` was reaching the host, and only the Proxmox firewall dropped it. Nothing watches that firewall on `gandalf`. A netdev `ingress` table on `vmbr1` now drops every frame the bridge passes up to the host, ARP included, without touching guest-to-guest traffic ([`build-the-playground.md`](runbooks/build-the-playground.md) §2, proved by §8 check four). Behind it, `gandalf` holds no estate credential, no GitHub login, no personal tooling and no third-party apt repository (§4, *Nothing else on `gandalf`*), so the host gives nothing beyond itself. The audits of 2026-11-13 and 2026-11-22 found credentials, then tooling and two third-party repositories. The credentials were gone by 2026-11-22. **The table and the tooling removal are not yet applied** | | Someone on Winterfell or Hicks logging in to `trinity` | **Key-only `sshd` since 2026-11-20; no host firewall by decision.** `trinity` holds the household's data and the sensitive tier's age key, and its `sshd` answers Hicks (by [ADR-0031](adr/0031-narrow-hicks-to-a-named-list-on-winterfell-and-leave-the-lab-open.md)'s list) and every host on VLAN 99, between which pfSense never filters. [`build-the-sensitive-tier-host.md`](runbooks/build-the-sensitive-tier-host.md) §3 now makes `sshd` key-only through a drop-in that outranks cloud-init's, refuses root and X11 forwarding, and keeps `authorized_keys` to `prometheus`'s key and Hicks's. The audit of 2026-11-13 found it taking passwords, with X11 forwarding on and 17 keys imported from GitHub. The step was applied on 2026-11-20: a password-only login is refused with `Permission denied (publickey)`, and three keys remain, `prometheus`'s, Hicks's and the operator's laptop, the last kept by decision. Agent sessions run on `trinity` as the operator, by decision ([ADR-0123](adr/0123-keep-agent-sessions-on-trinity.md)). `ufw` is installed and stays disabled, unlike `phoenix`'s ([ADR-0117](adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md)): the other two ports `trinity` answers, `443` and `53`, are published by Docker, whose rules run ahead of `ufw`'s, so a policy would govern `22` alone, which the drop-in already closes to anything without a key. Nothing routes through `trinity`, and as the spare firewall a host policy is one more thing to get in the way the day it stands in for `morpheus`. What reaches `443` and `53` is set by pfSense and by the stack's bind addresses | | Someone with the trusted Wi-Fi key quietly joining | Kea's lease log reaches Loki; `UnknownDeviceOnTrustedSegment` fires the first time a MAC appears on VLAN 50 in seven days ([ADR-0019](adr/0019-read-device-joins-from-the-dhcp-server.md)) | | Losing visibility of a failure | 182 alert rules, 30 days of metrics and logs | From f07c2e45b88eebac63a65f50986f5b45215dc7cd Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Sun, 22 Nov 2026 17:29:28 -0800 Subject: [PATCH 2/4] docs(adr): ADR-0124, power gandalf off on a timer Two audits found the range host left on for days, against the "off between sessions" that ADR-0017's "no monitoring" rests on. ADR-0124 chooses a timer on the host over a collector and an "on too long" alert. The host powers off six hours after boot or after the last range-extend (capped at twelve hours), warns 30 and 5 minutes before, and waits while dpkg holds its lock. ADR-0017 gains a note. build-the-playground.md section 7 says the timer is decided and not built. The changelog and roadmap gain entries, and README's ADR count is 124. #1647 builds it. Refs #1647. Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +- ...-for-iops-and-keep-the-range-disposable.md | 8 ++ docs/adr/0124-power-gandalf-off-on-a-timer.md | 101 ++++++++++++++++++ docs/changelog.md | 11 ++ docs/roadmap.md | 5 + docs/runbooks/build-the-playground.md | 9 ++ 6 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 docs/adr/0124-power-gandalf-off-on-a-timer.md diff --git a/README.md b/README.md index 87a8a203..914ae450 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ documents for different readers. at all. Every pinned digest is also scanned weekly for fixable HIGH and CRITICAL CVEs, and each image with findings has an open issue until a scan finds it clean. -- **Documented decisions and runbooks.** 123 ADRs covering what was chosen +- **Documented decisions and runbooks.** 124 ADRs covering what was chosen and what was rejected — including the costs accepted knowingly; 53 runbooks for the operations that are easy to get wrong at 1am, one of which is the handover page a successor reads first. Every critical alert links to @@ -236,7 +236,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology │ ├── architecture.md network.md hardware.md │ ├── observability.md security.md roadmap.md changelog.md │ ├── diagrams/ # the network diagram (SVG) and its predecessors -│ ├── adr/ # 123 ADRs — architecture decision records +│ ├── adr/ # 124 ADRs — architecture decision records │ ├── exercises/ # purple-team exercise records — see its README │ └── runbooks/ # 53 runbooks; successor-handover.md is the front door └── Makefile # make help diff --git a/docs/adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md b/docs/adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md index 6673d39b..eec32b30 100644 --- a/docs/adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md +++ b/docs/adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md @@ -2,6 +2,14 @@ **Status:** Accepted · 2026-09 +> [!NOTE] +> **"Off between sessions" is enforced by a timer.** Two audits found the +> range host left on for days, against the discipline that *No monitoring* +> and the second Consequence below rest on. +> [ADR-0124](0124-power-gandalf-off-on-a-timer.md) has the host power itself +> off six hours after boot or after a session's last extension. *No +> monitoring* stands. The text below is left as written, per ADR-0001. +> > [!NOTE] > **The host's name.** The machine this ADR calls `ifrit` is named > **`gandalf`** since 2026-11-07 diff --git a/docs/adr/0124-power-gandalf-off-on-a-timer.md b/docs/adr/0124-power-gandalf-off-on-a-timer.md new file mode 100644 index 00000000..0d1e4840 --- /dev/null +++ b/docs/adr/0124-power-gandalf-off-on-a-timer.md @@ -0,0 +1,101 @@ +# ADR-0124: Power `gandalf` off on a timer + +**Status:** Accepted · 2026-11 · amends +[ADR-0017](0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md) + +## Context + +[ADR-0017](0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md) gives +the range no monitoring, because the host is "off by design between +sessions". Every rule watching it would then be "permanently firing or +permanently silenced". Its Consequences name what that costs: "Nothing knows +whether `ifrit` is powered", and the useful statement, "this host is on when +it should be off", has no rule shape. So the box being off rests on a person +remembering. [`build-the-playground.md`](../runbooks/build-the-playground.md) +§7 says so: "Nothing is watching, so the discipline is yours." + +Two audits have found it left on: + +- **2026-11-13.** The host had been up since 2026-11-07, and the attack VM + `ragnarok` stayed running overnight with a lease on VLAN 30. +- **2026-11-22.** Nothing had changed for nine more days. The task log shows + `ragnarok` running from 2026-11-12 to 2026-11-22, and the host was up from + 2026-11-07 to 2026-11-22. The range disk's power-on hours rose by 224 in + nine days. + +Three things the design leans on assume the box is off most of the time: + +- **ADR-0017's "no monitoring".** It holds only while the box is off. +- **§7's per-session read-back.** It is how the host firewall is checked, + because no collector reaches `gandalf`. A fortnight of uptime is a + fortnight unchecked. +- **ADR-0014's exposure.** The attack VM shares VLAN 30 with the estate. It + is bounded by how long the attack VM is on, and nobody was bounding that. + +Three ways to stop relying on memory: + +1. **A collector and an "on too long" alert.** Give `gandalf` the + `pve-firewall-state` collector `Saruman` has, plus its uptime, and alert + when it has been up past a threshold. It would watch the firewall too. It + also overturns ADR-0017's "no monitoring" rather than amending it. It + needs an agent on the range host and a way for its metrics to reach + `prometheus` across the boundary ADR-0014 counts. And it reports the fault + rather than ending it: someone still has to act on the alert. +2. **A timer on the host that powers it off.** The host enforces the rule on + itself. Nothing crosses the boundary, nothing is added to the estate's + monitoring, and the fault ends whether or not anyone is paying attention. +3. **Both.** The timer ends the fault, and the collector watches the + firewall while the box is on. Most coverage, and still all of option 1's + cost. + +## Decision + +**`gandalf` powers itself off a fixed time after boot, or after the last +extension a session asks for.** Option 2. ADR-0017's "no monitoring" stands. +What changes is that "off between sessions" no longer depends on anyone. + +- **The deadline is six hours** after the later of the boot and the last + extension. A session is an afternoon. The 2026-11-22 session, which ran a + full upgrade, a reboot and an audit, fitted inside three hours. +- **A session can extend it.** A command on the host, `range-extend`, moves + the deadline to a given number of hours from now. One extension is capped + at twelve hours, so a typo or a "just leave it" cannot turn the timer off by + the back door. The deadline lives under `/run`, which a reboot clears, so + every boot starts the six hours again. +- **It warns before it acts.** `wall` reaches every shell on the host 30 + minutes and 5 minutes before the deadline, which is enough to extend from + the session already open. +- **It never powers off in the middle of a package install.** While `dpkg`'s + lock is held, it waits and checks again on its next run. +- **The power-off is the ordinary one.** `systemctl poweroff` runs Proxmox's + own guest shutdown, which stops every guest and forces any that ignore ACPI, + as Mr-Robot does. Reverting the targets to `clean` stays §7's step at the + start of the next session, which already reverts before any work. +- **A systemd timer runs the check every five minutes.** The script and its + two units are in the repository, and §7 installs them. §7's read-back + checks that the timer is enabled and active, so a disabled timer is caught + at the next power-on, as a disabled firewall is. + +Built under [#1647](https://github.com/Gerrrt/HomeLab/issues/1647). + +## Consequences + +- **A forgotten session ends by itself, at most six hours after it started + or was last extended.** The attack VM's time on VLAN 30, and the time the + host firewall goes unchecked, are bounded by that. Before this they were + bounded by nothing. +- **Nothing still watches the host firewall while the box is on.** This + decision bounds the window and leaves the check to §7. If a window without + a firewall check stops being acceptable, option 1 is still open, and it + would supersede ADR-0017's "no monitoring". +- **A long session has to extend.** Missing the warning costs the session, + not the range. The guests stop and the targets revert at the next start. + That is the price of a backstop that does not wait for someone to notice. +- **A disabled or broken timer puts the range back on discipline.** The + read-back catches it only at the next power-on. That is the same exposure + the firewall has today, and it is accepted for the same reason. +- **Powering on stays manual, as before.** The timer only turns the box off. +- **This decision is reopened** if the range starts needing to run unattended + for longer than an extension allows. That would mean something on it is + worth keeping on, and by ADR-0017's own rule it is then estate, on the + wrong machine. diff --git a/docs/changelog.md b/docs/changelog.md index f67b4ce4..710e9abd 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,17 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-22 +- **`gandalf` will power itself off on a timer + ([ADR-0124](adr/0124-power-gandalf-off-on-a-timer.md)).** Both audits of + `gandalf` found it left on for days, `ragnarok` included, against the + "off between sessions" that ADR-0017's "no monitoring" rests on. The ADR + chooses a timer on the host over a collector and an "on too long" alert. + The host powers off six hours after boot or after the last `range-extend`, + which is capped at twelve hours, with a warning 30 and 5 minutes before. + It never powers off while `dpkg` holds its lock. ADR-0017 gains a note, + and `build-the-playground.md` §7 says the timer is decided and not built. + [#1647](https://github.com/Gerrrt/HomeLab/issues/1647) builds it. + - **A second read-only audit of `gandalf` finds containment holding, and writes four fixes into the runbook.** It was run from Hicks after a power-on and a full upgrade. Holding: diff --git a/docs/roadmap.md b/docs/roadmap.md index a74328f0..8a8ee897 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -40,6 +40,11 @@ What an entry here may contain: Closes when it is empty. +- **[#1647](https://github.com/Gerrrt/HomeLab/issues/1647) Power `gandalf` + off on a timer.** Decided by + [ADR-0124](adr/0124-power-gandalf-off-on-a-timer.md). No gate. Until it is + built, the range's "off between sessions" rests on the operator, and two + audits found it left on. - **[#1226](https://github.com/Gerrrt/HomeLab/issues/1226) The HomePods in Home Assistant, for control.** Decided by [ADR-0099](adr/0099-control-the-homepods-from-home-assistant-and-leave-their-audio-out.md). diff --git a/docs/runbooks/build-the-playground.md b/docs/runbooks/build-the-playground.md index 2adec90f..2cb6ee7c 100644 --- a/docs/runbooks/build-the-playground.md +++ b/docs/runbooks/build-the-playground.md @@ -1076,6 +1076,15 @@ Then boot it, run §8's check four on it, power it off and take the snapshot ADR-0017 says why: every rule shape available says "this host is down", which is the normal state. Nothing is watching, so the discipline is yours. +Two audits found the box left on for days anyway (2026-11-13 and 2026-11-22). +[ADR-0124](../adr/0124-power-gandalf-off-on-a-timer.md) takes the backstop +off the person: a timer on the host powers it off six hours after boot, or +after the last `range-extend`, with a warning on every shell 30 and 5 minutes +before. **It is decided and not built yet** +([#1647](https://github.com/Gerrrt/HomeLab/issues/1647)). Until it is, the +power-off at the end below is still yours alone. Once it is built, this +section installs it and the read-back checks it is enabled. + ```text on → read the firewall back → revert every target to `clean` → work → revert → off ``` From 588b92a9ee3c038bfc1bb5d67c887318000b64d0 Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Sun, 22 Nov 2026 17:41:14 -0800 Subject: [PATCH 3/4] docs(adr): ADR-0124's six hours is the default deadline, not the bound range-extend replaces the deadline with 1 to 12 hours from now, and the power-off can lag the deadline by a timer period and by a held dpkg lock. The decision and the first Consequence now say so, and the ADR-0017 note, the changelog entry and section 7 match. Co-Authored-By: Claude Opus 5.5 --- ...-for-iops-and-keep-the-range-disposable.md | 3 ++- docs/adr/0124-power-gandalf-off-on-a-timer.md | 26 ++++++++++--------- docs/changelog.md | 5 ++-- docs/runbooks/build-the-playground.md | 5 ++-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/docs/adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md b/docs/adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md index eec32b30..a3080b22 100644 --- a/docs/adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md +++ b/docs/adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md @@ -7,7 +7,8 @@ > range host left on for days, against the discipline that *No monitoring* > and the second Consequence below rest on. > [ADR-0124](0124-power-gandalf-off-on-a-timer.md) has the host power itself -> off six hours after boot or after a session's last extension. *No +> off at a deadline: six hours after boot, or what a session's last +> extension set, up to twelve hours ahead. *No > monitoring* stands. The text below is left as written, per ADR-0001. > > [!NOTE] diff --git a/docs/adr/0124-power-gandalf-off-on-a-timer.md b/docs/adr/0124-power-gandalf-off-on-a-timer.md index 0d1e4840..b5a954bb 100644 --- a/docs/adr/0124-power-gandalf-off-on-a-timer.md +++ b/docs/adr/0124-power-gandalf-off-on-a-timer.md @@ -54,14 +54,14 @@ Three ways to stop relying on memory: extension a session asks for.** Option 2. ADR-0017's "no monitoring" stands. What changes is that "off between sessions" no longer depends on anyone. -- **The deadline is six hours** after the later of the boot and the last - extension. A session is an afternoon. The 2026-11-22 session, which ran a - full upgrade, a reboot and an audit, fitted inside three hours. -- **A session can extend it.** A command on the host, `range-extend`, moves - the deadline to a given number of hours from now. One extension is capped - at twelve hours, so a typo or a "just leave it" cannot turn the timer off by - the back door. The deadline lives under `/run`, which a reboot clears, so - every boot starts the six hours again. +- **The deadline is six hours after boot by default.** A session is an + afternoon. The 2026-11-22 session, which ran a full upgrade, a reboot and an + audit, fitted inside three hours. +- **A session can replace it.** A command on the host, `range-extend H`, sets + the deadline H hours from now, whatever the default or an earlier extension + had set. H is 1 to 12, so a typo or a "just leave it" cannot turn the timer + off by the back door. The deadline lives under `/run`, which a reboot + clears, so every boot starts again from the six-hour default. - **It warns before it acts.** `wall` reaches every shell on the host 30 minutes and 5 minutes before the deadline, which is enough to extend from the session already open. @@ -80,10 +80,12 @@ Built under [#1647](https://github.com/Gerrrt/HomeLab/issues/1647). ## Consequences -- **A forgotten session ends by itself, at most six hours after it started - or was last extended.** The attack VM's time on VLAN 30, and the time the - host firewall goes unchecked, are bounded by that. Before this they were - bounded by nothing. +- **A forgotten session ends by itself.** The bound is the deadline: six + hours after boot, or up to twelve hours after the last `range-extend`. It + is late by up to one five-minute timer period, and by as long as `dpkg` + holds its lock past the deadline, which is unbounded if `dpkg` hangs. The + attack VM's time on VLAN 30, and the time the host firewall goes + unchecked, are bounded that way. Before this they were bounded by nothing. - **Nothing still watches the host firewall while the box is on.** This decision bounds the window and leaves the check to §7. If a window without a firewall check stops being acceptable, option 1 is still open, and it diff --git a/docs/changelog.md b/docs/changelog.md index 710e9abd..4cf79693 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -24,8 +24,9 @@ docstring gives: it is a record, not a claim about now. `gandalf` found it left on for days, `ragnarok` included, against the "off between sessions" that ADR-0017's "no monitoring" rests on. The ADR chooses a timer on the host over a collector and an "on too long" alert. - The host powers off six hours after boot or after the last `range-extend`, - which is capped at twelve hours, with a warning 30 and 5 minutes before. + The host powers off at a deadline: six hours after boot by default, or + what the last `range-extend` set, 1 to 12 hours ahead. It warns 30 and 5 + minutes before. It never powers off while `dpkg` holds its lock. ADR-0017 gains a note, and `build-the-playground.md` §7 says the timer is decided and not built. [#1647](https://github.com/Gerrrt/HomeLab/issues/1647) builds it. diff --git a/docs/runbooks/build-the-playground.md b/docs/runbooks/build-the-playground.md index 2cb6ee7c..82ab63aa 100644 --- a/docs/runbooks/build-the-playground.md +++ b/docs/runbooks/build-the-playground.md @@ -1078,8 +1078,9 @@ the normal state. Nothing is watching, so the discipline is yours. Two audits found the box left on for days anyway (2026-11-13 and 2026-11-22). [ADR-0124](../adr/0124-power-gandalf-off-on-a-timer.md) takes the backstop -off the person: a timer on the host powers it off six hours after boot, or -after the last `range-extend`, with a warning on every shell 30 and 5 minutes +off the person: a timer on the host powers it off at a deadline, six hours +after boot by default or what the last `range-extend` set (1 to 12 hours +ahead), with a warning on every shell 30 and 5 minutes before. **It is decided and not built yet** ([#1647](https://github.com/Gerrrt/HomeLab/issues/1647)). Until it is, the power-off at the end below is still yours alone. Once it is built, this From 7f42fedf93811981d4729efa33c42034192f854d Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Sun, 22 Nov 2026 17:47:49 -0800 Subject: [PATCH 4/4] docs(adr): ADR-0124's check runs every minute, under one lock Review on #1649: a five-minute cadence equals the five-minute warning window, so a late run could skip the last warning. And without a lock, a check could act on a deadline an extension had just replaced. The decision now says every minute and one lock, and the Consequence's lag is about a minute. Co-Authored-By: Claude Opus 5.5 --- docs/adr/0124-power-gandalf-off-on-a-timer.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/adr/0124-power-gandalf-off-on-a-timer.md b/docs/adr/0124-power-gandalf-off-on-a-timer.md index b5a954bb..5e4442ae 100644 --- a/docs/adr/0124-power-gandalf-off-on-a-timer.md +++ b/docs/adr/0124-power-gandalf-off-on-a-timer.md @@ -71,8 +71,11 @@ What changes is that "off between sessions" no longer depends on anyone. own guest shutdown, which stops every guest and forces any that ignore ACPI, as Mr-Robot does. Reverting the targets to `clean` stays §7's step at the start of the next session, which already reverts before any work. -- **A systemd timer runs the check every five minutes.** The script and its - two units are in the repository, and §7 installs them. §7's read-back +- **A systemd timer runs the check every minute.** That is well inside the + five-minute warning window, so a late run cannot skip the last warning. A + check and an extension hold one lock, so a check never acts on a deadline + an extension has just replaced. The script and its two units are in the + repository, and §7 installs them. §7's read-back checks that the timer is enabled and active, so a disabled timer is caught at the next power-on, as a disabled firewall is. @@ -82,7 +85,7 @@ Built under [#1647](https://github.com/Gerrrt/HomeLab/issues/1647). - **A forgotten session ends by itself.** The bound is the deadline: six hours after boot, or up to twelve hours after the last `range-extend`. It - is late by up to one five-minute timer period, and by as long as `dpkg` + is late by about a minute, one timer period, and by as long as `dpkg` holds its lock past the deadline, which is unbounded if `dpkg` hangs. The attack VM's time on VLAN 30, and the time the host firewall goes unchecked, are bounded that way. Before this they were bounded by nothing.