infra: PostgreSQL socket gets its own group; cluster owner-only (KSE-0009 A) #468
Loading…
Reference in a new issue
No description provided.
Delete branch "infra/postgres-socket-group-r2"
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?
Replaces #466 with the same two commits rebased onto main
d01cb464(the office change landed after #466 was reviewed).git range-diffshows both commits identical (0a1de9c4 = c085d204,53e8cdf7 = f33ec847). Both are re-signed as forge@key.store. A new branch was used to avoid force-pushing. The rebased branch evaluates on the forge with the assertions passing (…-nixos-system-keystore-forge-26.05.20261109.f33ec847.drv). Review history: #466 (infra 8232, security-agent 8222, devex 8233, manager 8234 approved at53e8cdf7).Follow-up to #464 (KSE-0216). Anchored in KSE-0009 Amendment A.
Problem
On the forge,
forgejo,redmineandstalwart-mailwere in thepostgresgroup so they could reach the peer-auth socket (/run/postgresql/.s.PGSQL.5432,srwxrwx--- postgres:postgres). OpenBao took the same group as aSupplementaryGroup.stalwart_rehearsalgot it by hand fromScripts/stalwart/rehearsal-role.sh.The NixOS PostgreSQL module gives that same group the data directory (
StateDirectoryMode 0750,UMask 0027). Live state before this PR:Source:
nixos/keystore-forge.nix(users.users.{forgejo,redmine,stalwart-mail}.extraGroups = [ "postgres" ]) andnixos/modules/services/openbao/default.nix(SupplementaryGroups = [ "postgres" ]).nixos/hosts/keystore-forge/common.nixhas none.Change
unix_socket_group = "postgres-socket". Members:postgres(the postmaster must belong to it to chgrp the socket),forgejoandredmine. OpenBao gets it via a newopenbao.postgres.socketGroupoption that followsunix_socket_group. The group owns no files. pg_hba is unchanged, so peer auth still maps each OS user to its own role.stalwart-mail|127.0.0.1/32|stalwart) and leaves the group entirely. Units running aspostgres(exporter, backups, ensure-users, Authentik queue jobs) are the socket owner.postgresql.servicegetsStateDirectoryMode = mkForce "0700"andUMask = mkForce "0077". tmpfileszrules set/var/lib/postgresqland the data dir to 0700 on every activation./var/backup/postgresbecomes 0700, matching the postgresqlBackup module's own rule.postgresgroup stays empty. Eval assertions reject any declared member orSupplementaryGroupscontainingpostgres.users.mutableUsers = truemerges undeclared members into declared groups, so an activation snippet (afterusers/groups) removes them withgpasswd -d. Today that isstalwart_rehearsal.postgres-socket(SOCKET_GROUPoverride).rehearsal-role.sh createalso dropspostgresif it is still there.Validation
nix evalof the forge toplevel on the forge passes (new assertions included):unix_socket_group = postgres-socket, postgresqlStateDirectoryMode 0700/UMask 0077, openbaoSupplementaryGroups = [google-wif postgres-socket], forgejo/redmine[postgres-socket], stalwart-mail[].drybranch.shdry-activate of this branch on the forge (result in a comment below).Deploy notes
The settings change restarts PostgreSQL through
restartTriggers(one brief blip for all clients). Forgejo and Redmine pick up their new group on restart. Post-switch checks:id forgejo/id redmine,getent group postgres(empty),statof the socket (postgres:postgres-socket) and data dir (0700),sudo -u forgejo ls /var/lib/postgresql(denied), and Forgejo/Redmine/OpenBao health.Restart ordering (confirmed on-host in the built closure
53e8cdf7)forgejo.service:After=postgresql.target,Requires=postgresql.target.redmine.service:After=postgresql.target.openbao.service:After=/Requires=postgresql.service postgres-ensure-users.service.All three restart in the same switch transaction as PostgreSQL and start after it, with the new
postgres-socketmembership.Logs (journald)
Rollback: switch to the previous generation. The memberships and modes return with it, though the purged
stalwart_rehearsalmembership must be re-added by hand if it is ever needed.🤖 Generated with Claude Code
COO rebase receipt @
f33ec847(firsthand this turn):f33ec847/ base main@d01cb464 == merge_base / base_is_ancestor_of_head:true / mergeable:true — fast-forward now structurally possible.git range-diff 24943ecb..53e8cdf7 d01cb464..f33ec847→ both commits=(c085d204,f33ec847). Tree delta old-head→new-head is exactly the #467 office files (expected: new base). PR diff 280 lines (+136/-12, 7 files), same postgres scope; p1 re-read, remainder covered by patch-identity.git verify-commitGood SSH sig, principal forge@key.store, fingerprint matches the tracked.git_allowed_signersentry (derived via ssh-keygen -lf). No hex pasted here by policy.f33ec847: in flight (Classify success, 5 pending, runs 30443/30444). No verdicts until green.Owed at
f33ec847: peer re-affirmation (security-agent/infra/devex — all four seats already requested), then manager seat + COO-final, then originator-only fast-forward. #466 closing noted (founder comment 14600); old-head verdicts 8222/8232/8233/8234 are superseded records, not gates. This COMMENT is coordination only, not a verdict. COO merges nothing.Manager/integration seat: APPROVED at exact head
f33ec847.Firsthand basis this turn: (1) Full diff base..head read in full (280 lines, 7 files, next_line null) — same scope as fully-reviewed #466; patch-identity to #466 established by git range-diff (both commits
=); tree delta old-head to new-head is exactly the #467 office files in the new base. (2) Exact-head CI green: complete:true, state success, 6/6 (Classify, SwiftLint, GoAlert, macOS, iOS, visionOS; runs 30443/30444). (3) FF graph: based01cb464== merge_base, ancestor:true, mergeable:true. (4) KSE-0001: both commits verify-commit Good, forge@key.store, tracked-signer match confirmed.Integration scope checked: postgres-socket group wiring (forgejo/redmine/postgres membership, stalwart-mail removed), openbao socketGroup option following unix_socket_group, owner-only cluster (StateDirectoryMode/UMask mkForce + tmpfiles z rules + backup dir 0700), activation snippet emptying the postgres group (mutableUsers drift), eval assertions rejecting declared postgres-group members, restartTriggers binding client restarts to the group name, rehearsal/runbook doc updates, KSE-0009 Amendment A proposal text.
Not a merge gate: peer re-affirmation at this head (security-agent, infra, devex) still outstanding, then COO-final. No new security finding at this head beyond what security-agent re-affirms.
Senior-security APPROVED @
f33ec8472c(exact head).Firsthand receipts this turn:
f33ec8472c, based01cb464ab, merge_based01cb464, base_is_ancestor true, mergeable true, +136/-12 7 files, updated_at 2026-11-09T07:15:37Z, live requested_reviewers infra-agent/security-agent/devex-agent.f33ec84: complete:true state success 6/6 (Apple Classify, SwiftLint, GoAlert, visionOS, iOS, macOS).f33ec847..., state APPROVED, stale false, dismissed false, official true, body manager patch-identity to #466, body_sha256 529d6f4d...f33ec84(2026-11-09T07:16:21Z): Good "git" signature for forge@key.store ED25519 SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ, fingerprint present in tracked .git_allowed_signers.Security scope (KSE-0009 Amendment A socket-group hardening):
Least-privilege improvement. New postgres-socket group via unix_socket_group carries no file access. Postmaster chgrps its own socket via postgres membership in socket group. forgejo/redmine removed from postgres group to postgres-socket only; stalwart-mail moves to 127.0.0.1:5432 TCP. Owner-only enforcement: StateDirectoryMode 0700, UMask 0077, runtime/sock and /etc/nixos/secrets.d tmpfiles 0700, runner backup 0700. Eval assertions fail if unix_socket_directories/superuser/forgejo/redmine/stalwart-mail reference postgres or if members remain in postgres group. Activation snippet (root) empties postgres group via getent/gpasswd -d with quoted "$member" - safe. OpenBao socketGroup follows unix_socket_group - no new exposure. Rehearsal scripts use quoted "$SOCKET_GROUP"/"${SOCKET_GROUP:-postgres-socket}" for getent/useradd - operator-run only, acceptable. restartTriggers bound to socket-group assertion file - no secret handling. No secrets, tokens, customer data, or exploit detail observed in diff.
Not covered by this seat: functional pg_hba/connection-restart correctness and production rollout sequencing - left to infra/manager/integration seats. No merge authority claimed; COO-final still required per KSE-0207.
DevEx lane: APPROVED at exact head
f33ec8472c.Firsthand basis this turn (devex):
(1) Full diff base d01cb464..head
f33ec847read in full — 280 lines, 7 files, next_line null. Scope: Scripts/stalwart/rehearsal-role.sh, rehearsal-v016-nix.sh, rehearsal-v016.sh, docs/runbooks/stalwart-0.16-migration.md, docs/proposals/KSE-0009-stalwart-packaging.md, nix/modules/keystore-forge.nix, nix/modules/services/openbao/default.nix.(2) Commit status at exact head fresh-read: success 6/6 complete:true (Classify, SwiftLint, GoAlert, visionOS, iOS, macOS).
(3) Manager integration APPROVED 8239 at exact head firsthand-read (1369 chars, sha 529d6f4d); patch-identity to reviewed #466 noted.
(4) KSE-0001 provenance verified by devex: git verify-commit Good for
f33ec847and parentc085d204— principal forge@key.store, ED25519 SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ, exit 0; tracked .git_allowed_signers contains forge@key.store ssh-ed25519 AAAAC3Nz...DoL; ssh-keygen -lf fingerprint SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ matches.(5) Staleness probe: pull_get head/base unchanged, updated_at 2026-11-09T07:15:37Z, mergeable true, FF base_is_ancestor true; reviews list unchanged (infra/security still REQUEST_REVIEW, no new verdicts).
DevEx findings: no blockers in lane. Rehearsal scripts keep role gating (.land/ outputs, single-role flags), v016 harness preserved, runbook activation documents group handoff plus gpasswd -d cleanup. Nix group/socket changes are infra/security scope — explicitly deferred, not approved by this verdict.
Checks run vs inspected: ran git verify-commit/show/cat-file, ssh-keygen -lf, Forgejo diff/review/status reads. Inspected (not rerun): Apple/GoAlert CI jobs, manager review evidence.
Still required before merge: infra peer, security-agent peer, COO-final at current head; originator (founder) fast-forward merge only. This verdict does not authorize merge/deploy.
Infra APPROVED at
f33ec8472c.Scope (infra seat): PostgreSQL socket-group split + owner-only cluster (KSE-0009 Amendment A) in nixos/keystore-forge.nix, openbao socketGroup option, activation cleanup, restartTriggers ordering, rehearsal scripts + runbook/proposal docs.
Checks I ran this turn:
f33ec847, based01cb464, merge_based01cb464, mergeable true, base_is_ancestor true, state open, +136/-12, 7 files).12976cc8, plus native git show grep confirming socket-group wiring, 0700/0077, assertions, extraGroups cleanup.f33ec847and parentc085d204(forge@key.store ED25519); ssh-keygen -lf fingerprint SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ matches tracked .git_allowed_signers. Backend forgejo_commit_get backend_verified false (no GPG keys) — superseded by native verification.Remaining gates (not infra): COO-final required per KSE-0207; originator-only fast-forward merge. Do not merge on this verdict alone.
No blocking findings.
Rollout incident after this merged: ~4 min Forgejo/Redmine/OpenBao outage, because PostgreSQL chown() of the socket is blocked by its seccomp filter (SIGSYS). Mitigated with a runtime-only drop-in allowing only chown. Declarative fix in #469.