diff --git a/README.md b/README.md index 1b8e1624..629c51f7 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,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.** 134 ADRs covering what was chosen - and what was rejected — including the costs accepted knowingly; 56 + and what was rejected — including the costs accepted knowingly; 57 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. @@ -238,7 +238,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology │ ├── diagrams/ # the network diagram (SVG) and its predecessors │ ├── adr/ # 134 ADRs — architecture decision records │ ├── exercises/ # purple-team exercise records — see its README -│ └── runbooks/ # 56 runbooks; successor-handover.md is the front door +│ └── runbooks/ # 57 runbooks; successor-handover.md is the front door └── Makefile # make help ``` diff --git a/docs/changelog.md b/docs/changelog.md index ebfe4cc5..07771062 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,38 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-25 +- **`harden-saruman.md` is applied on `Saruman`, except §2 and §5's + reboot check.** It closes what the audit of 2026-11-13 found on the host. + - **§1.** A drop-in, `/etc/ssh/sshd_config.d/10-keys-only.conf`, turns off + password and keyboard-interactive logins and X11 forwarding, and keeps + root to keys. Every SSH login since 2026-09-25 had used a key. `sshd -T` + reads `without-password`, `no`, `no`, `no`. A password attempt is offered + `publickey` only and refused, and a key login still works. + - **§3.** `phoenix@pve!builder2` is removed. `pveproxy`'s access logs held + no request from it, against 1,101 from `builder`. `pveum user token list` + shows `builder` alone. + - **§4.** `1password-cli`, `glow` and `gum` are purged, and the 1Password, + charm and debug-symbol sources and their keyrings are gone. + `debian.sources` names each suite once, from `deb.debian.org` and + `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, 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 + live file. `pre-421-s3/` stays until the operator decides. + `proxmox-kernel-6.8.12-9-pve-signed` and six `rc` kernel packages are + purged. `/boot` and GRUB hold 6.8.12-43, 7.0.14-28 and 7.0.14-30, the + three `proxmox-boot-tool kernel list` selects. + - **Not done.** §2, a second factor on `root@pam`, is the operator's. + The `pre449weaknesses` snapshots and the fs-freeze timeouts on `titan` + and `ramuh` are not part of the runbook and are unchanged. + - **`neo` is on RouterOS 7.24.7 long-term.** Upgraded from 7.24.6 at 01:00 UTC under a one-hour silence on `component=~"internet|network"`, after a verified `make backup-switch`. The download staged in RAM and left @@ -34,6 +66,53 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-24 +- **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`. + It is filed on 2026-11-24, when it merged. A read of the box that day + found every item below as described, except ADR-0107. + [`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. + - **The wall page's files are served with `Cache-Control: no-cache`.** The card-by-card review's changes, below, reached `trinity` at `c5374a15`, but `heimdall`'s kiosk kept running the old `wall.js` through a Chromium diff --git a/docs/runbooks/harden-saruman.md b/docs/runbooks/harden-saruman.md new file mode 100644 index 00000000..7b42b9ad --- /dev/null +++ b/docs/runbooks/harden-saruman.md @@ -0,0 +1,209 @@ +# 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-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 +> operator decides. + +`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 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 + +[`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. +`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. + +## 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`, `cert-key.pem` and `fullchain.pem` + from 2025-09-14: a self-made CA, its leaf and the chain of the two. + `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. + +Removed kernels left `rc` packages behind: six on 2026-11-24. One more, +`proxmox-kernel-6.8.12-9-pve-signed`, is still installed, and +`proxmox-boot-tool kernel list` does not select it. Leave +`proxmox-kernel-6.8` and the 6.8 kernel it pulls in, 6.8.12-43 on +2026-11-24. `proxmox-boot-tool kernel list` selects it, so it is the way +back if a 7.0 kernel will not boot. + +```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 c50e32ff..0b1a6822 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 rule to the monitoring host deleted — and again on 2026-11-13, when a re-read found what that missed: a second administrator account, now deleted, the unauthenticated XML reply and SSDP, now off, and the lab's outbound internet through its DHCP gateway, now blocked on `morpheus`, so it reaches nothing off the segment ([`hardware.md`](hardware.md#management)); 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 `sshd` taking root's password and `root@pam` with no second factor on `8006`. Since 2026-11-25 `sshd` takes keys only and refuses X11 forwarding ([`harden-saruman.md`](runbooks/harden-saruman.md) §1). The second factor is §2, and it is not set 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. `phoenix`'s own way in is narrowed to match by [ADR-0117](adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md): its `sshd` takes keys only, and its `ufw` admits `22` from Hicks and the tunnel's peers and nothing from the rest of VLAN 30. Applied 2026-11-19 ([#1496](https://github.com/Gerrrt/HomeLab/issues/1496)): `sshd -T` reads `no` for password, keyboard-interactive and root login, and `22` from `alexander` times out | | Someone on the lab segment logging in to the sensor | **Closed at `sshd`.** `fenrir` sees every frame on `Saruman`'s lab bridge, and its `sshd` answers all of VLAN 30 with no host firewall. [`build-the-sensor-guest.md`](runbooks/build-the-sensor-guest.md) §3 makes `sshd` key-only for one user through a drop-in that outranks cloud-init's, refuses root and X11 forwarding, and keeps `authorized_keys` to the machines that administer the guest. The audit of 2026-11-13 found it very likely taking passwords, with X11 forwarding on and 18 distinct keys authorized, most imported from GitHub. The step was applied on 2026-11-17: `sshd -T` read `no` for all four settings with `allowusers atreus`, and `authorized_keys` went from 20 lines to the 2 keys that had logged in. The source address stays open: anyone on the segment can still offer a key | | Someone who takes the sensor reaching beyond its traffic | **Closed by clearing the guest, and re-checked hourly for drift by accident.** `fenrir` is an appliance ([`build-the-sensor-guest.md`](runbooks/build-the-sensor-guest.md) §0): the sensor stack, the agent collectors, the repository checkout and the stack's age key, and nothing else. The audit of 2026-11-13 found it used as a workstation as well: dotfiles, a stored Claude Code login with npm MCP servers reaching the internet, a `gh` token, the 1Password CLI and development packages, 4.8 GB in `$HOME`. All of it was removed on 2026-11-17, and a read the same evening found none of it: no user services beyond the distribution's, no TCP connection on the host's own sockets but inbound SSH from Hicks, and 180 MB in `$HOME`, nearly all of it the checkout. That read covered the host's network namespace only. The sensor's own Alloy, in its container, still pushes logs and metrics to `alexander`, as it is meant to. Since #1577 an hourly collector on `fenrir` re-reads what the runbook leaves (`sshd`, the keys, accounts and groups, user units, snaps, apt sources, host listeners, the size of `$HOME`) and the lab's `ApplianceCheckFailed` names a check that fails. That catches drift by accident only: whoever has root on `fenrir` can make it read clean, and the lab's Prometheus pages no one (ADR-0020), so it is seen by someone looking at the lab |