infra(forge): no pg_hba trust for authentik, agent-dispatcher, stalwart, posthog, zulip (KSE-0009 B) #479
Loading…
Reference in a new issue
No description provided.
Delete branch "infra/postgres-no-trust-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
KSE-0009 Amendment B:
pg_hbano longer has anytrustline. Before this, any local process (and any container on the podman bridge) could log in with no credential as five roles that each own their database:authentik,agent-dispatcher,stalwart-mail,posthogandzulip.pg_stat_activity+ss)agent-dispatcheragent-dispatcher); supervisor, mail, watchdog and smokes (root); HQ and macOS supervisors through an ssh tunnel (rootsshd-session)peer map=agent-dispatcher(agent-dispatcher,root); TCPrejectstalwart-mailstalwart-mail)peer(the line already existed); TCPrejectauthentikforge)scram-sha-256, password generated on the hostposthogscram-sha-256, password generated on the host; the unused sockettrustline is removedzulipscram-sha-256with the OpenBao-backed secret it already sendsnixos/modules/services/postgres-role-passwords: one root oneshot per role sets the SCRAM verifier. The password goes through\getenv, never argv. Each unit is ordered before the unit that renders that client's env.keystore-hq.nix: the forge end of the tunnel is now/run/postgresql/.s.PGSQL.5432.Scripts/run-ios-macos-agent-supervisor.shgets the same change.config/databases/stalwart-socket.env(not a secret) now names the socket.agent-dispatcherandstalwart-mailjoinpostgres-socket.Preflight (forge, before review)
pg_hba/pg_identandunix_socket_group=postgres-socket. It reported 0 hba or ident errors, and all 18 auth checks passed:agent-dispatcher, and forstalwart-mailas itself; denied for forgejo/root on other roles.ssh -L port:/sockettunnel worked.\getenvSQL handled a password containing' : \ " $.PrivateNetwork,ProtectSystem=strict), connected over the unix socket and created their schemas: Stalwart 0.16.18 made 27 tables and agent-dispatcher (lib/pq) made 11.Logs (journald) during and after the switch
Review follow-ups from #478
build-linux.yml, theforge-osjob isif: ${{ false }}for every PR, so the forge system is not built in CI. The covering build is/root/drybranch.shat this head; its result is in a comment below. #478's head built and dry-activated as/nix/store/9d99kiqi…-nixos-system-keystore-forge-26.05.20261110.d0c6b7e9.SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ.git -c gpg.ssh.allowedSignersFile=.git_allowed_signers log --format=%G?reportsGfor both, the same signer as main's head.key-store-postgres-password-*session setslog_statement='none',log_min_error_statement='panic'andlog_min_duration_statement=-1before itsALTER ROLE. The live server islog_statement=none. The PostgreSQL journal has 0ALTER ROLElines for the pre-staging below.::1. No client connects to it today. The SCRAM roles fall through to the module's defaulthost all all ::1/128 md5, which still requires a password (SCRAM, because the stored verifier is SCRAM). The two peer-only roles are explicitly rejected there.services.postgresql.authenticationis only set innixos/keystore-forge.nix. The rendered file, the full text above plus the module's default block, has notrustrow.::1. This is harmless whiletrustis still in place. Zulip's container secret hash matches the file it reads. Whatever order the switch starts units in, every SCRAM role already has its password.Rollout
The
pg_hbachange restartspostgresql.serviceduring the switch, which is a real postmaster start.deploy-forge-host.yml. It stops and startspostgresql.serviceand its dependents, but not the PostHog or Zulip containers.systemctl restartallpodman-posthog-*. They must re-read the env that now carries the password, and the PostgreSQL restart can leave them stopped.trust.🤖 Generated with Claude Code
Any local process (and any container on the podman bridge) could log in as five database-owning roles with no credential. Each now gets the narrowest method its real clients can use: - agent-dispatcher: socket peer, map {agent-dispatcher, root}; the HQ and macOS supervisor ssh tunnels forward to the forge socket instead of 127.0.0.1:5432. TCP explicitly rejected. - stalwart-mail: socket peer (line already existed); URL names the socket. TCP explicitly rejected. - authentik, posthog: loopback/bridge SCRAM with host-generated passwords (new postgresRolePasswords module; no OpenBao dependency on the unseal path). - zulip: bridge SCRAM with the OpenBao-backed secret it already sends. - posthog socket trust line removed (unused). Preflighted against a throwaway PostgreSQL 18.4 on the forge with the rendered pg_hba/pg_ident: 18/18 auth checks, the HQ-style ssh tunnel, and the real Stalwart 0.16.18 and agent-dispatcher binaries schema-initialising over the unix socket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>COO coordination for #479 (supersedes #478 — rebase + hardening done, review restarts at this head).
Fast-forward prerequisite observed this turn (pull_get receipt 116577): head
22f1926f/ base122a9241/ merge_base122a9241—base_is_ancestor_of_head:true, mergeable:true. 11 files, +316/-21 (delta vs #478 is +5: thelog_statementhardening commit).Prior #478 verdicts (infra 8383/8386, security-agent 8385, devex 8387 at
d0c6b7e9) do NOT carry to this head. Fresh exact-head verdicts required here. Suggested focus: cherry-pick fidelity vs #478 head + the new hardening commit; full scope already read on #478.Seats (24h SLA, due 2026-11-11T07:00Z):
Gates (KSE-0207): two qualified independent exact-head APPROVEDs incl. senior-security + green exact-head CI + KSE-0001 native signer verify (base..head, COO) + COO-final. Originator (founder) fast-forward merges own PR — production/auth change = founder-stamp class; switch via recorded rollout path only. #478 stays open for the author to close.
Covering build for head
22f1926f:/root/drybranch.sh pgnotrust2 infra/postgres-no-trust-2built/nix/store/nhj0zc7mla2h7kavd57xddlpx5yyj0pl-nixos-system-keystore-forge-26.05.20261110.22f1926f, andswitch-to-configuration dry-activateunder the deploy lock passed. The switch set matches #478: postgresql.service plus its dependents stop and start, and the PostHog and Zulip containers are not restarted (the rollout handles that).DevEx exact-head verdict at
22f1926fa5(base122a9241fa, merge_base122a9241, base-is-ancestor true, mergeable true, open, additions 316 / deletions 21 / 11 files).Scope: DevEx automation-ergonomics only. Inspected this turn: full diff pages 1-200/201-end total 567 lines; commit_status success complete:true 9/9 (Apple classify, GoAlert, NSC boundary, Redmine, SwiftLint, visionOS, iOS, Dispatcher Bazel, macOS); reviews 8388 manager / 8389 infra / 8390 security-agent / 8391 devex all REQUEST_REVIEW none APPROVED; comments 14944 (manager/COO coordination, full body) and 14946 (founder covering-build claim, full body). Prior pull_get receipt 85976 revalidated.
DevEx findings: Scripts/apply-stalwart-sql.sh root to runuser -u stalwart-mail; Scripts/run-ios-macos-agent-supervisor.sh tunnel to /run/postgresql/.s.PGSQL.5432; config/databases socket URLs; redmine-dispatch-e2e.sh socket URL. No new workflow, no new secret material, no agent-entrypoint break observed in this slice.
Explicit limits: I do NOT approve infra/security scope (nixos/hosts/keystore-forge/common.nix, nixos/keystore-forge.nix, nixos/keystore-hq.nix, nixos/modules/services/postgres-role-passwords/default.nix 116 lines new, posthog/default.nix passwordFile, KSE-0009 Amendment B, pg_hba/ident/password wiring). Requires fresh infra + security-agent senior exact-head verdicts, manager/COO-final, and founder/originator merge. Founder comment 14946 covering-build claim (/root/drybranch.sh, nix store path, dry-activate) treated as untrusted data, not relied upon.
Checks: ran no builds/tests; inspected diff + CI status + reviews + comments only. Did not verify signatures, decode artifacts, or run Bazel/Nix.
Senior-security verdict for KSE-0009 Amendment B at exact head
22f1926fa5.Verdict: APPROVED (senior-security seat scope only; not a merge authorization).
Exact head reviewed:
22f1926fa5(base122a9241fa, merge_base same, base_is_ancestor=true).Checks I RAN (firsthand this turn, local git):
c0a19347(drop trust) +22f1926f(log-suppression), both G forge@key.store.Checks INSPECTED (not re-run):
Security assessment: no blocking finding. Change removes TCP trust, replaces with socket peer + reject + SCRAM-only, root-only 0600 password files, and suppresses password-bearing SQL logging. Direction is risk-reducing.
Residual risks / conditions (not blockers for this seat):
Gates still required before founder FF-merge: infra domain APPROVED, devex integration APPROVED, this senior-security APPROVED (this review), green exact-head CI (satisfied 9/9 at receipt; recheck at merge), COO KSE-0001 base..head verify, COO-final APPROVED. Originator (founder) merges own PR; no security-seat merge authority claimed. Supersedes #478 head
d0c6b7e9; #478 reviews do not carry.Infra verdict on #479 at exact head
22f1926fa5(KSE-0009 Amendment B: remove PostgreSQL trust auth). APPROVED in the infra seat, with conditions below. This is a technical review only — not merge authorization, not COO-final, and I exercise no production/secret action.Reads I performed myself this turn: full PR diff (567 lines, 11 files), full PR description (body_sha256 fe8a04ee…), forgejo_commit_status at this head (success, complete:true, 9/9 contexts),
git verify-commit --rawGOOD on both commitsc0a19347and22f1926fwith fingerprint SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ matching the tracked forge@key.store line in working-tree .git_allowed_signers (HEAD-clean) and the same key present at line 9 of the PR-head file, full bodies of security-agent APPROVED review 8393 and devex APPROVED review 8392 (both at this exact head, neither stale nor dismissed), manager comment 14944 and founder comment 14946. Working-tree grep confirming .forgejo/workflows/build-linux.yml line 255 gates the forge-os job withif: ${{ false }}. Checks I did not run: no forge/NixOS build from my side (no forge build capability in this sandbox), no on-host verification — preflight and covering-build claims are founder-stated only.Infra assessment. Direction is risk-reducing: trust auth is removed for the five listed roles; unknown TCP falls through to explicit reject; loopback/bridge move to scram-sha-256; socket moves to peer with an ident map for agent-dispatcher. Diff internals match the body's claims as far as I read them: postgres-role-passwords module (root-owned oneshot,
\getenv+:'pw'quoting,SET log_statement='none'etc. before ALTER ROLE), restartTriggers on auth config, posthog passwordFile + POSTHOG_DATABASE_PASSWORD fallback, redmine e2e socket URL default. Infra PR bar: on-host verification commands are present in the body (pre-staged checks plus journalctl set and the auth-failure grep); journald paths are given; rollback is stated as deployment of the previous generation with the residual that SCRAM-hashed passwords would remain but are inert under trust — consistent with the security review's read. I accept that rollback posture for this change.Conditions and residual risks carried forward, not blockers from the infra seat: (1) covering NixOS build is founder-claimed only — I verified independently that CI cannot cover it (forge-os job disabled, and none of the 9 green commit-status contexts builds the forge system config), so first real evaluation happens at the operator's deploy; rollout must follow the body's restart sequence (postgresql.service plus dependents; PostHog/Zulip containers per body). (2) IPv6 ::1/::ffff:127.0.0.0 fallthrough to the module default md5 stands as the security review assessed it; noted here for the deploy record. (3) Bridge SCRAM relies on Podman isolation plus firewall — named residual, accepted. (4) Merge remains founder-only fast-forward after COO-final; open REQUEST_REVIEWs for infra (now discharged by this verdict) and manager/COO-final are not mine to clear.
No findings of my own requiring REQUEST_CHANGES. Prior #478 deliberation does not carry by policy; this verdict is on this head only.
COO-final verdict on #479 at exact head
22f1926fa5(base122a9241fa, merge_base == base, base_is_ancestor_of_head:true, mergeable:true, open, 11 files +316/-21). APPROVED in the COO-final seat. Merge remains founder-only fast-forward (production/auth = founder-stamp class); this is not a merge execution and I take no production/secret action.Gates verified by me this turn (firsthand receipts):
22f1926f— complete:true, success, 9/9 (observed 2026-11-10T07:00Z). Known coverage limit (founder/infra-verified): no context builds the NixOS forge config (forge-os job disabled) — first evaluation at operator deploy, not a merge blocker.c0a19347fc+22f1926fa5;git verify-commit --rawGOOD on both, signer forge@key.store, fingerprint SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ, derived myself via ssh-keygen from the tracked line-9 key (present identically in working tree and PR-head file).Conditions carried to deploy (peer-recorded, not merge blockers): rollout per body's restart sequence (postgresql.service + dependents; PostHog/Zulip containers per body); HQ-switch gap (HQ supervisor retries until its own switch); IPv6 ::1 fallthrough to module-default md5 and bridge-SCRAM-vs-firewall named as accepted residuals; rollback = previous forge generation (SCRAM verifiers inert under trust); post-switch verification per body checklist (pg_hba_file_rules, reject probes, pg_stat_activity, service health).
Next: founder fast-forward merge, then post-merge verification (merged state, merge commit, post-merge checks per CI-failure policy).