diff --git a/docs/changelog.md b/docs/changelog.md index 411d861c..84cf0b23 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,18 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-25 +- **`build-the-backup-guest.md` §2 gains a host firewall for `golem`.** + The audit of 2026-11-13 left the choice open, and the entry below lists it + as the last thing not done. `golem` can delete every backup the lab has, + and its `sshd` and PBS's UI answered all of VLAN 30. In the fourteen days + before, only `Saruman` (`10.0.30.20`) and Hicks addresses reached `8007` + or logged in on `22`, apart from `Saruman`'s old address, last seen on + 2026-11-07. The `nftables` ruleset admits `22` and `8007` from those two, + and replies to what `golem` starts itself, which covers the NFS mount and + Alloy's push. It is loaded live first, and enabled at boot only after a new + SSH login from the Mac and `Saruman`'s request to `8007` both work. + §11 gains a row for a source left out of the set. `security.md`'s `golem` + row says the firewall is written and not yet applied. - **`heimdall` runs the hardening `build-heimdall.md` §2 added today.** This completes the entry "`build-heimdall.md` closes what a second audit of `heimdall` could still raise", which said the steps were not yet applied. diff --git a/docs/runbooks/build-the-backup-guest.md b/docs/runbooks/build-the-backup-guest.md index 941ffef7..675ad8b2 100644 --- a/docs/runbooks/build-the-backup-guest.md +++ b/docs/runbooks/build-the-backup-guest.md @@ -123,6 +123,57 @@ pool: its disk is ext4 on LVM, and the datastore is NFS. `zpool list` must say systemctl disable --now zfs-zed.service ``` +**Then a host firewall.** With those off, only `22` and `8007` listen on an +address other than loopback, but nothing holds it there, and both answer all +of VLAN 30: the domain, the range's targets and every lab guest. Only two +places need them. `Saruman` stores to `8007` and runs §10's collector +installer over `22`. Hicks is where the operator logs in and opens the UI. +`nftables` ships with PBS, installed and empty. This ruleset admits those +two, and the replies to what `golem` starts itself. That covers the NFS +mount, because NFSv4.1 and later carry the server's callbacks on the +client's own connection, and Alloy's push to `alexander`: + +```bash +cat > /etc/nftables.conf <<'NFT' +#!/usr/sbin/nft -f +flush ruleset +table inet filter { + set admin { + type ipv4_addr; flags interval; + elements = { 10.0.30.20, 10.0.50.0/24 } # Saruman, Hicks + } + 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 + ip saddr @admin tcp dport { 22, 8007 } accept + } + chain forward { + type filter hook forward priority filter; policy drop; + } + chain output { + type filter hook output priority filter; + } +} +NFT +nft -c -f /etc/nftables.conf # parses, changes nothing +nft -f /etc/nftables.conf # live, but not yet at boot +``` + +Keep this session open, and check three things. From the Mac, open a new +session with `ssh -o ControlPath=none root@10.0.30.80`. From `Saruman`, +`curl -sk -m 5 -o /dev/null -w '%{http_code}\n' https://10.0.30.80:8007/` prints +`200`. From `alexander`, which is on the segment and is neither, the same +`curl` times out. If either of the first two fails, reboot `golem` from +`Saruman` (`qm reboot 180`). The ruleset is not loaded at boot yet, so it +comes back open. Once all three hold: + +```bash +systemctl enable nftables.service +``` + After §5's mount exists, reboot once and check that `findmnt /mnt/datastore/erebor` still shows the share. And give `root@pam` a second factor in the web UI, *Configuration → Access Control → Two Factor @@ -491,6 +542,7 @@ nothing behind it. Two pieces: | PBS writes to the OS disk and `/` fills | The share was not mounted | Cannot happen with §5's `chattr +i`. If `/mnt/datastore/erebor` is writable while unmounted, the attribute is missing | | Backups succeed, restore fails to decrypt | The key on `Saruman` is not the one the backups were made with | Restore `golem.enc` from `secrets/lab.sops.yaml` or the paper key, to `/etc/pve/priv/storage/golem.enc` | | The verify job fails with `manifest load error … index.json.blob … No such file` | A backup broke mid-run, and its cleanup failed with `Directory not empty` because NFS had renamed a still-open file to `.nfs*`. The snapshot directory was left without a manifest | Once no `.nfs*` file remains in it, remove that snapshot directory as root on `golem`. Then `proxmox-backup-manager verify-job run weekly`, so the job's last state, and `PbsJobFailed`, clear before Sunday | +| `Saruman`'s backups, or `pvesm status` for `golem`, time out, and the UI does not load from a Hicks address that used to work | The source is not in §2's `admin` set. `Saruman` moved from `.110` to `.20` on 2026-11-07, and a move like that again would do it | Add the new address to the set in `/etc/nftables.conf` from VM 180's console in `Saruman`'s web UI, then `nft -f /etc/nftables.conf`. `systemctl disable --now nftables.service && nft flush ruleset` takes the firewall off while you look | | Garbage collection deletes chunks a backup needs, and verify reports missing chunks | `atime` was off when garbage collection ran | Roll `erebor/pbs` back to the newest TrueNAS snapshot from before that run, then fix `atime` | ## 12. Write it down diff --git a/docs/security.md b/docs/security.md index c275f327..1a7e26e2 100644 --- a/docs/security.md +++ b/docs/security.md @@ -22,7 +22,7 @@ What this network is actually built to survive: | 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 | | Someone on the lab segment logging in to `alexander` | **Closed at `sshd`.** `alexander` holds the lab's only age key, and its `sshd` answers all of VLAN 30 with no host firewall. It is installed by hand from the ISO, so it does not inherit the template's `allow-pw: false`. [`build-the-lab-guest.md`](runbooks/build-the-lab-guest.md) §2 makes `sshd` key-only through a drop-in, refuses root and X11 forwarding, and keeps `garnet`'s `authorized_keys` to Hicks's key and `phoenix`'s; §7 checks it with `sshd -T`. A read on 2026-11-15 found it taking passwords; the step was applied the same day, and `sshd -T` read `no` for all four settings. The source address stays open: anyone on the segment can still offer a key | | Someone on the lab segment logging in to `odin` | **Closed at `sshd`.** `odin` holds the SOC's certificate authority key and its own age key, and its `sshd` answers all of VLAN 30 with no host firewall. It is installed by hand from the ISO, so OpenSSH's default of taking passwords stood. [`build-the-soc-guest.md`](runbooks/build-the-soc-guest.md) §2 makes `sshd` key-only through a drop-in that outranks cloud-init's, and refuses root and X11 forwarding; §10 checks it with `sshd -T`. A read on 2026-11-15 found it taking passwords and X11 forwarding; the step was applied on 2026-11-16, and `sshd -T` read `no` for all four settings. The source address stays open: anyone on the segment can still offer a key | -| Someone on the lab segment logging in to `golem` | **Closed at `sshd`, with a second factor on `root@pam`, since 2026-11-25. There is no host firewall and no decision on one.** `golem` can delete every backup the lab has; the TrueNAS snapshots of `erebor/pbs` are the copy it cannot. Its `sshd` and PBS's UI on `8007` answer all of VLAN 30 with no host firewall. It is installed by hand from the PBS ISO, whose installer lets root log in by password and starts `rpcbind` on every address. [`build-the-backup-guest.md`](runbooks/build-the-backup-guest.md) §2 does three things. A drop-in keeps root to keys and refuses passwords and X11 forwarding. `rpcbind` and `nfs-blkmap` are turned off. `root@pam` gets a TOTP second factor. The audit of 2026-11-13 found all of it open. The drop-in and the services were applied on 2026-11-25. `sshd -T` read `without-password`, `no`, `no`, a password login was refused with `Permission denied (publickey)`, and nothing listened on `111`. After a reboot the datastore was mounted again. The TOTP second factor was enrolled later the same day. The source address stays open: anyone on the segment can still offer a key or reach the login page | +| Someone on the lab segment logging in to `golem` | **Closed at `sshd`, with a second factor on `root@pam`, since 2026-11-25. A host firewall is written into §2 and not yet applied.** `golem` can delete every backup the lab has; the TrueNAS snapshots of `erebor/pbs` are the copy it cannot. Its `sshd` and PBS's UI on `8007` answer all of VLAN 30 with no host firewall. It is installed by hand from the PBS ISO, whose installer lets root log in by password and starts `rpcbind` on every address. [`build-the-backup-guest.md`](runbooks/build-the-backup-guest.md) §2 does three things. A drop-in keeps root to keys and refuses passwords and X11 forwarding. `rpcbind` and `nfs-blkmap` are turned off. `root@pam` gets a TOTP second factor. The audit of 2026-11-13 found all of it open. The drop-in and the services were applied on 2026-11-25. `sshd -T` read `without-password`, `no`, `no`, a password login was refused with `Permission denied (publickey)`, and nothing listened on `111`. After a reboot the datastore was mounted again. The TOTP second factor was enrolled later the same day. The source address stays open: anyone on the segment can still offer a key or reach the login page. §2's `nftables` ruleset closes that, admitting `22` and `8007` from `Saruman` and Hicks only, and is written but not yet applied | | 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 | | Someone on the lab segment fetching a Velociraptor client package | **Scoped by address, and accepted.** `odin`'s `caddy` service (container `soc-agent-msi`) serves the two agent MSIs `ansible/` installs, and the two Debian packages `garuda` installs, on `8448` ([#1068](https://github.com/Gerrrt/HomeLab/issues/1068), [ADR-0092](adr/0092-enrol-garuda-in-odins-soc-with-debian-packages-staged-on-odin.md)). Its Caddyfile answers the six domain addresses, `.50`–`.55`, and `garuda`'s `.62`, and refuses everyone else, Hicks's route from VLAN 50 included. The Velociraptor MSI and the Velociraptor `.deb` each carry the client config: the server URL, its CA, and the enrolment nonce. Whoever holds either can enrol a rogue client, which is why #864 took the MSI out of SYSVOL. The residual: an address on this segment can be spoofed, and any of the seven can fetch either package. What the nonce buys is noise in Velociraptor's client list, the same class as the Wazuh enrolment password. Rotating it means a new server config, a rebuilt MSI with the role's pin moved, and the staged `.deb` deleted so that `scripts/stage-agent-msis.sh` builds it again. The two Wazuh packages carry no secret | | An OpenVAS plugin on `garuda` reaching a non-target | **Fenced at layer 2** ([ADR-0093](adr/0093-run-openvas-on-garuda-on-demand-scoped-to-the-domain-by-nftables.md)). OpenVAS scans the domain's six only. While a scan runs, the scanner runs in a network namespace whose one route to the segment is a macvlan, `scan0` at `10.0.30.63`, behind an nftables `netdev` egress hook that drops every frame — IP, ARP (`send_arp_request`) and raw (`send_frame`) — to anything but the six. So the AF_PACKET paths that bypass an IP filter are caught here. Proved: a GVM scan of an out-of-scope host raised the egress drop counter with 0 open ports, and an `arping` from the namespace to an out-of-scope host was dropped while an in-scope host answered. `gvmd`, `notus`, `redis` and `mosquitto` stay on the host; only MQTT crosses to the namespace, on a veth that routes nowhere else |