operator-newsletters / member-newsletters: Listmonk's masked client_secret is echoed back by the SMTP + brand reconcilers, so the token exchange 401s and the door shows its own login form #1611
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#1611
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
The failure
Drive
20260918T211405Z(roles proof #1547, onae2a2ecd): 43 legs green, two red —operator-newslettersandmember-newsletters, both the same fault (artifacts/legs.json,artifacts/verdict.jsonfirstRedLeg: operator-newsletters). Each door reachedhttps://newsletters.roles-proof.idss.nz/auth/oidc?code=…and rendered Listmonk's own login form:What the box said
The box was kept (
artifacts/live-box.json,kept_on_red: true). Nothing had failed:systemctl --failed→0 loaded units listed.journalctl -u newsletters-oidc.service -b→Login Success for idm_admin@id.roles-proof.idss.nz,Successfor every kanidm call,{"data":true}for its settings PUT, thenFinished ….The database named it in one query:
48 bullets = the kanidm basic secret's own length; 32 = the minted SMTP credential's. The stored secrets are Listmonk's read mask, not secrets.
Cause
All three newsletters reconcilers are
GET /api/settings→ jq-merge →PUT /api/settingsof the ONE settings object, so each echoes back fields it does not own:internal/clan/newsletters.go:406-424(newsletters-smtp)internal/clan/newsletters.go:717-725(newsletters-brand)internal/clan/newsletters.go:591-605(newsletters-oidc)Against the pinned upstream (listmonk 6.1.0,
/tmp/listmonk-6.1.0):cmd/settings.go:66-81—handleGetSettingsmasks every secret it returns asstrings.Repeat("•", utf8.RuneCountInString(secret)); line 81 iss.OIDC.ClientSecret.cmd/settings.go:232-233—handleUpdateSettingsrestores the stored value only when the field arrives empty:if set.OIDC.ClientSecret == "" { set.OIDC.ClientSecret = cur.OIDC.ClientSecret }; lines 142-148 are the UUID-matched twin forsmtp[].password.Bullets are not empty, so the mask is stored verbatim. The journal gives the order:
newsletters-oidcfinished (real secret written, listmonk restarted) at22:06:07;newsletters-smtpfinished22:06:09;newsletters-brand22:06:10, and again22:06:58on the redeploy. Each of the last two read the secret back masked and PUT the mask over it.That is why the fault surfaces one door away from its cause: kanidm still authenticates (
branded-login,oidc-adminand the other twelve door legs are green) and the code arrives; only the token exchange — the one step that presents the client secret — refuses. It is also invisible to the OIDC reconciler's compare-before-write (newsletters.go:599-602), which correctly excludes the masked secret from the projection (GOTCHAS #242 rule (a)) and therefore can never notice the clobber.The fix
internal/clan/newsletters.go: one shared rewrite,newslettersBlankMaskedSecrets, runs over the settings object each reconciler has just read, before its own merge — blanking all ten fieldshandleGetSettingsmasks, so Listmonk keeps what it already holds. Wired into the shared readiness gate (newslettersSettingsReadyGate, coveringnewsletters-smtp+newsletters-brand) and intonewsletters-oidc's own read. A reconciler that OWNS a secret still sets it again in its own merge below — verified for the SMTP relay password in the round-trip below.GOTCHAS #256 records the hazard as the counterpart to #248 ("echo the whole record back" — but never a field the server masked).
Suspected layer
Product,
internal/clanrender seam. Additions only: 3 files, 86 non-test lines, 0 deletions; no assertion, test or leg touched.Proposed ruling (Ruled by the healer under ADR 0174 — veto anytime)
Two-way door, mechanical repair, not a design decision.
Why it is not a design decision. The three reconcilers already MEAN to set only their own keys and leave the rest of the settings object alone — that intent is written into their own comments (
newsletters.go:402-404,713-716) and into the OIDC reconciler's projection comment at594-598, which already knew Listmonk masksclient_secret. The change makes the code do what it already meant: it stops a field the server itself redacted from being written back as data. Nothing a community sees changes, no route, message, default, secrets shape or security posture changes — the deploy stops destroying a secret it was never writing on purpose. This is the "wrong ordering / wrong constant" class, not the front-door / co-host-route / secrets class.Revertible how.
git revert 30db5680restores the previous bytes exactly. The change is additive (127 insertions, 0 deletions): one new function plus two one-line call sites. No schema, no dependency, no state outside the checkout, no infra touched — the box was only ever read.Proven by which test.
TestRenderNewsletters_ReconcilersNeverEchoAMaskedSecretBack(internal/clan/newsletters_test.go:409), written and watched fail first (got 0 of 3). It pins that all three settings-PUT reconcilers blank before they merge, that the blanking covers every fieldhandleGetSettingsmasks, and that the SMTP reconciler still writes its own relay password afterwards. Beyond the render test, the emitted shell was round-tripped verbatim through real bash + jq against a settings document carrying the box's actual masked values: the secrets come out""(the restore path), the smtp UUID that Listmonk's password restore matches on is preserved, and the SMTP reconciler's resulting PUT body carries its own real password withclient_secret: "". Rules 1 and 2 are untouched: additions only, nothing weakened, 3 files / 86 non-test lines. Built on the workstation (never the drive host) and closed through the close-report gate — the same gate a swarm worker passes.drive
20260918T211405Zred atoperator-newsletters(sig be8cfadc5b90) — self-fixed on the fast lane, commit679af8442051065e36513e7a76c94fedc3f0bbff; checks: Red-first:GOWORK=off go test ./internal/clan/ -run TestRenderNewsletters_ReconcilersNeverEchoAMaskedSecretBack -count=1BEFORE the fix — FAIL,every settings-PUT reconciler must blank the masked client_secret before echoing the object back … got 0 of 3. Targeted (after the fix): same command — ok. Package tests:GOWORK=off go test ./internal/clan/ -count=1— ok (24.5s). Dependent packages:GOWORK=off go test ./internal/brandkit/ ./internal/newslettersvc/ ./control-plane/... -count=1— all ok.GOWORK=off go vet ./internal/clan/— exit 0.gofmt -l internal/clan/— clean.GOWORK=off go build ./...— exit 0. Quoting/behaviour round-trip: extracted the rendered blanking block VERBATIM from the generated newsletters.nix and ran it under bash with real jq against a settings document carrying the box's own masked values (48-bullet client_secret, 32-bullet smtp password) — it emittedoidc_secret: "",smtp_pw: "",bounce_pw: ""while preservingsmtp_uuid: u-1(the key Listmonk's password restore matches on),smtp_host,oidc_enabled: true,oidc_cid: newslettersandapp.site_name; feeding that through the SMTP reconciler's own merge produced a PUT body with the real relay password restored andsecurity.oidc.client_secret: "". Diff: 3 files, 127 insertions / 0 deletions (86 non-test lines); no assertion, test or leg touched. The live legs need a rented droplet and re-prove on the next drive.. evidence:/home/dev/swarm/Matou/idss/test-results/drive-rented-services/20260918T211405Zon matou-workstation.close-report for #1611 — status
success✅ close-report gates passed — every claim verified against main; issue closed.
envelope