From 71deacc71816e51790547084728f483dd5e92fd2 Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Wed, 25 Nov 2026 20:45:34 +0000 Subject: [PATCH] docs(phoenix): ADR-0135 turns forwarding off on phoenix's sshd and removes cloud-init's file ADR-0117 made phoenix's sshd key-only but left TCP, agent and Unix-socket forwarding on, and kept cloud-init's 50-cloud-init.conf, which still reads PasswordAuthentication yes. ADR-0043 already says ProxyJump through phoenix is not a supported path. DisableForwarding yes enforces that, as on garuda. Removing the installer's file stops it being read as the host's policy, as on fenrir. build-the-jumpbox.md 6a gains both steps and their checks. ADR-0117 carries an amendment note, security.md records the decision as not yet applied, and README counts 135 ADRs. Refs #1496 Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +- ...-sshd-and-a-default-deny-inbound-policy.md | 6 ++ ...oenixs-sshd-and-remove-cloud-inits-file.md | 93 +++++++++++++++++++ docs/runbooks/build-the-jumpbox.md | 31 ++++++- docs/security.md | 2 +- 5 files changed, 129 insertions(+), 7 deletions(-) create mode 100644 docs/adr/0135-turn-forwarding-off-on-phoenixs-sshd-and-remove-cloud-inits-file.md diff --git a/README.md b/README.md index 629c51f74..67d4e02d4 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.** 134 ADRs covering what was chosen +- **Documented decisions and runbooks.** 135 ADRs covering what was chosen 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 @@ -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/ # 134 ADRs — architecture decision records +│ ├── adr/ # 135 ADRs — architecture decision records │ ├── exercises/ # purple-team exercise records — see its README │ └── runbooks/ # 57 runbooks; successor-handover.md is the front door └── Makefile # make help diff --git a/docs/adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md b/docs/adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md index fdfdb3eea..217ad8c56 100644 --- a/docs/adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md +++ b/docs/adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md @@ -2,6 +2,12 @@ **Status:** Accepted · 2026-11 · amends [ADR-0043](0043-keep-the-ca-on-prometheus-and-build-phoenix-as-the-deployment-host.md) +> [!NOTE] +> Amended by [ADR-0135](0135-turn-forwarding-off-on-phoenixs-sshd-and-remove-cloud-inits-file.md): +> `10-phoenix.conf` also sets `DisableForwarding yes`, and cloud-init's +> `50-cloud-init.conf` is removed instead of being left in place. The text +> here is left as written, per ADR-0001 and ADR-0115. + ## Context [ADR-0043](0043-keep-the-ca-on-prometheus-and-build-phoenix-as-the-deployment-host.md) diff --git a/docs/adr/0135-turn-forwarding-off-on-phoenixs-sshd-and-remove-cloud-inits-file.md b/docs/adr/0135-turn-forwarding-off-on-phoenixs-sshd-and-remove-cloud-inits-file.md new file mode 100644 index 000000000..c9735978c --- /dev/null +++ b/docs/adr/0135-turn-forwarding-off-on-phoenixs-sshd-and-remove-cloud-inits-file.md @@ -0,0 +1,93 @@ +# ADR-0135: Turn forwarding off on `phoenix`'s `sshd`, and remove cloud-init's file + +**Status:** Accepted · 2026-11 · amends +[ADR-0117](0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md) + +## Context + +[ADR-0117](0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md) +made `phoenix`'s `sshd` key-only with a drop-in, `10-phoenix.conf`. That +drop-in sorts ahead of the installer's `50-cloud-init.conf`, and `sshd` keeps +the first value it reads. It turned off X11 forwarding and left every other +kind on, and it left cloud-init's file in place on purpose: "the drop-in wins +without the installer's file being edited". + +The recheck of `phoenix` on 2026-11-25 +([#1496](https://github.com/Gerrrt/HomeLab/issues/1496)'s audit) found both +choices still standing out: + +- **`sshd -T` reads `allowtcpforwarding yes`, `allowagentforwarding yes` and + `allowstreamlocalforwarding yes`.** A key that logs in to `phoenix` can + therefore tunnel through it. `phoenix` is the one address on VLAN 30 with a + path to `Saruman`'s and `gandalf`'s `8006`, so it can tunnel there too. + [ADR-0043](0043-keep-the-ca-on-prometheus-and-build-phoenix-as-the-deployment-host.md) + already says that "`ProxyJump` through `phoenix` is not a supported path", + and that the day it becomes one, ADR-0002's decline of a bastion is + reopened. Nothing in `sshd` enforces that sentence. +- **`50-cloud-init.conf` still reads `PasswordAuthentication yes`.** It has + no effect, but it is the first thing an audit without `sudo` sees, and it + has to be explained each time. [`build-the-sensor-guest.md`](../runbooks/build-the-sensor-guest.md) + removes the same file on `fenrir` for the same reason. There, cloud-init + wrote it once per instance and did not restore it across four reboots. + +Nothing found on the host uses forwarding. Neither the repository nor the +operator's SSH config jumps through `phoenix`. The Claude Code remote session +on the host runs as a command over the SSH channel's stdio, next to +`sftp-server`, and opens no forwarded channel. No remote IDE server is +installed. Agent forwarding *into* `phoenix` would hand a workstation's agent +to the host whose compromise the residual in [`security.md`](../security.md) +already prices as owning the lab domain. + +## Decision + +**`10-phoenix.conf` gains `DisableForwarding yes`.** One line turns off TCP, +Unix-socket, agent and X11 forwarding at once. `AllowTcpForwarding no` alone +would leave Unix-socket forwarding on. `stacks/analyst/ssh/10-garuda.conf` +already does the same on `garuda`. `X11Forwarding no` stays in the file +because it is harmless, and keeping it means ADR-0117's check still reads +four `no` lines. + +**cloud-init's `50-cloud-init.conf` is removed,** as `fenrir`'s runbook +removes it. The `10-` drop-in keeps doing the work. Removing the file stops a +misleading line from being read as the host's policy. + +Both are applied by hand from +[`build-the-jumpbox.md`](../runbooks/build-the-jumpbox.md) §6a, because +nothing converges `phoenix`. The check reads `disableforwarding yes` from +`sshd -T` and expects one file in `sshd_config.d`. `sshd -T` still prints the +separate `allow*forwarding` options as `yes`, because `DisableForwarding` +overrides them without changing what they report. + +This amends ADR-0117. Its key-only settings and its `ufw` policy are +unchanged. + +## Alternatives considered + +- **`AllowTcpForwarding no` and `AllowAgentForwarding no`.** This is what + `heimdall`'s runbook writes. Declined because it leaves Unix-socket + forwarding at its default of `yes`, and the garuda drop-in's comment + records that gap. +- **Leave forwarding on and rely on ADR-0043's sentence.** Declined. A rule + that only a document enforces is the gap ADR-0117 closed for passwords. +- **Edit `50-cloud-init.conf` to read `no`.** Declined. It keeps a second + file that says the same thing, and the next cloud-init instance would + rewrite it. Removing it matches `fenrir`. +- **Disable cloud-init on `phoenix`.** Out of scope. It would change how a + rebuilt `phoenix` gets its first network and user, which build-the-jumpbox + §2 relies on. + +## Consequences + +- **`ssh -J`, `-L`, `-D`, `-R` and `-A` through `phoenix` fail.** That was + already the intended policy, and now it is enforced. A workstation that + needs `Saruman`'s UI reaches it directly from Hicks, as before. +- **A tool that tunnels over SSH breaks on `phoenix`.** Remote IDEs such as + VS Code Remote-SSH forward a port by default. The runbook's check opens a + fresh remote session before the old one closes, so the change can be + rolled back without the console. +- **The audit's low leftovers for `sshd` close** once it is applied. +- **Reopened by:** + - anything that needs to tunnel through `phoenix`. That is also ADR-0043's + bastion question; + - a remote-development tool on `phoenix` that cannot run without + forwarding. diff --git a/docs/runbooks/build-the-jumpbox.md b/docs/runbooks/build-the-jumpbox.md index e12f5962a..e2e070539 100644 --- a/docs/runbooks/build-the-jumpbox.md +++ b/docs/runbooks/build-the-jumpbox.md @@ -441,7 +441,9 @@ another VLAN and this one is not. ## 6a. Close the way in [ADR-0117](../adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md): -`sshd` takes keys only, and inbound is default-deny. Nothing converges this +`sshd` takes keys only, and inbound is default-deny. +[ADR-0135](../adr/0135-turn-forwarding-off-on-phoenixs-sshd-and-remove-cloud-inits-file.md): +nothing tunnels through it. Nothing converges this host, so this section is how it gets there, on a rebuild as on the first build. @@ -463,7 +465,11 @@ password, and prints `key-ok` without testing a key. Every machine prints `phoenix` until the end of this section. **Then `sshd`.** On `phoenix`. The `10-` prefix sorts ahead of the installer's -`50-cloud-init.conf`, and `sshd` keeps the first value it reads: +`50-cloud-init.conf`, and `sshd` keeps the first value it reads. The drop-in +would win anyway, but the installer's file is then removed. It reads +`PasswordAuthentication yes`, and an audit without `sudo` would read that as +the host's policy. cloud-init writes it once per instance, so it stays gone, +as on `fenrir`: ```bash sudo tee /etc/ssh/sshd_config.d/10-phoenix.conf >/dev/null <<'EOF' @@ -472,12 +478,29 @@ PasswordAuthentication no KbdInteractiveAuthentication no PermitRootLogin no X11Forwarding no +# ADR-0135: not a jump host. Covers TCP, Unix-socket, agent and X11 at once. +DisableForwarding yes EOF +sudo rm -f /etc/ssh/sshd_config.d/50-cloud-init.conf sudo sshd -t && sudo systemctl reload ssh -sudo sshd -T | grep -E '^(passwordauthentication|kbdinteractiveauthentication|permitrootlogin|x11forwarding) ' +sudo sshd -T | grep -E '^(passwordauthentication|kbdinteractiveauthentication|permitrootlogin|x11forwarding|disableforwarding) ' +ls /etc/ssh/sshd_config.d/ ``` -All four lines read `no`. A fresh login from a second terminal, with the +The first four lines read `no`, `disableforwarding` reads `yes`, and `ls` +lists only `10-phoenix.conf`. `sshd -T` still prints the separate +`allow*forwarding` options as `yes`, because `DisableForwarding` overrides +them without changing what they report. Prove it from a workstation instead: +`ssh -o ControlMaster=no -o ControlPath=none -N -L 18006:127.0.0.1:22 @10.0.30.70` +logs in, and a connection to `localhost:18006` fails, with `sshd` refusing +the channel as administratively prohibited. + +If you reach `phoenix` with a remote tool, such as a Claude Code remote session +or an editor's remote mode, open a fresh session with it now, before closing +the old one. The Claude Code session runs over the channel's stdio and does +not need forwarding. An editor that tunnels a port does, and the fix then is +to remove the `DisableForwarding` line and reload, from the session that is +still open. A fresh login from a second terminal, with the first still open, is the check that the reload did not shut you out: the same command as above, with its `ControlMaster=no` and `ControlPath=none`. diff --git a/docs/security.md b/docs/security.md index c275f327d..702686bdf 100644 --- a/docs/security.md +++ b/docs/security.md @@ -17,7 +17,7 @@ What this network is actually built to survive: | 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`, `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 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. [ADR-0135](adr/0135-turn-forwarding-off-on-phoenixs-sshd-and-remove-cloud-inits-file.md) adds `DisableForwarding yes`, so no key tunnels through `phoenix` to `8006` or anywhere else, and removes cloud-init's `50-cloud-init.conf`. Decided, not yet applied | | 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 | | 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 |