From 21b827a9c4043d72f9665e12388f6d2ac8cb6e45 Mon Sep 17 00:00:00 2001 From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:49:34 -0800 Subject: [PATCH 1/2] docs(saruman): record the 2026-11-13 audit, and a runbook to close what it found A read-only audit of Saruman found sshd taking root's password, no second factor on root@pam, an undeclared token phoenix@pve!builder2, third-party apt sources, rpcbind on every address and leftovers in /root. harden-saruman.md holds the fix for each, none applied yet. security.md now says the firewall admits 8007 from Hicks, as ADR-0014 and network.md do, and names the gap behind the firewall. The changelog records the audit, and corrects its own Ceph claim: Proxmox depends on ceph-common and ceph-fuse. Refs #574 Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +- docs/changelog.md | 45 ++++++++ docs/runbooks/harden-saruman.md | 192 ++++++++++++++++++++++++++++++++ docs/security.md | 2 +- 4 files changed, 240 insertions(+), 3 deletions(-) create mode 100644 docs/runbooks/harden-saruman.md diff --git a/README.md b/README.md index d8debbc58..6a51c6eb5 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ documents for different readers. CRITICAL CVEs, and each image with findings has an open issue until a scan finds it clean. - **Documented decisions and runbooks.** 116 ADRs covering what was chosen - and what was rejected — including the costs accepted knowingly; 54 + and what was rejected — including the costs accepted knowingly; 55 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 one. @@ -237,7 +237,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology │ ├── diagrams/ # the network diagram (SVG) and its predecessors │ ├── adr/ # 116 ADRs — architecture decision records │ ├── exercises/ # purple-team exercise records — see its README -│ └── runbooks/ # 54 runbooks; successor-handover.md is the front door +│ └── runbooks/ # 55 runbooks; successor-handover.md is the front door └── Makefile # make help ``` diff --git a/docs/changelog.md b/docs/changelog.md index 34be002c2..0c7166bae 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,51 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-14 +- **An audit of `Saruman`, read-only, found its management plane open to a + password behind the firewall, an undeclared API token, and two snapshots + that could roll back the domain.** It was read on the box on 2026-11-13, + against this repository at `2276e75`. + [`harden-saruman.md`](runbooks/harden-saruman.md) is new and holds the + fixes, none of them applied yet. + - **What matched.** 21 guests with the VMIDs and names in `network.md` + and `tofu/`, and the `on-demand` tag on exactly the guests that should + carry it. Templates 901 and 903–912 are present, and 902 is on `gandalf`. + `golem-nightly` holds exactly the `backup`-tagged guests. Both firewall + levels are on with `policy_in: DROP`, `local_network` is `10.0.30.20`, + and `management` holds only that address. The Zeek mirror runs on 14 of + 14 ports. There is no Docker. No updates were pending, and the newest + kernel was running. The array, the cache battery, ECC and the SSDs' SMART + all read OK, and all 12 collectors were fresh. The fans, PSUs and + temperatures were read through `shiva` the same day and are OK. + - **What did not.** + - [ADR-0107](adr/0107-subscribe-trinity-to-the-ups-and-bound-saruman-s-guest-stop.md)'s + `Saruman` half was not applied. It was applied the same day, in its + own change. + - `sshd` took root's password and allowed X11 forwarding, and + `root@pam` had no second factor on `8006`. + - A second token, `phoenix@pve!builder2`, has no expiry and privilege + separation off. Nothing in this repository names it, and its access + logs show no request from 2026-10-12 on. + - The `pre449weaknesses` snapshot from 2026-10-07 is still on 150–153. + Rolling back a domain controller five weeks would roll back the + domain's update sequence numbers. + - The nightly backup's fs-freeze times out on `titan` (152) and `ramuh` + (153). The 2026-11-07 run failed for `garuda` with a write timeout to + `golem`. + - The 1Password, charm and Proxmox debug-symbol apt sources are + configured, and Debian is listed twice. An old self-made CA with its + key, and copies of `pveproxy`'s certificate, sit in `/root`. + - `rpcbind` listens on `111`. One spindle reads a reallocated sector of + 1, which only the iLO watches. + - **Corrected here.** `security.md` said the firewall admits `8006` and + `22` from Hicks. It admits `8007` too, as ADR-0014 decided and + `network.md` says, and nothing listens there. The audit also listed the + Ceph source and `ceph-common` and `ceph-fuse` as unneeded. + `libpve-storage-perl` and `pve-qemu-kvm` depend on both, so they stay, + and the runbook says so. + - **Not decided here.** Deleting the snapshots and the freeze on the + two Windows servers are left to the operator. Neither is a host setting. + - **`trinity`'s age-key deadline is declared, as `verify-key-backup-sensitive`, and a sensitive key copy can now be proved.** A read-only audit of `trinity` on 2026-11-13 found both recipients in its diff --git a/docs/runbooks/harden-saruman.md b/docs/runbooks/harden-saruman.md new file mode 100644 index 000000000..d8eaaa57c --- /dev/null +++ b/docs/runbooks/harden-saruman.md @@ -0,0 +1,192 @@ +# Runbook: Close what `Saruman`'s installer and its history left open + +**The hypervisor holds every lab guest. Its firewall is the only control +in front of a root password, and its apt sources trust vendors that the +host does not need.** + +> **Status — 2026-11-14: written, and nothing applied yet.** A read-only +> audit of `Saruman` on 2026-11-13 found each item below. Every section ends +> with the check that proves it was applied. + +`Saruman`'s Proxmox firewall admits `22`, `8006` and `8007` from Hicks and +`8006` from `phoenix`, and drops everything else +([ADR-0014](../adr/0014-put-ifrit-on-imaginationlan-and-give-the-targets-no-route.md), +[`network.md`](../network.md)). `PveFirewallDisabled` pages if it goes off. +Behind it, sshd still accepts root's password, and so does `8006`. A +workstation on Hicks, or the whole of VLAN 30 if the firewall stops, is one +guessed password from root on the host. `gandalf` +([`build-the-playground.md`](build-the-playground.md) §4) and `golem` +([`build-the-backup-guest.md`](build-the-backup-guest.md) §2) are both closed +the same way. This runbook does the same for `Saruman`. + +## 0. Before you start + +- **Have the console to hand.** `shiva`'s remote console is the way back if + SSH locks you out. It needs root's password, which this runbook leaves set. +- **Root logs in by key from Hicks.** Every workstation that runs + `deploy-agent.sh` or `install-agent-collectors.sh` against `Saruman` needs + its key in `/root/.ssh/authorized_keys` before §1. Prove it from each one: + + ```bash + ssh -o PasswordAuthentication=no root@10.0.30.20 true + ``` + + It must return with no password prompt. + +## 1. SSH: keys only, no X11 + +Open a root shell on `Saruman` from Hicks with a key, and leave it open until +the checks pass. `sshd` keeps sessions that are already open, so this shell +is the way back. In it: + +```bash +printf '%s\n' \ + '# harden-saruman.md §1: keys only. Root logs in by key, never by password.' \ + 'PermitRootLogin prohibit-password' \ + 'PasswordAuthentication no' \ + 'KbdInteractiveAuthentication no' \ + 'X11Forwarding no' \ + > /etc/ssh/sshd_config.d/10-keys-only.conf +sshd -t && systemctl reload ssh +sshd -T | grep -E '^(permitrootlogin|passwordauthentication|kbdinteractiveauthentication|x11forwarding) ' +``` + +**You should see** `permitrootlogin without-password`, `passwordauthentication +no`, `kbdinteractiveauthentication no` and `x11forwarding no`. 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 a second terminal on Hicks: + +```bash +ssh -o PubkeyAuthentication=no -o PreferredAuthentications=password root@10.0.30.20 true +ssh -o PasswordAuthentication=no root@10.0.30.20 true +``` + +The first must fail with `Permission denied (publickey)` and no password +prompt. The second must succeed. If it fails, go back to the open shell, +remove the drop-in and run `systemctl reload ssh`. + +## 2. A second factor on `root@pam` + +`root@pam` on `8006` can do everything the host can. In the web UI: +*Datacenter → Permissions → Two Factor → Add → TOTP*, user `root@pam`. Then +add *Recovery Keys* for the same user, and keep them with root's password, +not in this repository. + +API tokens do not take a second factor, so `phoenix`'s `builder` token is +unaffected. Neither are `qm` and `pvesh` from a root shell, or the console +login. + +**Check:** log out, and log in again as `root@pam`. It must ask for the +code. If a phone is lost and the recovery keys with it, a root shell can +remove the factor: `pveum user tfa delete root@pam`. + +## 3. One API token for `phoenix`, not two + +[`build-the-jumpbox.md`](build-the-jumpbox.md) declares one token, +`phoenix@pve!builder`, and `tofu/` and Packer use it. `Saruman` also holds +`phoenix@pve!builder2`, with no expiry and privilege separation off, so it +carries all of `phoenix`'s rights. Nothing in this repository or its +history names it, nothing in the journal records its creation, and +`pveproxy`'s access logs show no request from it between 2026-10-12 and +2026-11-14. `builder` made hundreds in the same period. + +```bash +pveum user token remove phoenix@pve builder2 +pveum user token list phoenix@pve +``` + +**You should see** one row, `builder`. If something breaks afterwards, it +used the token. Record what it was before giving it a token of its own. + +## 4. What the host runs, and the apt sources it trusts + +This is what `Saruman` needs: + +| Source | For | +| --- | --- | +| Debian `trixie`, `trixie-updates`, `trixie-security` | The base system | +| `download.proxmox.com` `pve-no-subscription` | Proxmox VE | +| `download.proxmox.com` `ceph-tentacle` `no-subscription` | `ceph-common` and `ceph-fuse`. `libpve-storage-perl` and `pve-qemu-kvm` depend on them, so they stay, even with no Ceph cluster | +| HPE `mcp` | `ssacli`, which reads the P440ar ([`fit-the-saruman-ssds.md`](fit-the-saruman-ssds.md)) | + +Alloy, the native agent +([ADR-0020](../adr/0020-run-the-lab-stack-in-a-guest-with-its-own-prometheus.md)), +needs no source: `deploy-agent.sh` installs a pinned `.deb` from Grafana's +releases. + +Anything else is a vendor running code as root on the host that holds every +guest. The audit found three: + +- `1password.list`, for `1password-cli`; +- `charm.list`, for `glow` and `gum`; +- `pve-dbgsym.sources`, with no debug-symbol package installed from it. + +It also found Debian listed twice in `debian.sources`, once from +`deb.debian.org` and once from `ftp.us.debian.org`. + +```bash +apt-get purge 1password-cli glow gum +rm /etc/apt/sources.list.d/1password.list /etc/apt/sources.list.d/charm.list \ + /etc/apt/sources.list.d/pve-dbgsym.sources \ + /etc/apt/keyrings/1password.gpg /etc/apt/keyrings/charm.gpg +``` + +Edit `/etc/apt/sources.list.d/debian.sources` so that each suite appears once, +from `deb.debian.org`. Then: + +```bash +apt-get update && ls /etc/apt/sources.list.d/ +``` + +**You should see** `apt-get update` finish with no warning about duplicate +targets, and only `ceph.sources`, `debian.sources`, `hpe-mcp.list` and +`proxmox.sources`. + +## 5. `rpcbind` off + +The ISO store is mounted over NFSv4.2 +([ADR-0072](../adr/0072-put-the-iso-store-on-smaug-over-nfs-to-saruman-alone.md)), +and NFSv4 needs no portmapper on the client. Proxmox's NFS check queries +`smaug`'s portmapper, not this host's. `rpcbind` listens on `111` on every +address anyway. The firewall drops it, but nothing on the host needs it. + +```bash +systemctl disable --now rpcbind.socket rpcbind.service +``` + +**Check:** reboot in a maintenance window, then `findmnt -t nfs4` shows the +ISO share, `pvesm status` shows its storage `active`, and `ss -tlnp | grep +:111` prints nothing. + +## 6. Leftovers in `/root`, and old kernels + +The audit found these in `/root`, none of them in use: + +- `ca.pem`, `ca-key.pem`, `cert.pem` and `cert-key.pem` from 2025-09-14: a + self-made CA and its leaf. `pveproxy` serves the Proxmox CA's certificate. +- The `pveproxy-ssl.*` copies that + [`build-the-lab-templates.md`](build-the-lab-templates.md) makes. +- `cluster.fw.new`, which is identical to the live firewall file. + +Read each one before you delete it. Keep `pre-421-s3/` only if it is still +wanted. + +Five removed kernels left `rc` packages behind. One more, +`proxmox-kernel-6.8.12-9-pve-signed`, is still installed, and +`proxmox-boot-tool kernel list` does not select it: + +```bash +apt-get purge proxmox-kernel-6.8.12-9-pve-signed +dpkg -l | awk '/^rc/ && /proxmox-kernel/ {print $2}' | xargs -r apt-get purge -y +proxmox-boot-tool refresh +``` + +**Check:** `dpkg -l | grep -c '^rc'` counts no kernels, and `ls /boot` holds +only kernels in `proxmox-boot-tool kernel list`. + +## 7. Write down what is now true + +Record each applied section in [`changelog.md`](../changelog.md) on the day, +with what its check printed, and update this runbook's status line. diff --git a/docs/security.md b/docs/security.md index 0175f5cfd..fd979b612 100644 --- a/docs/security.md +++ b/docs/security.md @@ -16,7 +16,7 @@ What this network is actually built to survive: | A lab VM escaping into the house | VLAN 30 reachable only *from* trusted, never *to* it; the lab tripwire logs anything that gets past the blocks ([#234](https://github.com/Gerrrt/HomeLab/issues/234)) | | A lost or stolen tunnel peer | **Accepted.** A WireGuard peer is a device with a key and no second factor ([ADR-0042](adr/0042-terminate-the-remote-path-on-the-lab-and-route-it.md)); the firewall, not the key, bounds what it reaches — the lab and nothing else — with a `/32` pin on the server and a preshared key per peer. Revocation is a `wg0.conf` edit on `phoenix` ([runbook](runbooks/open-the-remote-path.md#rollback)), proportionate at two or three devices and recorded as the thing that stops being so | | An attacker on the lab segment reaching the hypervisor's BMC | **Accepted.** `shiva` stays on VLAN 30 by decision ([ADR-0033](adr/0033-keep-the-ilo-on-the-lab-segment.md)), hardened on 2026-09-09 — IPMI-over-LAN, SSH and Federation off, and its one path out of the segment deleted; a BMC compromise in the lab costs the lab, and the tripwire watches what it initiates | -| An attacker on the lab segment reaching the hypervisor's management plane | **Closed at the host, and watched.** `Saruman`'s Proxmox firewall admits `8006` and `22` from Hicks and `8006` from the deployment host only ([ADR-0014](adr/0014-put-ifrit-on-imaginationlan-and-give-the-targets-no-route.md), [ADR-0043](adr/0043-keep-the-ca-on-prometheus-and-build-phoenix-as-the-deployment-host.md)). It was found disabled and turned on on 2026-09-20 ([#566](https://github.com/Gerrrt/HomeLab/issues/566)); since [#576](https://github.com/Gerrrt/HomeLab/issues/576) `homelab_pve_firewall_enabled` is read every five minutes and `PveFirewallDisabled` pages after ten, so a `pve-firewall stop` left in place is noticed rather than found. `PveFirewallPolicyAccept` does the same for `policy_in` left at `ACCEPT`, which reads as enabled and admits the whole segment | +| An attacker on the lab segment reaching the hypervisor's management plane | **Closed at the host, and watched.** `Saruman`'s Proxmox firewall admits `8006`, `8007` and `22` from Hicks and `8006` from the deployment host only. Nothing on `Saruman` listens on `8007`: ADR-0014 wrote one rule for two hypervisors ([ADR-0014](adr/0014-put-ifrit-on-imaginationlan-and-give-the-targets-no-route.md), [ADR-0043](adr/0043-keep-the-ca-on-prometheus-and-build-phoenix-as-the-deployment-host.md)). It was found disabled and turned on on 2026-09-20 ([#566](https://github.com/Gerrrt/HomeLab/issues/566)); since [#576](https://github.com/Gerrrt/HomeLab/issues/576) `homelab_pve_firewall_enabled` is read every five minutes and `PveFirewallDisabled` pages after ten, so a `pve-firewall stop` left in place is noticed rather than found. `PveFirewallPolicyAccept` does the same for `policy_in` left at `ACCEPT`, which reads as enabled and admits the whole segment. Behind the firewall, an audit on 2026-11-13 found that `sshd` still takes root's password and `root@pam` has no second factor on `8006`. [`harden-saruman.md`](runbooks/harden-saruman.md) closes both, and neither is applied yet | | Someone on the lab segment reaching the domain's configuration path | **Scoped, key-only, and accepted for `phoenix` itself.** Each of ADR-0029's six listens on `22` for `ansible/` ([ADR-0077](adr/0077-configure-the-lab-domain-with-ansible-from-phoenix.md)). The rule admits `10.0.30.70` alone, `sshd` refuses passwords, and the only administrators' key is `phoenix`'s, installed by the template and never by hand on a clone. The residual: whoever owns `phoenix` owns the lab domain. That was already true through its Proxmox token, so it adds reach to nothing. Host keys are not pinned, because every rebuild replaces them | | Someone on the lab segment logging in to the sensor | **Authored, and live only once applied.** `fenrir` listens on `22` to the whole segment and has no host firewall. [`build-the-sensor-guest.md`](runbooks/build-the-sensor-guest.md) §3 makes `sshd` key-only for one user, refuses root and X11 forwarding, and keeps `authorized_keys` to the machines that administer the guest. Until that step has run on `fenrir`, the installer's `sshd` defaults are the running state. The source address stays open: anyone on the segment can still offer a key | | Someone on the lab segment reading the domain's metrics | **Scoped, unauthenticated, and accepted.** `windows_exporter` listens on `9182` on all six of ADR-0029's guests, on the segment that exists to hold attackers. Each guest's Windows Firewall admits `10.0.30.40` (`alexander`) alone ([`build-the-lab-domain.md`](runbooks/build-the-lab-domain.md) §7). That rule is the difference between an endpoint a `/24` sweep finds and one you have to go looking for, and it is a residual, not a control: the exporter has no authentication, so whoever owns `alexander` reads every gauge. It has no write API, so what leaks is the shape of the host (services, disks, uptime, the licence clock), the same class as `node_exporter` on the NAS below | From a01af004919cac39c0c2af1573f9b35d9001b3d7 Mon Sep 17 00:00:00 2001 From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:53:44 -0800 Subject: [PATCH 2/2] docs(saruman): mask rpcbind, and give the TFA recovery its --id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review on #1515: harden-saruman.md §5 now masks rpcbind.socket and rpcbind.service as well as disabling them, as build-the-playground.md does, since nfs-common stays for the ISO mount. Applied on Saruman the same day; a fresh NFSv4 mount with both masked succeeded. §2 lists the factors and deletes one by --id, and says no --id deletes them all. Co-Authored-By: Claude Opus 5.5 --- docs/changelog.md | 8 +++++--- docs/runbooks/harden-saruman.md | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 7b3bfa7ef..07771062a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -35,9 +35,11 @@ docstring gives: it is a record, not a claim about now. `security.debian.org`, with `contrib` kept. `apt-get update` warns of nothing. `sources.list.d` holds `ceph.sources`, `debian.sources`, `hpe-mcp.list` and `proxmox.sources`. - - **§5.** `rpcbind.socket` and `rpcbind.service` are disabled and stopped. - Nothing listens on `111`, and the ISO store is still mounted over NFSv4.2 - and `active`. The reboot check is owed. + - **§5.** `rpcbind.socket` and `rpcbind.service` are disabled, stopped and + masked, so no other unit's dependency can start them. Nothing listens on + `111`. The ISO store is still mounted over NFSv4.2 and `active`, and a + fresh NFSv4 mount of the share with both masked succeeded. The reboot + check is owed. - **§6.** The self-made CA, its leaf and chain, the `pveproxy-ssl.*` copies and `cluster.fw.new` are deleted from `/root`. None was in use: `8006` serves a different certificate, and `cluster.fw.new` matched the diff --git a/docs/runbooks/harden-saruman.md b/docs/runbooks/harden-saruman.md index 9c765ba1a..7b42b9ad3 100644 --- a/docs/runbooks/harden-saruman.md +++ b/docs/runbooks/harden-saruman.md @@ -4,8 +4,8 @@ in front of a root password, and its apt sources trust vendors that the host does not need.** -> **Status — 2026-11-25: §1, §3, §4 and §6 applied and checked; §5 applied, -> its reboot check owed; §2 not done.** A read-only audit of `Saruman` on +> **Status — 2026-11-25: §1, §3, §4 and §6 applied and checked; §5 applied +> and masked, its reboot check owed; §2 not done.** A read-only audit of `Saruman` on > 2026-11-13 found each item below. Every section ends with the check that > proves it was applied. §2 is the operator's, in the web UI. §5's check > waits for the next reboot. `pre-421-s3/` in `/root` is kept until the @@ -83,7 +83,9 @@ login. **Check:** log out, and log in again as `root@pam`. It must ask for the code. If a phone is lost and the recovery keys with it, a root shell can -remove the factor: `pveum user tfa delete root@pam`. +remove the factor. `pveum user tfa list root@pam` prints each factor's ID; +`pveum user tfa delete root@pam --id ` removes that one, and with no +`--id` it removes every factor the user has. ## 3. One API token for `phoenix`, not two @@ -154,11 +156,19 @@ The ISO store is mounted over NFSv4.2 and NFSv4 needs no portmapper on the client. Proxmox's NFS check queries `smaug`'s portmapper, not this host's. `rpcbind` listens on `111` on every address anyway. The firewall drops it, but nothing on the host needs it. +`nfs-common` stays for the mount, so mask the two units as well as disabling +them: a mask stops another unit's dependency from starting them again, as +[`build-the-playground.md`](build-the-playground.md) does on `gandalf`. ```bash systemctl disable --now rpcbind.socket rpcbind.service +systemctl mask rpcbind.socket rpcbind.service ``` +A fresh NFSv4 mount of the share at a scratch directory proves the mount +needs neither before the reboot does. If an NFSv3 store is ever added, +unmask and enable them first. + **Check:** reboot in a maintenance window, then `findmnt -t nfs4` shows the ISO share, `pvesm status` shows its storage `active`, and `ss -tlnp | grep :111` prints nothing.