Stop shipping the MCP service default credential; make Helm use the mcp account - #188
Stop shipping the MCP service default credential; make Helm use the mcp account#188jgruberf5 wants to merge 16 commits into
Conversation
…ount (#187) The seeded `mcp` service account (role=admin) shipped a known password, MCP_SERVICE_PASSWORD = "mcp-service-changeme" -- a live admin credential with no rotation gate. And the Helm chart was worse than #187 described: mcpUsername was `admin`, so the MCP server logged in as the HUMAN admin, not the service account, and it only worked because that default was also "changeme". #184 breaks that outright (the admin password is generated now), so this also un-breaks MCP on Helm. - config.py: MCP_SERVICE_PASSWORD defaults to None (no shipped value). It's a shared secret and can't be auto-generated, so validate_production fails fast in staging/prod if it's unset or the known default, mirroring JWT/ENCRYPTION_KEY. - startup_steps: seed the mcp service account only when MCP_SERVICE_PASSWORD is set; unset -> not seeded (MCP unavailable until configured), never a default. - Helm: mcpUsername `admin` -> `mcp` (the dedicated service account), mcp-password generated (randAlphaNum, reused across upgrades), and _helpers.tpl injects MCP_SERVICE_USERNAME/PASSWORD into the BACKEND from the SAME secret the MCP server reads as BNK_FORGE_USERNAME/PASSWORD -- so both agree (mcp/generated), and the mcp account is must_change_password=False so #184's gate doesn't block it. - Compose: dropped the `:-mcp-service-changeme` fallback; unset -> empty -> the MCP server fails clearly and the backend skips seeding, rather than a weak default. .env.example documents it as a shared secret with no default. Tests: production/staging validation fails when MCP_SERVICE_PASSWORD is unset or the known default, and passes when set; the ensure_service_user tests already use explicit passwords. helm lint clean, ruff clean. Overlaps #180 and #184 on helm secrets.yaml/values.yaml/_helpers.tpl (all touch the generated-secret block) -- merge-time rebase. Fixes #187 Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
Self-review of #188. The compose fix was incomplete: the backend's env anchor (x-backend-env / x-local-backend-env) never set MCP_SERVICE_PASSWORD, so the backend only ever saw the config default -- a rotated .env value reached the MCP server but not the backend, so they mismatched. My None default turned that latent bug into "MCP never authenticates when set". Added MCP_SERVICE_USERNAME/PASSWORD to both compose anchors so the backend and MCP server source the same .env value. `docker compose config` confirms the backend now renders MCP_SERVICE_PASSWORD/USERNAME. Also fixed a stale doc: docs/E2E-CRITICAL-004 listed MCP_PASSWORD=changeme (not a real var) -> MCP_SERVICE_PASSWORD, no default. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
mwiget
left a comment
There was a problem hiding this comment.
Good PR, and the discovery buried in it is the valuable part: mcpUsername: admin meant the MCP server was logging in as the human admin all along, and only worked because both defaults happened to be changeme. That would have surfaced as "MCP broke mysteriously" the moment #186 landed. Catching it here rather than there is worth more than the credential fix itself.
Two things need attention before merge. Both are about the upgrade path -- new installs are correctly fixed.
Verified
ensure_service_usergenuinely reconciles rather than only creating: on every startup it rewriteshashed_password, and resetsrole,is_activeandmust_change_password=False. So a rotatedMCP_SERVICE_PASSWORDpropagates, and #186's gate can't block the service account.- The Helm wiring is symmetric --
_helpers.tplgives the backendMCP_SERVICE_USERNAME/PASSWORDfrommcp-username/mcp-password, andmcp.yamlreads the same two keys asBNK_FORGE_USERNAME/PASSWORD. Same secret, same keys, both sides. - Your self-review catch is a real latent bug, not a tidy-up:
x-backend-envnever setMCP_SERVICE_PASSWORD, so a rotated.envvalue reached only the MCP server. That was silently broken before this PR and would have stayed broken.
Blocking 1 -- every existing Helm install keeps changeme, permanently
$mcpPass falls back to $existing.data["mcp-password"], and on any already-deployed chart that value is changeme -- it was the published default in values.yaml. So:
- new installs: generated password. Fixed.
- existing installs:
changemesurvives the upgrade, silently.
And unlike the human admin in #186, nothing ever forces it to change: the mcp account is role=admin with must_change_password=False, so #186's rotation gate deliberately does not apply. The result is a permanent, ungated, publicly-documented admin credential on every deployment that already exists -- which is the exact thing #187 is about.
Preserve-on-upgrade is the right default for an operator-chosen secret. This one isn't operator-chosen: it's a generated shared secret whose only consumers are two pods that both read it from this Secret. So it can be rotated safely, and detecting the known default is cheap:
{{- if eq $mcpPass "changeme" -}}{{- $mcpPass = randAlphaNum 24 -}}{{- end -}}
One caveat that has to come with it -- see the note below on checksum/secret. If you'd rather not rotate automatically, then this needs to be loud instead: NOTES.txt and the CHANGELOG telling operators to run --set secrets.mcpPassword=... once. What it can't be is silent.
Blocking 2 -- this is a breaking change and isn't declared as one
validate_production now SystemExits in staging/prod when MCP_SERVICE_PASSWORD is unset. Any existing compose deployment running ENVIRONMENT=production that relied on the shipped default will refuse to start after upgrading. That is the correct behaviour -- failing fast beats booting with a known admin credential -- but neither commit on this branch carries a BREAKING CHANGE footer:
fa5a174 review fix: compose backend must actually receive MCP_SERVICE_PASSWORD (no BREAKING marker)
c0e4a6e fix: stop shipping the MCP service default; make Helm use the mcp account (#187) (no BREAKING marker)
scripts/extract-breaking-changes.sh reads exactly that footer, so as it stands the release notes will not mention that a previously-optional variable is now mandatory. Operators find out when the backend won't boot. Given how #177 went, this is worth getting right at the commit rather than patching the notes afterwards:
BREAKING CHANGE: MCP_SERVICE_PASSWORD is now required in staging/production.
Deployments that relied on the shipped default ("mcp-service-changeme") will
exit at startup until it is set to the same value the MCP server receives as
BNK_FORGE_PASSWORD.
Non-blocking
- No
checksum/secretannotation anywhere in the chart, so changing a generated secret doesn't roll the pods that consume it. Pre-existing, but it matters more now thatmcp-passwordis generated and shared between two deployments: if ahelm upgraderolls the backend and not the MCP server, the backend re-seeds the account with the new value while MCP still holds the old one, and MCP auth breaks until its pod restarts. This is also the caveat on the auto-rotate suggestion above -- rotating without an annotation opens exactly that window. docker compose upno longer yields a working MCP without setting the variable first. Deliberate and documented in.env.example, but worth a line wherever the compose quickstart lives, since "MCP tools return auth errors" is a confusing first-run experience.- Overlaps #180 (approved), #184/#186 and this PR all in
secrets.yaml/values.yaml/_helpers.tpl. You've flagged it; just noting the rebase order will matter, since #180 and #188 make different edits to the samemcp-passwordblock.
|
|
||
| {{- $mcpPass := .Values.secrets.mcpPassword -}} | ||
| {{- if and (not $mcpPass) $existing -}} | ||
| {{- $mcpPass = (index $existing.data "mcp-password" | b64dec) -}} |
There was a problem hiding this comment.
On an existing install this resolves to changeme -- that was the published default in values.yaml, so it is what is sitting in every already-deployed Secret. The upgrade preserves it.
That leaves a role=admin account with a documented password and, unlike the human admin in #186, no gate that will ever force a change: ensure_service_user sets must_change_password=False on every startup, deliberately, so the service account isn't blocked. New installs get a generated value; every existing one silently keeps the credential #187 was filed about.
Preserve-on-upgrade is right for a secret an operator chose. This one is generated, and its only two consumers both read it from this Secret, so it can be rotated without asking anyone:
{{- $mcpPass := .Values.secrets.mcpPassword -}}
{{- if and (not $mcpPass) $existing -}}
{{- $mcpPass = (index $existing.data "mcp-password" | b64dec) -}}
{{- end -}}
{{- /* #187: the published default must not survive an upgrade. */ -}}
{{- if eq $mcpPass "changeme" -}}{{- $mcpPass = randAlphaNum 24 -}}{{- end -}}
{{- if not $mcpPass -}}{{- $mcpPass = randAlphaNum 24 -}}{{- end -}}
With one caveat: no template in this chart carries a checksum/secret annotation, so a Secret change alone doesn't roll the pods. If an upgrade rolls the backend but not the MCP server, the backend re-seeds the account with the rotated value while MCP still holds the old one. Worth adding
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}to both pod templates alongside the rotation, so the two always move together.
If you'd rather not rotate automatically, the alternative is fine too -- but then it has to be loud in NOTES.txt and the CHANGELOG, because the failure mode of staying quiet is that nobody ever changes it.
| # #187: the MCP service password is a shared secret and cannot be | ||
| # auto-generated -- it must be set explicitly and identically on the | ||
| # backend and the MCP server. Refuse an unset or known-default value. | ||
| if not self.MCP_SERVICE_PASSWORD or self.MCP_SERVICE_PASSWORD == "mcp-service-changeme": |
There was a problem hiding this comment.
This is the right call -- an unset shared secret should stop the boot rather than fall back to something guessable -- but it changes the contract for deployments that already exist. Anyone running ENVIRONMENT=production on compose today relies on the shipped default and has never set this; after upgrading, the backend exits at startup.
Neither commit on this branch declares it:
fa5a174 review fix: compose backend must actually receive MCP_SERVICE_PASSWORD (no BREAKING marker)
c0e4a6e fix: stop shipping the MCP service default; make Helm use the mcp account (#187) (no BREAKING marker)
scripts/extract-breaking-changes.sh matches BREAKING CHANGE in the commit body, so without the footer this won't reach the release notes at all and the version derivation won't see it either. A footer on the squash-merge commit:
BREAKING CHANGE: MCP_SERVICE_PASSWORD is now required in staging/production.
Deployments that relied on the shipped default ("mcp-service-changeme") will
exit at startup until it is set to the same value the MCP server receives as
BNK_FORGE_PASSWORD.
Worth also confirming the check can't fire in development -- validate_production is only called for staging/prod as far as I can see, which is what makes the compose-dev path (unset -> warn, don't seed) work rather than crash.
…hange mwiget's review of #188. Blocking 1 — existing installs kept "changeme" forever. $mcpPass falls back to the deployed Secret's value, which on any already-installed chart IS the published "changeme" default, and nothing ever rotated it (the mcp account is role=admin, must_change_password=False, so #186's gate deliberately doesn't apply). Since this is a generated shared secret whose only consumers are the two pods that read it from the same Secret -- not an operator-chosen value -- it can be rotated safely: detect the known default and regenerate it. Blocking-adjacent — the auto-rotate needs the pods to roll together, or a helm upgrade could roll the backend (which re-seeds the mcp account with the new value) while the MCP server keeps the old one until its next restart. Added a checksum/secret annotation to the api and mcp pod templates so both roll when the Secret changes. (On a stable upgrade every value is loaded from the existing Secret via lookup, so the checksum is stable and pods don't roll needlessly.) BREAKING CHANGE: MCP_SERVICE_PASSWORD is now required in staging/production. Deployments that relied on the shipped default ("mcp-service-changeme") will exit at startup (validate_production) until it is set to the same value the MCP server receives as BNK_FORGE_PASSWORD. New installs generate it (Helm) or require it in .env (compose); existing Helm installs on the old "changeme" secret are rotated automatically on the next upgrade. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
Both blockers fixed (e67dd31). Blocking 1 — existing installs kept I took the caveat with it rather than leaving it: added a Blocking 2 — undeclared breaking change. e67dd31 now carries the Non-blocking noted: the compose-quickstart line and the #180 rebase order on the shared |
…#188) bonnyrf5 aggregate review, #180. --write fails open (scripts/sync-version-artifacts.sh): a sed whose pattern matched nothing no-ops silently, so a format change to any artifact left it unchanged while the script still reported success -- and the release job commits that [skip ci]. Now re-reads all three with the same helpers --check trusts and exits 1 if any didn't take ${V}. Verified: happy path passes, a package.json whose "version" line no longer matches makes it exit 1. MCP secret (secrets.yaml / values.yaml): this PR generated mcp-password as a chart-owned secret with mcpUsername: admin, which breaks MCP auth on every fresh install -- it's a client credential the MCP server must also read, not a chart-owned value. That's the half-fix bonnyrf5 flagged. The complete fix (point the chart at the mcp service account, wire MCP_SERVICE_PASSWORD into the backend so ensure_service_user reconciles the hash, rotate the shipped default on upgrade, checksum/secret roll) lives in #188. Reverted the MCP edits here so this PR stays scoped to version-artifact consistency; its MCP diff vs staging is now empty, so it no longer overlaps #188. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…scheme The user flagged that many docs still tell operators to log in with admin/changeme, which #184/#186 removed — no default ships; the backend generates a random admin password on first startup, writes it to /app/keys/initial_admin_password (mode 600, boot log points there), and forces a change on first login. DEFAULT_ADMIN_PASSWORD sets a known one instead. Swept the stale instructions to match the actual behavior: - docs/INSTALLATION.md: 4 prose spots (local, linux-server x2, VM note); also tightened the canonical credentials block to name the file path and give both the `docker exec ... cat` and `docker logs ... grep "GENERATED password"` retrieval commands. - Makefile: both deploy-summary echoes. - The_BNK_Forge_Developers_Guide.md: quickstart + summary. - dist/README.md, dist/install.sh: customer login instructions. - vm-bnk-forge/README.md: quickstart line + the security "Default credentials" note. Left alone: config.py's explanatory comment, the historical archive review, and the MCP-credential lines (dist/.env.example) which belong with the MCP scheme in #188. install-guide.html was handled on #183 to keep that file on one branch. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
mwiget
left a comment
There was a problem hiding this comment.
Approving at e67dd317. Both blockers from my last pass are fixed, all 25 checks are green (17 pass, 8 skipped by path filters, 0 pending, 0 failed), and I re-verified the rotation end to end rather than reading it.
Blocker 1 — existing installs keep changeme: fixed. Rendered the chart at this head three ways:
secrets.mcpPassword |
rendered mcp-password |
|---|---|
unset (default "") |
FkRMpTL6nP37tCJuAv0rM3do (generated) |
changeme |
drC78mncTooJPFjeh14NrTIs (rotated — the known default never survives) |
myrealpass |
myrealpass (operator value honored) |
So the new {{- if eq $mcpPass "changeme" -}} line catches exactly the case it needs to — the value that arrives from lookup on every already-installed chart — and leaves a real operator-chosen password alone.
Blocker 2 — the two pods drifting apart: fixed, and the rotation actually lands. I traced the whole chain rather than trusting the annotation alone:
- Helm rotates the Secret;
checksum/secreton bothapi.yamlandmcp.yamlchanges → both roll together;seed_auth_step()callsensure_service_user(...)on every backend start, and its else-branch reconcileshashed_passwordto the current env var unconditionally — so the DB hash follows the rotated Secret without any manual step;- the MCP server reads
BNK_FORGE_PASSWORDfrom that same Secret, so both sides land on the same value.
Point 3 is the part that makes this safe: without an unconditional reconcile, a rotated Secret would lock the MCP account out permanently. It's there, it's idempotent, and its docstring says why.
Also confirmed the MCP_SERVICE_PASSWORD unset path degrades honestly — a warning plus an unseeded account (MCP unavailable), not a shipped default — and that the BREAKING CHANGE: footer is in the commit body, so extract-breaking-changes.sh will pick it up and the release will be a major.
Two non-blocking notes, neither worth another round:
- Transient rollout window. During
helm upgradethe new MCP pod can come up with the rotated password while the old api pod is still serving the old hash, so MCP auth fails until the new backend finishesseed_auth_step(). Self-healing on reconnect, and the alternative (ordering hooks) costs more than it buys — just be aware the MCP server may log auth failures for a few seconds mid-upgrade. secrets.mcpPassword: changemeset deliberately (a lab reproducing the old default) is silently replaced rather than rejected. Consistent, since both consumers read the same Secret — but it is the one input the chart ignores.
…oud script The dist/ files are shipped to customers (git ls-files dist/ is the tarball manifest), and they still carried the exact pre-#188 bug this PR fixes for the main compose: the MCP server logged in as ${MCP_USERNAME:-admin} with ${MCP_PASSWORD:-changeme} — the human admin account and a shipped default — and the backend never received a matching MCP_SERVICE_PASSWORD to reconcile a service account. So the credential fix was incomplete for the people who actually deploy. Mirrored the main-compose fix into dist/docker-compose.yml, dist/docker-compose.local.yml, and the ibm_cloud inline compose: - backend env anchors now export MCP_SERVICE_USERNAME=${MCP_USERNAME:-mcp} and MCP_SERVICE_PASSWORD=${MCP_PASSWORD:-}, so the backend seeds the mcp account; - the mcp server authenticates as ${MCP_USERNAME:-mcp} / ${MCP_PASSWORD:-} — the mcp service account, no changeme default. - dist/.env.example switches MCP_USERNAME to mcp, empties MCP_PASSWORD, and tells the operator to set it (the backend refuses to boot in production without it). Verified with docker compose config: backend and mcp receive the SAME secret on the same service account; base and base+local both render valid. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…word scheme The cloud bootstrap script still printed 'admin / changeme' at the end. Aligned it with the #184/#186 scheme (generated password at /app/keys/initial_admin_password, or DEFAULT_ADMIN_PASSWORD) alongside this PR's MCP edit to the same file, so the script is fixed on one branch rather than conflicting across two. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…#188) bonnyrf5 aggregate review, #180. --write fails open (scripts/sync-version-artifacts.sh): a sed whose pattern matched nothing no-ops silently, so a format change to any artifact left it unchanged while the script still reported success -- and the release job commits that with CI suppressed. Now re-reads all three with the same helpers --check trusts and exits 1 if any didn't take ${V}. Verified: happy path passes, a package.json whose "version" line no longer matches makes it exit 1. MCP secret (secrets.yaml / values.yaml): this PR generated mcp-password as a chart-owned secret with mcpUsername: admin, which breaks MCP auth on every fresh install -- it's a client credential the MCP server must also read, not a chart-owned value. That's the half-fix bonnyrf5 flagged. The complete fix (point the chart at the mcp service account, wire MCP_SERVICE_PASSWORD into the backend so ensure_service_user reconciles the hash, rotate the shipped default on upgrade, checksum/secret roll) lives in #188. Reverted the MCP edits here so this PR stays scoped to version-artifact consistency; its MCP diff vs staging is now empty, so it no longer overlaps #188. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
mwiget
left a comment
There was a problem hiding this comment.
Re-approving at ba780490 — 25/25 green. This covers 4de8884 and ba780490, which landed after my approval of e67dd317.
Extending the scheme to dist/ was the right call — the customer package was the one surface still shipping admin / changeme as a live MCP credential, which is the actual exposure #187 is about. All three compose files are wired consistently (MCP_SERVICE_USERNAME/MCP_SERVICE_PASSWORD on the backend, BNK_FORGE_USERNAME/BNK_FORGE_PASSWORD on the MCP server, same variable behind both), and folding the ibm_cloud_bnk_forge.sh admin-login line into this PR rather than #186 is the right instinct — that file has an MCP edit here too, so splitting it would have conflicted across branches.
I checked the thing that would have made this a blocker: whether an empty MCP_PASSWORD now bricks a customer install. It doesn't. validate_production refuses an unset MCP_SERVICE_PASSWORD, but it returns early unless ENVIRONMENT is staging/production (config.py:193), and dist/docker-compose.yml sets no ENVIRONMENT — so the default development applies. A customer who skips the variable gets a booting stack, the seed_auth_step warning, and an MCP server that can't authenticate until they set it. Visible in the logs, recoverable by editing .env and restarting, and no silent live credential. That's the right failure shape for a customer package.
Two non-blocking notes:
1. The same secret now has two names across the two packages. Root .env.example documents MCP_SERVICE_USERNAME / MCP_SERVICE_PASSWORD (lines 87-88) and root compose reads exactly those; dist/.env.example uses MCP_USERNAME / MCP_PASSWORD and dist compose reads those. Each package is internally consistent, so nothing is broken — but an operator who follows the repo docs while editing a dist/.env will set MCP_SERVICE_PASSWORD, dist compose will ignore it, and MCP stays unseeded with only a log line to explain why. If the divergence is deliberate (not breaking existing customer .env files), a one-line pointer in dist/.env.example — "called MCP_SERVICE_PASSWORD in the source repo" — would cost nothing.
2. #183's install guide is now slightly stale on this variable. It says MCP_PASSWORD — "Change from the default." After this PR there is no default to change; it must be set, and leaving it empty disables MCP rather than leaving a weak credential — a different instruction to the reader. The same callout also says these values "cannot be changed easily after the stack first starts", which is now untrue for this one: ensure_service_user reconciles the hash on every boot, so changing MCP_PASSWORD and restarting just works. #183 is already approved and green, so this is a small follow-up on whichever branch is convenient.
mwiget non-blocking note on #188: the same MCP secret has two names — the source repo uses MCP_SERVICE_USERNAME/MCP_SERVICE_PASSWORD, the dist package uses the shorter MCP_USERNAME/MCP_PASSWORD. Each package is internally consistent, but an operator following the repo docs while editing a dist/.env could set MCP_SERVICE_PASSWORD (which dist compose ignores) and leave MCP unseeded. Added a one-line pointer so the mapping is explicit; kept the short names to avoid breaking existing customer .env files. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…ault scheme mwiget non-blocking note (via #188): after #187/#188 the MCP password has no default to 'change from' — it must be set, empty disables MCP rather than leaving a weak credential, and it is reconciled on every boot so it CAN be rotated later (unlike postgres/redis, which are baked in at first init). Updated the .env table row and split the 'cannot be changed easily' callout so that claim applies only to postgres/redis, with MCP called out as set-required-but-rotatable. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
mwiget non-blocking note on #188: after this PR a bare 'docker compose up' no longer yields a working MCP without setting the variable first — deliberate and in .env.example, but a first-run 'MCP tools return auth errors' is confusing. Added a short note by the Quick Start start command (kept away from #186's Login table edit so the two README changes merge cleanly). Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
Both of your non-blocking notes addressed:
Also added a Quick-Start note in |
mwiget
left a comment
There was a problem hiding this comment.
Re-approving at 770c4c48 — 25/25 green. Both of my non-blocking notes are closed.
795c651 adds the var-name mapping to dist/.env.example, which is the case I was worried about: an operator reading the source repo's docs sets MCP_SERVICE_PASSWORD in a dist/.env, the dist compose reads MCP_PASSWORD, and MCP stays unseeded with only a log line to explain it. The note says both names and why they differ (existing customer .env files keep working), so the divergence is now documented intent rather than a trap.
770c4c48 goes past what I raised. The README's quick-start had no mention of the MCP credential at all, so a developer following it got a stack where MCP tools return auth errors with nothing pointing at the cause. Stating that the stack still comes up and only MCP is affected is the useful half — that's the difference between "did my install fail?" and "I skipped one variable."
Everything from the earlier passes stands: the changeme rotation verified across three renders, the ensure_service_user reconcile chain that makes rotation land on both sides, the checksum/secret annotations rolling the two pods together, and dist/ deployments defaulting to ENVIRONMENT=development so a missing MCP_PASSWORD degrades rather than refusing to boot.
Worth noting for sequencing: #183's install guide now documents this PR's scheme (and #186's), so #183 wants both merged ahead of it. All three are approved and green.
Review: BLOCKReviewed under the review-discipline pipeline at Verified correct — the shared-secret consistencyThis is the part the PR gets right, and it's the part that's easy to get wrong: all four compose renders agree ( Blocker — on two shipped install paths, the reconcile is pointed at the human admin row
So on a fresh IBM Cloud install the admin password silently becomes the MCP secret — and the banner this PR edits at The That re-creates the publicly-known default admin credential #186 exists to remove, with the forced-change gate disabled — because Class fix: Blocker — the upgrade path: the account is left pre-existing and the old default still authenticates
Reached independently two ways. By inspection: So "unset → not seeded, never a default" is true for fresh installs only — and upgrades are exactly the population that has the default. Blocker —
|
…ADMIN_PASSWORD bonnyr-f5 BLOCK review of #186. All findings independently reproduced and confirmed. BLOCKER — must-change gate bypassed on dependency-less routes. The gate lived only in the get_current_user dependency; ~32 /api routes declare none and rely on AuthMiddleware alone, which validated the token but never loaded the User — so must_change_password was invisible and the seed credential reached them (proven: DELETE /api/benchmarks/configs, GET /api/system/process-metrics). Moved the gate to services.auth_service.enforce_password_change and enforce it in BOTH the dependency AND the middleware, for JWT and bnk_ API tokens. Regression test: a must-change token now gets 403 on /api/system/process-metrics, exempt paths still work, and it clears after rotation. BLOCKER — helm upgrade of a pre-#184 release failed to render: secrets.yaml did `index $existing.data "admin-password" | b64dec` with no guard; the key doesn't exist on old Secrets → nil → b64dec error. Added a hasKey guard. BLOCKER (upgrade) — existing installs kept admin/'changeme' with must_change=False, unhelped by the new gate, and /api/auth/change-password (exempt) let it persist. seed_admin_user now rotates on boot: if 'admin' still authenticates with a known shipped default, force must_change_password. Tested. MAJOR — DEFAULT_ADMIN_PASSWORD reached no compose service (config.py has no env_file; no anchor passed it), so "set it in .env" was inert. Plumbed it into the root, local and dist backend env anchors (verified via docker compose config). MAJOR — the README/INSTALLATION retrieval command grepped the boot log, which prints a POINTER, not the secret. Fixed to `docker exec bnk-forge-backend cat /app/keys/initial_admin_password`. MAJOR (test gap) — added the 0o600 mode assertion the "harden the password-file mode" commit was missing. Cross-PR (documented on the PR, resolved in #188): the mcp-service-changeme default, helm mcpUsername: admin, and ensure_service_user's username collision. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…le mcp on upgrade bonnyr-f5 BLOCK review of #188. All findings reproduced and confirmed. BLOCKER — the reconcile pointed at the human admin row. ensure_service_user reconciles by username (rewrites hash, clears must_change_password, forces role=admin/active). With MCP_USERNAME still 'admin' on an existing .env (its old shipped default) or ibm_cloud's MCP_USERNAME=admin, it took over the human admin and disabled #186's gate on it. Class fix: refuse a reserved human username (raise), and fixed ibm_cloud MCP_USERNAME=admin -> mcp. Tested: reconciling 'admin' raises and leaves the row (hash + must_change) untouched. BLOCKER — upgrade with MCP_SERVICE_PASSWORD unset left the pre-existing mcp account (seeded by a prior release with 'mcp-service-changeme') still authenticating; the reconcile only ran on the set branch. Added disable_stale_service_user, called on the unset branch, so the stale default is deactivated until a real password re-seeds it. Never touches a reserved username. BLOCKER — .env.example shipped a live credential: the inline comment on the `MCP_SERVICE_PASSWORD=` line becomes the password verbatim when uncommented (and validate_production accepts it). Moved the prose to its own line. MAJOR — validate_production only rejected 'mcp-service-changeme'; the actually shipped default across dist/helm/scripts was 'changeme'. Now rejects both. Cross-PR (#186): the admin-side upgrade rotation and the middleware gate that make this account's role=admin blast radius safe are fixed on #186. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
@bonnyr-f5 — reproduced every finding; all real, all fixed in Blockers — fixed
Major — fixed
Acknowledged / cross-PR
Nothing here was wrong — thank you for the depth. |
…vy exp bonnyr-f5 BLOCK review of #183. All findings reproduced and confirmed. BLOCKER — the install guide's happy path 404'd: the registry was corrected to ghcr.io/f5devcentral but BNK_FORGE_VERSION stayed 'customer-build', a jlcode-tech- era tag no workflow builds. Every pull returned manifest unknown. Switched all five sites to the tags the release actually publishes (rolling 'latest'; pin example now a real version '3.1.6' instead of the dead '3.0.1-cb.<sha>'). MAJOR — DOCKER.md's blanket "images are signed" is false for 100% of currently- published images: release-publish is gated on a successful final/manual release, and both main-branch runs failed before it. Qualified: signed "from v4.0.0 onward (the first release cut through the signing pipeline)". MINOR — roadmap.yaml:219 was a LIVE in-progress row still naming ghcr.io/jlcode- tech (not the dated historical prose the PR body claimed); pointed it at f5devcentral and regenerated ROADMAP.md/roadmap.html. Added trivy 'exp:2026-09-12' to CVE-2026-7598 so the revisit is machine-enforced, not a prose deadline. Acknowledged (documented on the PR): the roadmap issue links >#191 are upstream numbers absent from this squashed mirror; the PR-body claim about MIN_UPGRADE_FROM is stale (the file correctly reads v3.1.6). Merge #183 LAST (after #186 and #188). Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
Review: BLOCKRound 2, cold re-audit of The takeover I flagged in round 1 is closed at the value level and I verified it directly: But the refusal is a denylist of one name, and the mutation it guards is wider than the hash. BLOCKER 1 — INV-18: a one-name denylist, guarding a mutation that escalates privilege
_RESERVED_HUMAN_USERNAMES = frozenset({"admin"})and the reconcile branch at user.hashed_password = hash_password(password)
user.must_change_password = False
user.role = role # default "admin"
user.is_active = TruePoint
Class fix: stop identifying service accounts by name. Gate on a property of the row — a BLOCKER 2 — INV-11: the rotation branch never runs for the shipped
|
…healthcheck bonnyr-f5 round-2 BLOCK of #188. All reproduced. BLOCKER 1 — the guard was a one-name denylist over a privilege-widening mutation. Pointing MCP_SERVICE_USERNAME at any non-'admin' human row (operator, a named user) let the boot reconcile overwrite its password, promote it to admin, clear its must-change gate and re-activate it. Fixed on the class: added users.is_service_account (model + migration v2_154), ensure_service_user now records provenance at creation and REFUSES to reconcile any pre-existing row it did not create, and the reconcile mutation is narrowed to the hash + must_change only (no role/is_active — a reconcile never widens privilege). disable_stale only touches service-account rows. Test: reconciling a real 'operator' now raises and leaves its role + password intact. BLOCKER 2 — the rotation never ran for the shipped dist/IBM population: a known default ('changeme') is truthy, so the reconcile branch ran instead of the disable-stale branch. Now a known-default value is treated as unset on the rotation path too (shared MCP_KNOWN_DEFAULT_PASSWORDS with validate_production). BLOCKER 3 — validate_production SystemExits on an unset/known-default MCP_SERVICE_PASSWORD in staging/prod (correct), but the FATAL block's copy-paste remediation only covered JWT/ENCRYPTION. Added the MCP_SERVICE_PASSWORD line. (The CHANGELOG upgrade note lands on #183, which owns CHANGELOG.md.) MINOR — the MCP healthcheck reported HEALTHY with no credentials (empty password default), so a default deploy showed a green container that 401s every call. Now fails the probe. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…efaults; USER 1000 bonnyr-f5 round-2 REVISE of #183. MAJOR — the fail-closed MCP_SERVICE_PASSWORD change (#188) makes every existing staging/production install SystemExit on upgrade (they all ship changeme/ mcp-service-changeme), and no PR documented it. #183 owns CHANGELOG.md, so the 4.0.0 heads-up now carries that upgrade note alongside the container-runner one, and no longer dangles a "see the 4.0.0 entry" reference to a section that doesn't exist yet. MINOR — USER 65532 in the heads-up can't write a 1000:1000 workspace; recommend USER 1000. dist/.env.example shipped ghcr.io/your-org + BNK_FORGE_VERSION=3.0.1 (a verified 404); fixed to ghcr.io/f5devcentral + latest. Acknowledged (follow-up): trivy exp: on all entries + drop .trivyignore from paths-ignore; the DOCKER.md local-signing verify cert-identity/issuer pairing; the cosign identity regexp anchoring; the roadmap 'merged' chip. Merge #183 LAST. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
@bonnyr-f5 round 2 — the one-name denylist was exactly as shallow as you said. Fixed on the class in
|
…ploys My earlier "return 1 when not has_credentials" was too broad: a token-only deployment (BNK_FORGE_TOKEN set, no username/password) is a valid auth mode, and returning 1 there marked a working MCP container UNHEALTHY — and broke test_probe_returns_0_when_no_credentials_configured (the advisory MCP CI failure). The probe authenticates via /api/auth/login, which only accepts username/password, so it structurally cannot exercise a bearer token. Three-way contract now: - has_credentials -> run the login probe (unchanged) - token-only (has_token) -> skip the probe, return 0 (validated on real calls) - neither password nor token -> return 1 (bonnyr-f5 #188: cannot authenticate) Tests rewritten to set has_token explicitly and cover all three branches (token-only -> 0 + "token-only" log; no-auth -> 1 + "cannot authenticate" log). Verified against the real probe() with stdlib mock. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
@bonnyr-f5 Round-3 BLOCK addressed. You were right on all four blockers — one root cause ( Root cause & fix
Backfill scope (deliberately narrow — the justification)UPDATE users SET is_service_account = true
WHERE username = 'mcp' AND email = 'mcp@bnk-forge.local'
The pair (username + synthesised email) is the creation fingerprint and can't collide with a human provisioned through normal signup. Documented edge: an operator who set a custom Reproduction (isolated py3.11 venv, alembic Operations against SQLite)OLD migration — the stale row survives (your BLOCKER 1/2): FIXED migration — only the provable service row flips: Full trap table — resolved end-to-end (real
|
MCP_SERVICE_PASSWORD on upgrade |
before | after |
|---|---|---|
| unset / known default | stale row authenticates as admin | disabled — old default rejected |
| set to a real secret | reconcile refuses forever, MCP dead | reconciled + re-activated, MCP works |
BLOCKER 3 (docstring vs code)
ensure_service_user's reconcile branch now sets user.is_active = True. The provenance guard just above already proved the row is our service account, so re-activation is safe and it's exactly what disable_stale_service_user's docstring promised ("re-seeds and re-activates it"). Without it a stale→reconciled row stayed is_active=False and hit Account is disabled despite a correct password. Role is still left untouched — no privilege widening.
Other items in this PR's scope
- Healthcheck inverted row:
probe()now returns healthy (and never touches the backend) whenever a bearer token is set, even alongside a stale password — a token is a self-sufficient auth path. New test covers token+password. worker.yaml/beat.yaml: added thechecksum/secretannotation so they roll on thechangeme→random rotation likeapi/mcp(verified viahelm template).- Model drift nit:
User.is_service_accountnow carriesserver_default=false()to match the migration.
Verification
alembic heads→ single headv2_154; v2_154 upgrade→downgrade→upgrade round-trips cleanly (SQLite, Operations).84 passed—test_auth_service,test_migrations,test_startup_steps,test_auth_service_pure(incl. 3 new: backfill scope+roundtrip, reconcile-reactivates, and the full trap-table assertions).12 passed— mcp-servertest_healthcheck(incl. token+stale-password).- ruff clean on all changed files.
Cross-PR notes (not fixed here — for the integration branch)
These are the shared credential surface with #186 / cross-PR ordering; flagging, not touching, per the integration plan:
- INV-12
dist/legacy.env→ MCP asadmin/changemeand INV-23ibm_cloud_bnk_forge.sh:708initial_admin_passwordboth live in the#186credential surface (the 9-filegit merge-treeconflict set). They need resolving once on the merge-integration branch, not divergently here. - Healthcheck wired into only the dev compose (
dist/,ibm_cloud_bnk_forge.sh, HelmtcpSocket) — those files are in the same conflict set; wiring belongs on the integrated tree. docs/DEPLOYMENT.mdboot-halt note lives in Fix registry/cosign/upgrade metadata + USER-gate authoring guide — PR #177 Majors #183, which merges last — move that CHANGELOG hunk forward or merge Fix registry/cosign/upgrade metadata + USER-gate authoring guide — PR #177 Majors #183 together, as you noted.
Review: BLOCKRound 4, cold re-audit of BLOCKER 1 — the stale-credential disable is a no-op on the shipped dist upgrade path (INV-11)
BLOCKER 2 — migration backfill appended after the revision id already shipped (INV-7)
Major findings (all execution-proven unless noted)
Minors (selected)
Genuinely fixed, and verifiedINV-16: all four new test groups map to real CI jobs and pass (26 + 32 + mcp). INV-9: Cross-PR (BLOCK-class)The 9-file credential conflict with #186 (CROSS-1) is the series' central integration wall — see the Review Assessment
Findings & Action Items
|
…p by provenance (#188) BLOCKER 1 (INV-11): the stale-credential disable was a no-op on the dist upgrade path. dist/docker-compose maps MCP_SERVICE_USERNAME=${MCP_USERNAME:-mcp}, and an upgrading install's existing .env carries MCP_USERNAME=admin, so disable_stale_service_user(db, "admin") hit the reserved-username early-return and left the legacy mcp/mcp-service-changeme service row (role=admin) authenticating. Fix: key the disable on provenance (is_service_account IS TRUE) and deactivate every active service account, independent of the configured username. The provenance flag is never set on a human row, so no reserved-name guard is needed; startup calls disable_stale_service_user(db) with no username. BLOCKER 2 (INV-7): the backfill was appended to v2_154, which already shipped in earlier RCs. An install stamped at v2_154 never re-runs it, so exactly the existing installs it was meant to fix never got the backfill. Fix: restore v2_154 to its shipped add-column-only form and move the backfill into a NEW revision v2_155_backfill_is_service_account that chains from v2_154, keeping the same conservative dual-signal scope (username='mcp' AND email='mcp@bnk-forge.local'). alembic heads is a single head (v2_155); up/down round-trips cleanly; an install already at v2_154 applies v2_155 on the next upgrade. Also: DEPLOYMENT.md no longer tells operators to set MCP_USERNAME=admin / MCP_PASSWORD=<admin-password> (the exact input that triggers the reserved-username refusal) — it now documents the dedicated mcp service account and MCP_SERVICE_PASSWORD. Tests: provenance-keyed disable test added and the migration test drives v2_154 then v2_155; both guards mutation-tested red. Auth + migration + startup + config + auth-route suites pass (159 tests total under py3.11). Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
@bonnyr-f5 — round-4 BLOCKERS addressed. Both reproduced first, fixed, then verified with a py3.11 venv (uv, CPython 3.11.15) running alembic + pytest. Head is now BLOCKER 1 (INV-11) — stale-credential disable was a no-op on the dist upgrade pathReproduced against the real Fix ( Verified (same probe, after fix): BLOCKER 2 (INV-7) — backfill appended after the revision id already shippedFix: Single head: Verified via real alembic commands — an install already stamped at Guards mutation-tested (broke what they protect, confirmed red)
Both files restored after each mutation. Test output (py3.11)
Also fixed (directly triggers BLOCKER 1)
Not addressed here (your non-blocking Minors, called out for the record)Left for a follow-up / the #186 integration branch, as they are non-blocking and/or cross-PR: the Cross-PR (#186): this change touches only |
…P-cred 401 trap, operator image, dupes Round-4 review fixes (bonnyr-f5, comment 5366217504): BLOCKER (INV-23/INV-17): CHANGELOG.md and install-guide.html asserted, in the present tense, that the backend "refuses to boot / SystemExit"s on an unset or default MCP_SERVICE_PASSWORD. Verified against the tree: validate_production() (backend/core/config.py:181) checks only JWT/ENCRYPTION keys and ALLOWED_ORIGINS, never MCP_SERVICE_PASSWORD, and the default "mcp-service-changeme" still ships (config.py:103). That boot-time check lives in #188, not here. Reframed both docs as explicitly forward-looking ("from 4.0.0", "via #188", "once that check is in the tree") so #183's docs are true for the tree #183 ships, without dropping the #188 heads-up. Also: - install-guide Step 2: setting MCP_PASSWORD to an independent secret before first login 401s the MCP server against the still-default admin credential (dist wires MCP as admin/changeme). Rewrote the guidance to keep MCP_PASSWORD equal to the admin account password and rotate them together. - restart -> "docker compose up -d" where .env changes must be re-read (a plain restart does not re-read .env). - Documented the 7th signed/published image bnk-forge-operator in docs/DOCKER.md and dist/README.md (release.yml + publish-signed-images.sh build/sign 7). - Removed the duplicated "--user" sentence in the CI-runner module guide. - Removed the orphaned .callout-cred CSS (no element uses it). install-guide.html verified tag-balanced. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…istro MCP off admin/changeme BLOCKER 1 (bonnyr-f5 r4): the mcp service account (role=admin, must_change_password=False) was re-seeded every boot from the published default MCP_SERVICE_PASSWORD="mcp-service-changeme" and is EXEMPT from the #184 must-change gate -- a second live, publicly-known admin credential. Closed the same way as the human admin: MCP_SERVICE_PASSWORD now defaults to None, and ensure_service_user refuses any known published default (mcp-service-changeme/changeme) as a seed value, generates a strong random secret on a fresh row, and OVERWRITES an existing row still holding a published default with a fresh random secret. The published value can no longer authenticate; the reconcile stays idempotent for a generated/operator secret so reboots don't churn it. BLOCKER 2 (#186's share): every docker-compose/.env/shell distro pointed the MCP client at admin/changeme, which #184 already made unusable (admin password generated + gated). Repointed dist/docker-compose.yml, dist/docker-compose.local.yml, dist/.env.example and scripts/ibm_cloud_bnk_forge.sh at the mcp service account (MCP_SERVICE_USERNAME/MCP_SERVICE_PASSWORD, no shipped default), mirroring what this PR already did to the root compose; dropped the now-dead :-mcp-service-changeme fallback from the root compose files. The Helm mcp-username/mcp-password provenance (generate the secret + inject MCP_SERVICE_* into the backend from it) is #188's remit and left untouched. Also fixes the #186-introduced _helpers.tpl crashloop: adminMustChange: null rendered a bare `value:` (pydantic rejects the empty string); nil now falls back to the secure "true" while an explicit false still renders "false". Tests: added ensure_service_user mutation tests proving the published default cannot authenticate (fresh seed, None seed, upgrade rotation, idempotency, operator override). 143 auth/service/route/websocket tests pass; ruff + mypy clean; helm template/lint and docker compose config green. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…ring, helm idempotency (#188) Round-4 review classified these as Major (a PASS requires no Majors). All reproduced first, then mutation-tested. - auth: re-enabling a disabled service account via PUT /api/auth/users/{id} resurrected the shipped default. disable_stale_service_user only flips is_active; the bcrypt("mcp-service-changeme") hash stays, so a naive re-enable brought the published default credential back (proven: authenticates role=admin active=True). Add holds_known_default_password() and refuse the re-enable transition on a service-account row still holding a known default; the operator must rotate (set MCP_SERVICE_PASSWORD, which re-seeds + re-activates with a real hash). Mutation test: disable -> PUT re-enable (400) -> old default no longer authenticates. Legit real-password re-enable still works. - healthcheck (INV-10): the "no creds -> unhealthy" auth-probe had exactly one consumer (dev docker-compose.yml). Wire it into dist/docker-compose.yml so the shipped path (and the dist local overlay, which inherits it) fails green-but- non-functional MCP containers instead of a bare liveness ping that can't see a 401. Document MCP_PASSWORD (ships empty) in dist/README.md. - helm secrets.yaml: eq $mcpPass "changeme" fired on the values-supplied value, so randAlphaNum ran on every render -> non-idempotent (two templates gave two passwords) -> GitOps drift. Scope the shipped-default rotation to the persisted Secret ($existing.data) only; a values-supplied value is preserved verbatim. Verified with helm template (unset/changeme/real) + helm lint. - docs: DEPLOYMENT.md already corrected on this head (MCP_USERNAME=mcp, warns off admin, cites MCP_SERVICE_PASSWORD) — the Major was against cd521ca. Fix the half-updated MCP_USERNAME=admin leftovers in E2E-CRITICAL-004, mcp-server/README, and Makefile to the dedicated mcp service account. Suites (py3.11 venv): auth_service 33, routes_auth integration 19 (+2 new guard tests), routes_auth 3, startup_steps 9, auth_contracts 5, migrations 17, mcp-server healthcheck/config 17 — all pass. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
@bonnyr-f5 — round-4 Major findings addressed. The earlier pass wrongly deferred these as Minors; you classify them as Major and a PASS needs zero Majors, so they're fixed here. Head Major 1 —
|
…ntext, fix secret provenance, gate the agent WS bonnyr-f5 round-4 classes all Major items as blockers (a PASS requires zero Majors). This addresses every Major finding plus the quick, clearly-correct Minors, and defers the MCP-secret provenance surface to #188. Majors: - auth_service: an unwritable /app/keys no longer LOGS the generated plaintext. _persist_generated_password now raises GeneratedCredentialPersistError (no secret in the message) and every path persists BEFORE committing the DB row, so a failure leaves nothing committed and is re-runnable. seed_auth_step converts it to SystemExit (escapes main.py's best-effort except Exception) => refuse to start. Mutation-tested: reintroducing the leak fails the new tests. - Secret provenance: the upgrade rotation now honors DEFAULT_ADMIN_PASSWORD (Helm wires it from the admin-password Secret) when it is not a published default, so the Secret the docs tell operators to read is authoritative on upgrade too; otherwise it generates + writes the keys-file. NOTES.txt, docs/DEPLOYMENT.md and docs/INSTALLATION.md rewritten to the single rule. - user-pack/install-guide.html: point at the keys-file (the grep target was never logged) and drop the stale "default password is well-known" callout. - helm secrets.yaml: normalize a nil .data map to an empty dict once, so an existing Secret with no .data no longer errors "index of untyped nil"; all five keys share the hasKey guard. Proven across 4 topologies. Minors (quick, clearly-correct): - benchmarks agent WS Layer-2 now enforces the must-change gate (INV-10): a human token owing a change, or one that no longer resolves, is refused; agent-role tokens still connect. - rotation/reconcile use SELECT FOR UPDATE (INV-8) to stop two api replicas desyncing the stored hash from the keys-file. - docs/DEPLOYMENT.md runbook uses MCP_SERVICE_* (MCP runs its own mcp account). Deferred to #188: chart mcp-password provenance across the 9-file surface, and the name-keyed remediation (the only shipped role=admin defaults, admin + the mcp service account, are both handled). Tests: auth_service 49, startup_steps 10, benchmark_agent_auth 28 (all pass); mutation-verified the plaintext-log guard; helm lint/template green. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
Review: BLOCKRound 5, cold re-audit of Merges standalone: mechanically yes (fast-forward, no conflict). Semantically no — one line Round-4 blockers: confirmed closedBoth are genuinely fixed, and the migration hygiene is now clean:
BLOCKER-1 · the #187 remediation never fires on the path a diligent operator takes
So whenever a real password is configured under any username other than The real-world instance is the topology this PR's own docstrings name: a dist customer's existing Every existing Helm release is in the same population, since pre-#188 Helm never delivered these Note the shape: your round-4 fix made the disable provenance-keyed precisely so a name-keyed Useful side result from the same investigation: the legacy row is universally named Major-2 · the chart declines to rotate a value the same PR makes fatal
Major-3 · the documented fail-fast is unreachable on the entire dist population
Major-4 · INV-23 recurrence
Minors
Verified clean by executionSweep for hardcoded MCP passwords and BLOCKER-1 is the one to fix, and the fix is small: make the stale-row cleanup unconditional rather |
|
Cross-PR merge-order constraints for this series are now tracked in #192. Relevant here: this PR and #186 conflict on 16 files under both strategies, across the whole credential surface and both auth test modules. The coupling runs the other way too: this PR holds the |
…p admin, commit merge ordering Round-5 review (bonnyr-f5) fixes, verified against this tree: F1 (BLOCKER): the 4.0.0 upgrade step told dist operators to set MCP_SERVICE_PASSWORD, which the dist backend never reads — the dist &backend-env anchor passes no such variable, and config.py declares no env_file (process env only). The dist MCP client authenticates with MCP_PASSWORD (dist/docker-compose.yml:357 -> BNK_FORGE_PASSWORD). Rewrote the step to name MCP_PASSWORD, state MCP_SERVICE_PASSWORD is inert here, and mark the #188 boot-check as forward-looking (from 4.0.0). F2 (Major): disclosed the seeded `mcp` admin-role account whose default password (mcp-service-changeme) is published in the public config.py and is reconciled back on every boot, so it cannot be rotated in this bundle; noted #186 removes it. No longer hidden. F3 (Major): documented that MCP borrows the human admin login only until #186 wires the dedicated `mcp` service account; do not prescribe the human credential as the permanent machine identity. F4 (Major, INV-4): committed the #183 x #186 merge ordering in CHANGELOG (with/after #186 + #188), not only in a PR comment, incl. conflict- resolution guidance for user-pack/install-guide.html. Minors: swept dist/install.sh registry line ("images are public") to match dist/docker-compose.yml; made the dist/README.md end-user download URL an explicit version placeholder (no v3.1.6 release/asset exists); added the valid `merged` status to ROADMAP_PROCESS.md, roadmap-add.py help, and the roadmap-gen stats tally. Roadmap regenerates byte-identical. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…hart+docs (#188) Round-5 review (bonnyr-f5) BLOCK. Reproduce-first; each fix carries a test. BLOCKER-1 — remediation unreachable on the diligent-operator path. disable_stale_service_user lived in the `else` of the MCP_SERVICE_PASSWORD check, so an operator who did the right thing (set a strong MCP_PASSWORD) but left MCP_USERNAME at the legacy 'admin' hit the reconcile branch, where ensure_service_user raises a reserved-name ValueError (swallowed) and the legacy 'mcp' row was never disabled — still authenticating with 'mcp-service-changeme'. Make the provenance-keyed disable UNCONDITIONAL, before the reconcile; the reconcile re-activates the one configured account. Reproduced via a legacy-install fixture driving the real seed_auth_step (test_startup_seed_auth.py, the previously zero-coverage function); the diligent + dedicated-name cases failed pre-fix, pass post-fix. Mutation-tested: removing the unconditional disable fails 4/5 tests; name-keying the disable (INV-11 regression) fails 2/5. Major-2 — chart declined to rotate a value the PR makes fatal. secrets.yaml passed an operator-supplied `mcpPassword: changeme` straight through, but validate_production treats it as fatal under production -> crashloop. A rotate is non-idempotent for a values-supplied value (round-4 drift), so refuse it at render with `fail` — chart and fail-fast now agree. Also rotate a persisted default of EITHER known form (round 4 only caught "changeme"). helm template verified: empty->auto-gen, changeme/mcp-service-changeme->fail, real->passthrough. Major-3 — documented fail-fast unreachable on the dist population. ENVIRONMENT is never set anywhere in dist/, so validate_production returns early and the backend never "refuses to boot". Reworded dist/.env.example to state precisely that the account is simply left unseeded (MCP unavailable) unless ENVIRONMENT=staging| production, which the package does not set. Major-4 — INV-23 recurrence. ibm_cloud_bnk_forge.sh referenced /app/keys/initial_admin_password, a #186-only mechanism absent from this tree; restored the accurate admin / DEFAULT_ADMIN_PASSWORD-else-'changeme' line. Minors — expose is_service_account on the users listing so the UI toggle isn't blind (schema + _user_to_dict + guard test); add seed_auth_step coverage. Suites (py3.11/uv venv): auth+config+startup+migration+rbac 110 passed, 5 skipped; alembic single head v2_155; ruff clean; helm lint clean. Deferred to the #186+#188 integration branch (documented in PR comment with evidence): MCP auth-probe on the remaining 2/4 surfaces (Helm tcpSocket, image HEALTHCHECK) needs credential wiring entangled with #186; the two PRs overlap on 20 files and conflict on the credential surface. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
@/tmp/claude-1000/-mnt-d-project-bnk-forge/01a289e5-e845-497f-99d9-622be0bf9a98/scratchpad/comment.md |
…cp admin/changeme, guard the reserved admin identity, and unblock the event loop Round-5 blockers (bonnyr-f5). The admin-rotation core was proven correct; every fix here is in the second (mcp) account, its distribution, and the middleware. BLOCKER-1 (backend never received MCP_SERVICE_PASSWORD): the var reached the mcp client on every channel but the backend on none, so the backend generated a random secret while the client used the operator value -- they could never agree. Plumb MCP_SERVICE_USERNAME/MCP_SERVICE_PASSWORD into the backend on every deploy mode: the x-backend-env anchors in docker-compose.yml, docker-compose.local.yml and dist/docker-compose.yml (dist local inherits via env merge), the ibm installer's embedded compose, and the Helm shared-env in _helpers.tpl (sourced from the release Secret's mcp-* keys, identical to mcp.yaml). Verified with docker compose config + helm template. BLOCKER-2 (chart shipped mcpUsername: admin / mcpPassword: changeme): a live, publicly-known default admin credential in the PR that removes exactly that. values.yaml now ships mcpUsername: mcp and mcpPassword: "" with secrets.yaml generating a per-install secret and reusing it on upgrade (same treatment as admin-password). No shipped default renders. BLOCKER-3 (ensure_service_user had no identity check): it resolved its target purely by username and force-set role=admin. Pointed at admin it rewrote the human admin row and cleared the must-change gate. Add _RESERVED_HUMAN_USERNAMES and fail closed before any lookup (identifier kept identical to #188's guard so the two land cleanly on the integration branch). Major (blocking sync DB query in async dispatch): the must-change gate ran a synchronous DB session on every authenticated request straight on the event-loop thread. Move _verify_api_token and token_user_state onto run_in_threadpool so the blocking round-trip never stalls the loop. Minors: cover the bnk_ API-token middleware branch (must-change 403 + settled pass, exercising the threadpool path); correct the with_for_update comment to state the create path is serialised by the username UNIQUE constraint, not the row lock. Integration split (#186 + #188): the reserved-name guard and the Helm mcp-secret surface (values.yaml, secrets.yaml, _helpers.tpl) are shared with #188; the guard uses #188's identifier and the chart changes complete #186's own class, so the integration branch reconciles rather than conflicts. Tests: 192 passed across the auth/middleware/route suites (incl. 4 new); mutation-checked the reserved-name guard and the API-token gate (both caught). helm lint/template + docker compose config green on all changed deploy modes. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…188) The is_service_account additions to UserResponse/UserInfo/UserWithProjectCount changed the API surface; regenerate the committed spec so the P1 OpenAPI Spec Freshness check passes. Scoped diff: three is_service_account properties only. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
…elds #188's openapi.json regeneration added is_service_account schema fields; the frontend generated types must match or the "TypeCheck Frontend (tsc)" CI job fails. Regenerated via `npx openapi-typescript backend/openapi.json`; verified it matches what the CI freshness check produces. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
Combine the two complementary halves of the credential model: - #188 (already on the branch): is_service_account provenance, the v2_154/v2_155 migrations, the UNCONDITIONAL provenance-keyed disable_stale_service_user before reconcile, the _RESERVED_HUMAN_USERNAMES guard, and the openapi schema. - #186: the backend MCP_SERVICE_PASSWORD wiring across compose/helm/ibm, the chart mcpUsername/mcpPassword + per-install secret generation, run_in_threadpool for the sync DB calls in the async auth dispatch, and the published-default seed/rotate remediation. ensure_service_user unions both: provenance + reserved-name guard + published -default generate/rotate, with the provenance guard allowing rotation of a row that still authenticates with a shipped default (a stale pre-provenance service credential). seed_auth_step keeps #188's disable-first + gated reconcile and #186's GeneratedCredentialPersistError fail-closed. Infra files union the env vars/chart keys; dist unifies on the canonical MCP_SERVICE_* names.
Resolve user-pack/install-guide.html for the merged tree. With #184/#186/#188 now all present, convert #183's forward-looking hedges to present tense: the admin password is generated (no shipped default) and the API refuses every call until first-login change; MCP authenticates as a dedicated non-human `mcp` service account via MCP_SERVICE_PASSWORD (not MCP_PASSWORD/admin), the shipped mcp-service-changeme default is removed, and the backend fails fast in staging/production when it is unset or a shipped default.
#188 regenerated backend/openapi.json with the is_service_account fields but the committed frontend-v2/src/types/api-generated.ts was never regenerated, so openapi-types-check / TypeCheck Frontend would fail on the integration branch. Regenerate with the pinned openapi-typescript 7.13.0.
Consolidated landing of seven interdependent PRs whose shared credential and release/CI surfaces prevented merging in any order (see issue #192's conflict matrix). Merged in dependency order 179, 180, 181, 188, 186, 183, 182; the #186/#188 credential surface was reconciled once (single reserved-name guard; provenance + migrations + stale-disable combined with rotation + backend MCP wiring + threadpool). Squashed to one commit; per-PR history retained on the seven archived branches. Validated on the merged tree: ruff + mypy clean; 172 auth/credential/startup/ migration tests pass; single alembic head v2_155; openapi + frontend types fresh; helm lint/template and docker compose config green on all modes; version and detector self-tests green; commit-message lint clean. Closes #192. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
|
Superseded by the consolidated integration PR #193 (branch Closing unmerged, not abandoning: the branch is retained and all review history stays on this page for reference. See #193 for the integrated, validated result and #192 for the cross-PR conflict analysis. |
…he credential seed Addresses mwiget's three CHANGES_REQUESTED blockers on the #177 integration PR (#193), plus follow-up findings from a max-effort review of the same credential surface. The merge chose #188's "unset MCP_SERVICE_PASSWORD -> disable" over #186's "unset -> generate", so the generate/rotate-on-unset code was left unreachable but still documented, and the release-notes footer was missing. BLOCKING 2 (core/config.py): the MCP_SERVICE_PASSWORD comment claimed ensure_service_user "generates a random secret and surfaces it once" when unset, contradicting the merged behaviour. Rewrote it to state the truth: when unset (or a known default) seed_auth_step calls disable_stale_service_user, leaving the mcp account disabled/unavailable until an operator configures a real password; a published default is refused and rotated out; the backend receives MCP_SERVICE_PASSWORD on every deploy mode and reconciles to it when set. Also removed the duplicate #186 block that sat above the wrong field. BLOCKING 3 (services/auth_service.py): removed the unreachable usable_password is None branches from ensure_service_user (the generate-on-create and rotate-on-unset paths). seed_auth_step only calls it under the _mcp_pw_usable gate, so password is never None/default in production. ensure_service_user now requires a usable password and only creates/reconciles with it (failing closed and loudly if handed an unusable one); the unset case is owned entirely by disable_stale_service_user. Dropped the now-dead _log_generated_service_password helper and the service-account token_urlsafe/_persist_generated_password calls (_persist_generated_password is still used by the admin seed). Kept the reserved-name guard, the provenance check, the adopt-a-published-default remediation, and disable_stale_service_user fully intact. Updated the affected unit tests (published-default/None now refused; added a reachable adopt-and-reconcile test; stale-row setup builds the legacy row directly) and fixed scripts/mcp_live_smoke.py, which pointed operators at /app/keys/initial_mcp_password, a file no reachable path writes. CR-1 (services/auth_service.py, seed_admin_user): fixed a concurrent-first-boot admin lockout. With DEFAULT_ADMIN_PASSWORD unset and 2+ api replicas, both generated different passwords and the loser overwrote the keys file while its INSERT rolled back, so the file and the committed row disagreed. The fresh seed now creates+flushes first (the loser's INSERT raises IntegrityError -> rollback, no file write) and persists the keys file only after winning but before commit, so the file can only ever hold the committed row's password. Added a losing-replica test. CR-5 (services/auth_service.py, _persist_generated_password): os.open's 0600 mode only applies on create, so a pre-existing 0644 file was truncated in place and kept 0644, writing the secret world-readable. Added os.fchmod(fd, 0o600) and a test that a pre-existing 0644 file is tightened to 0600. CR-2 (routes/k8s_websocket.py, dpus_websocket.py, benchmarks.py): the WS auth validators called the blocking sync token_user_state directly on the event loop. Moved it off the loop via run_in_threadpool, matching core/auth_middleware.py. Validation: make lint-backend clean; mypy core/ schemas/ unchanged; auth (57) + ws/benchmark/startup (79) suites pass; alembic heads single v2_155; helm lint/template OK and --set secrets.mcpPassword=changeme fails the render; docker compose config OK on all modes; extract-breaking-changes and compute_version_bump self-tests pass; lint-commit-markers clean. BREAKING CHANGE: MCP_SERVICE_PASSWORD is now required — the backend SystemExits under ENVIRONMENT=staging|production when it is unset or a known default; the shipped admin/changeme default is removed and rotated out on upgrade; the dist bundle renames MCP_USERNAME/MCP_PASSWORD to MCP_SERVICE_USERNAME/MCP_SERVICE_PASSWORD; and the Helm chart ships mcpUsername=mcp with a generated mcpPassword instead of admin/changeme. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
Follow-up to the #177 integration on pr177-integration, addressing the CREDENTIAL/BACKEND/HELM/DIST/DOCS half of bonnyr-f5's BLOCK on PR #193. B1 (SECURITY): ensure_service_user no longer adopts any human account whose password is a known default. The adoption exception is now scoped to v2_155's exact backfill fingerprint (username=='mcp' AND email=='mcp@bnk-forge.local'), matching the migration's own conservative rule, and must_change_password is no longer cleared on an adopted row. Adds tests proving a human operator/changeme row (and a wrong-email mcp row) is REFUSED, not taken over. B2/B2b: all five compose files (root + dist docker-compose{,.local}.yml and the IBM embedded compose) honor legacy MCP_USERNAME/MCP_PASSWORD as aliases for MCP_SERVICE_USERNAME/MCP_SERVICE_PASSWORD on both backend and mcp env, so an existing customer .env keeps working after upgrade. Docs (dist/README.md, dist/.env.example, user-pack/install-guide.html) document MCP_SERVICE_PASSWORD as canonical with MCP_PASSWORD honored as a legacy alias. B3: ENVIRONMENT is plumbed to the backend in every compose file, so an operator who sets ENVIRONMENT=staging|production actually reaches config.py's MCP fail-fast. Helm already routes ENVIRONMENT=production onto api/worker/beat. M1: the unset-MCP behavior stays "disabled" (#188 over #186); added an explicit deliberate-consolidation comment at the decision point. M2: disable_stale_service_user skips the about-to-be-reconciled row and the "no usable MCP_SERVICE_PASSWORD" warning is conditional on a configured password, so a correctly-configured install no longer logs a false warning or commits an inactive MCP window on every boot. M7: the Helm mcp deployment and the IBM installer's mcp service now run the exec auth-probe healthcheck (python -m bnk_forge_mcp.healthcheck) instead of a bare tcpSocket probe. M8: the chart fails the render for a reserved mcpUsername (admin), mirroring the mcpPassword guard, and NOTES.txt/values.yaml call it out. Minors: deterministic checksum/secret via a shared helper (stable across renders, identical across api/worker/beat/mcp); vestigial _persist_generated_password filename docstring; false "backend generates its own secret" rationale corrected in compose/helpers/ibm; mcp_live_smoke.py #186/#188 attribution; e2e/config.py changeme default note; .env.example :58/:73/:94 fixes; unified BNK_FORGE_VERSION to latest across dist. Validation: ruff clean; typecheck-backend (core/ schemas/) Success 38 files; 199 auth/credential/startup/ws/migration tests pass incl. new B1 tests; helm lint + template stable checksums, --set secrets.mcpUsername=admin and secrets.mcpPassword=changeme both FAIL; docker compose config on all five modes shows the backend receiving MCP_SERVICE_PASSWORD (via either alias) and ENVIRONMENT. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4
) * Integrate the #177 follow-up stack (#179 #180 #181 #182 #183 #186 #188) Consolidated landing of seven interdependent PRs whose shared credential and release/CI surfaces prevented merging in any order (see issue #192's conflict matrix). Merged in dependency order 179, 180, 181, 188, 186, 183, 182; the #186/#188 credential surface was reconciled once (single reserved-name guard; provenance + migrations + stale-disable combined with rotation + backend MCP wiring + threadpool). Squashed to one commit; per-PR history retained on the seven archived branches. Validated on the merged tree: ruff + mypy clean; 172 auth/credential/startup/ migration tests pass; single alembic head v2_155; openapi + frontend types fresh; helm lint/template and docker compose config green on all modes; version and detector self-tests green; commit-message lint clean. Closes #192. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193): reconcile the merged unset-MCP-password model and harden the credential seed Addresses mwiget's three CHANGES_REQUESTED blockers on the #177 integration PR (#193), plus follow-up findings from a max-effort review of the same credential surface. The merge chose #188's "unset MCP_SERVICE_PASSWORD -> disable" over #186's "unset -> generate", so the generate/rotate-on-unset code was left unreachable but still documented, and the release-notes footer was missing. BLOCKING 2 (core/config.py): the MCP_SERVICE_PASSWORD comment claimed ensure_service_user "generates a random secret and surfaces it once" when unset, contradicting the merged behaviour. Rewrote it to state the truth: when unset (or a known default) seed_auth_step calls disable_stale_service_user, leaving the mcp account disabled/unavailable until an operator configures a real password; a published default is refused and rotated out; the backend receives MCP_SERVICE_PASSWORD on every deploy mode and reconciles to it when set. Also removed the duplicate #186 block that sat above the wrong field. BLOCKING 3 (services/auth_service.py): removed the unreachable usable_password is None branches from ensure_service_user (the generate-on-create and rotate-on-unset paths). seed_auth_step only calls it under the _mcp_pw_usable gate, so password is never None/default in production. ensure_service_user now requires a usable password and only creates/reconciles with it (failing closed and loudly if handed an unusable one); the unset case is owned entirely by disable_stale_service_user. Dropped the now-dead _log_generated_service_password helper and the service-account token_urlsafe/_persist_generated_password calls (_persist_generated_password is still used by the admin seed). Kept the reserved-name guard, the provenance check, the adopt-a-published-default remediation, and disable_stale_service_user fully intact. Updated the affected unit tests (published-default/None now refused; added a reachable adopt-and-reconcile test; stale-row setup builds the legacy row directly) and fixed scripts/mcp_live_smoke.py, which pointed operators at /app/keys/initial_mcp_password, a file no reachable path writes. CR-1 (services/auth_service.py, seed_admin_user): fixed a concurrent-first-boot admin lockout. With DEFAULT_ADMIN_PASSWORD unset and 2+ api replicas, both generated different passwords and the loser overwrote the keys file while its INSERT rolled back, so the file and the committed row disagreed. The fresh seed now creates+flushes first (the loser's INSERT raises IntegrityError -> rollback, no file write) and persists the keys file only after winning but before commit, so the file can only ever hold the committed row's password. Added a losing-replica test. CR-5 (services/auth_service.py, _persist_generated_password): os.open's 0600 mode only applies on create, so a pre-existing 0644 file was truncated in place and kept 0644, writing the secret world-readable. Added os.fchmod(fd, 0o600) and a test that a pre-existing 0644 file is tightened to 0600. CR-2 (routes/k8s_websocket.py, dpus_websocket.py, benchmarks.py): the WS auth validators called the blocking sync token_user_state directly on the event loop. Moved it off the loop via run_in_threadpool, matching core/auth_middleware.py. Validation: make lint-backend clean; mypy core/ schemas/ unchanged; auth (57) + ws/benchmark/startup (79) suites pass; alembic heads single v2_155; helm lint/template OK and --set secrets.mcpPassword=changeme fails the render; docker compose config OK on all modes; extract-breaking-changes and compute_version_bump self-tests pass; lint-commit-markers clean. BREAKING CHANGE: MCP_SERVICE_PASSWORD is now required — the backend SystemExits under ENVIRONMENT=staging|production when it is unset or a known default; the shipped admin/changeme default is removed and rotated out on upgrade; the dist bundle renames MCP_USERNAME/MCP_PASSWORD to MCP_SERVICE_USERNAME/MCP_SERVICE_PASSWORD; and the Helm chart ships mcpUsername=mcp with a generated mcpPassword instead of admin/changeme. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193): close bonnyr-f5's credential/backend/helm/dist/docs blockers Follow-up to the #177 integration on pr177-integration, addressing the CREDENTIAL/BACKEND/HELM/DIST/DOCS half of bonnyr-f5's BLOCK on PR #193. B1 (SECURITY): ensure_service_user no longer adopts any human account whose password is a known default. The adoption exception is now scoped to v2_155's exact backfill fingerprint (username=='mcp' AND email=='mcp@bnk-forge.local'), matching the migration's own conservative rule, and must_change_password is no longer cleared on an adopted row. Adds tests proving a human operator/changeme row (and a wrong-email mcp row) is REFUSED, not taken over. B2/B2b: all five compose files (root + dist docker-compose{,.local}.yml and the IBM embedded compose) honor legacy MCP_USERNAME/MCP_PASSWORD as aliases for MCP_SERVICE_USERNAME/MCP_SERVICE_PASSWORD on both backend and mcp env, so an existing customer .env keeps working after upgrade. Docs (dist/README.md, dist/.env.example, user-pack/install-guide.html) document MCP_SERVICE_PASSWORD as canonical with MCP_PASSWORD honored as a legacy alias. B3: ENVIRONMENT is plumbed to the backend in every compose file, so an operator who sets ENVIRONMENT=staging|production actually reaches config.py's MCP fail-fast. Helm already routes ENVIRONMENT=production onto api/worker/beat. M1: the unset-MCP behavior stays "disabled" (#188 over #186); added an explicit deliberate-consolidation comment at the decision point. M2: disable_stale_service_user skips the about-to-be-reconciled row and the "no usable MCP_SERVICE_PASSWORD" warning is conditional on a configured password, so a correctly-configured install no longer logs a false warning or commits an inactive MCP window on every boot. M7: the Helm mcp deployment and the IBM installer's mcp service now run the exec auth-probe healthcheck (python -m bnk_forge_mcp.healthcheck) instead of a bare tcpSocket probe. M8: the chart fails the render for a reserved mcpUsername (admin), mirroring the mcpPassword guard, and NOTES.txt/values.yaml call it out. Minors: deterministic checksum/secret via a shared helper (stable across renders, identical across api/worker/beat/mcp); vestigial _persist_generated_password filename docstring; false "backend generates its own secret" rationale corrected in compose/helpers/ibm; mcp_live_smoke.py #186/#188 attribution; e2e/config.py changeme default note; .env.example :58/:73/:94 fixes; unified BNK_FORGE_VERSION to latest across dist. Validation: ruff clean; typecheck-backend (core/ schemas/) Success 38 files; 199 auth/credential/startup/ws/migration tests pass incl. new B1 tests; helm lint + template stable checksums, --set secrets.mcpUsername=admin and secrets.mcpPassword=changeme both FAIL; docker compose config on all five modes shows the backend receiving MCP_SERVICE_PASSWORD (via either alias) and ENVIRONMENT. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193): close bonnyr-f5 CI/RELEASE/SCRIPTS blockers, majors, and minors Blockers: - B4 registry-tag-probe.sh: replace GNU-only BRE alternation (\|) with portable `sed -nE (access_token|token)` so the token parse works on BSD/ macOS sed; on BSD the empty token classified every image `unknown` and routed the operator into FORCE_LATEST=1, overwriting immutable :VERSION manifests (INV-24). Reproduced under `sed --posix`, fix proven to parse T2. - B5 registry-tag-probe.test.sh had no caller and was red on BSD. Both the Makefile script-selftests target and ci.yml's script-selftests job now enumerate and run every scripts/tests/*.test.sh, failing on an empty enumeration or any non-zero rc. - B6 lint-commit-markers.sh: replace the spoofable committer-identity exemption (GitHub <noreply@github.com> + single parent) with an unspoofable "already reachable from origin/main|origin/staging" check; lint the PR title (PR_TITLE via env) on pull_request events; split the rules so machine/already-merged is exempt for the marker rule but the spurious-major rule always applies. Majors: - M3 release.yml overwrite guard: derive the vacuity floor from an independent source (docker-bake.hcl default group, sourced from the workflow-ref tooling) and assert the probe's exit status before trusting its output, so an unavailable probe fails closed instead of "safe". - M4 (INV-31): generate release notes and run the registry existence-probe BEFORE the irreversible push in release-final/release-manual (new shared scripts/registry-overwrite-guard.sh); release-publish keeps its own in-critical-section re-check. - M5 make script-selftests now runs the INV-15 detector-parity diff (extracted to scripts/tests/detector-parity.test.sh) so local == CI. - M6 extractor self-test runs unconditionally with anti-vacuity assertions (ok lines + END marker), no longer gated on grepping its own --self-test. Minors: stale cross-PR comments in release.yml and extract-breaking-changes.sh; removed the duplicate Makefile version-check target; `git add dist/VERSION` no longer swallows failures; first-ever-release notes range fixed; CHANGELOG insertion asserts a non-no-op before committing; refreshed .trivyignore CVE-2026-7598 review deadline; removed e2e-tests.yml dead `|| true`; documented the new Docker dependency in the pre-push hook. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r2): close credential/backend/helm/dist blockers — drop the username alias, make ENVIRONMENT=production satisfiable, and fix the mcp liveness probe bonnyr-f5 round-2 BLOCK, credential/backend/helm/dist/docs half. B-1 (INV-12): the compose files aliased the SERVICE username (MCP_SERVICE_USERNAME:-${MCP_USERNAME:-mcp}); a legacy .env with MCP_USERNAME=admin resolved it to `admin`, and against the guardless image `latest` still points at, the old ensure_service_user rewrites the human admin row to `changeme` every boot. Drop the username alias across all five compose files + the ibm embedded compose (keep the harmless password alias), and default BNK_FORGE_VERSION to 4.0.0 (the release this tree becomes, first image with the guards) instead of `latest`, so a compose file can never hand the new credential contract to a pre-guard image. B-2: ENVIRONMENT=production reaches validate_production, which also gates on JWT_SECRET_KEY / ENCRYPTION_KEY / ALLOWED_ORIGINS — none of which were deliverable from a compose install, so the switch bricked the backend. Plumb all three into every x-backend-env anchor (four compose files + ibm) and document them in the env examples; treat an empty ("" from ${VAR:-}) key as unset in config.py so the plumbed empty default auto-generates rather than passing as a real empty key. _persist_or_load_key now flags only keys WE generated as auto_generated (sidecar .autogen marker), so an operator-provisioned key on the volume validates while a fresh prod boot still fail-fasts permanently. M-4: mcp liveness returned non-zero when the BACKEND was unreachable, so k8s restarted the pod for a dependency outage. Move the auth-probe to readiness only; liveness is tcpSocket. Fix mcp-server/README + mcp_live_smoke hints to name only the vars each process actually reads (container: BNK_FORGE_*, backend: MCP_SERVICE_*). Minors: refuse a known-default DEFAULT_ADMIN_PASSWORD on fresh seed + helm adminPassword fail-guard; guard secrets.yaml mcpUsername nil with kindIs "invalid"; make the Python reserved-name check case-insensitive/trim to match Helm; neutralise the hash when disabling a stale service account; correct the benchmarks.py JWT-gate comment; surface an empty MCP_SERVICE_PASSWORD in install.sh; fix the .env.example "No .env file is needed!" contradiction. Tests: config B-2 satisfiability + provenance-marker tests; seed_auth_step against an admin-still-holds-changeme upgrade DB; case-insensitive reserved-name and disable-hash-neutralisation cases. ruff clean, mypy clean, 4831 unit pass, helm lint/template green, docker compose config verified on all modes. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193): close r2 CI/RELEASE blockers B-3, M-1..M-3 + scripts/release minors B-3 (commit-lint exemptions): key the already-merged exemption on the range BASE (github.event.before), not the post-push tip, so a new skip-CI marker on a push to main/staging is caught while a genuinely-already-merged base commit stays exempt; replace the self-settable `^release: ` subject exemption with release.yml's own version+trailing-skip fingerprint. M-1 (spurious-major rule): redefine rule 2 as the exact complement of the detectors, sourced from the shared predicate, so it flags only a marker the detectors would MISS (never dash-bullet, markdown-bold or indented shapes); give it the same already-merged exemption; and lint inputs.release_notes through the script before it becomes a release commit/tag. M-2 (overwrite guard floor): derive the vacuity floor from `docker buildx bake --print default | jq '.group.default.targets | length'`, scoped to the default group, so a second bake group no longer wedges the release; separate bake-file parse failures from registry-unreachable in the messaging. Single-source the policy: release-publish and make push-images now call the one guard. M-3 (portability): drop bash-4 mapfile from the probe test; rebuild the compute self-test newline expansion with awk to avoid the bash-3.2 parameter-expansion cliff, so make script-selftests runs under stock macOS bash 3.2. Detector single-sourced into scripts/lib/breaking-change-detect.sh (compute, extract, lint all source it); detector-parity test asserts the wiring; added mutation tests for the lint rules and the overwrite guard. Minors: fix version-consistency misdiagnosis of a column-0 YAML comment; correct the compute/extract parity docstrings and the docker-bake four-push-paths note; wire artifact-network-self-test into ci-gates; make the pre-push hook migration message reachable under set -e; omit the false provenance buildStartedOn; filter the release CI-status poll by commit SHA. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193): seed the re-enable-guard test's default-hash row directly The round-2 disable_stale_service_user hash-scrub (bonnyr-f5 #193 minor) collided with the re-enable guard's own regression test: _seed_disabled_default_mcp built its "disabled while holding the published default" state BY CALLING disable_stale, which now scrubs the hash -- so holds_known_default_password was false and the PUT re-enable was allowed (200) instead of refused (400). The guard defends a row taken inactive by a path that LEAVES the credential intact (a manual operator PUT), not one disable_stale scrubbed. Seed that state directly (set is_active=False on the default-hash row) so the guard's real scenario is exercised; assert the default hash survives the seed. Corrected the now-stale guard comment in routes/auth.py that still claimed disable "only flips is_active". Neutralisation and its asserting tests are unchanged. Verified: TestServiceAccountReEnableGuard 2/2 pass; the three affected auth files (test_startup_seed_auth, component/test_auth_service, integration/test_routes_auth) 97/97 pass; ruff clean. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r3): fail-close key provenance (B-2) + credential/auth minors Own the round-3 CREDENTIAL/AUTH findings. B-2 (BLOCKER): _persist_or_load_key classified a marker-less key file as operator-provided, so every upgrade keys volume (key present, no marker) let SEC-006's fail-fast pass OPEN on an auto-generated JWT/ENCRYPTION secret in production. Invert the sentinel: a marker-less key now classifies AUTO-GENERATED (fail closed); an operator asserts provenance with an explicit <filename>.operator opt-out marker. No marker is written on generation, which also removes the second trigger (a partial marker write can no longer downgrade provenance). Regression tests seed the PREVIOUS-RELEASE on-disk shape and assert validate_production raises under ENVIRONMENT=production. Minors: - Write the key via os.open(0o600)+fchmod so the secret is never briefly 0644. - Single-source the MCP known-default denylist: delete the local tuple in auth_service and use core.config.MCP_KNOWN_DEFAULT_PASSWORDS (comment notes the helm copy is deploy-owned). - Correct holds_known_default_password docstring (disable_stale now scrubs the hash; this guard covers the other disable paths). - Reconcile ENCRYPTION_KEY docs with reality: the keys-file is the source of truth for at-rest crypto; the env var only drives the production gate (encryption.py comment + .env.example). - Clarify the v2_155 custom-username remedy in disable_stale docstring. Test-gaps: - Normalise the service username (trim/casefold) at the reconcile lookup and the disable skip filter, so " mcp "/"MCP" reconciles the existing mcp row instead of minting a second service account and disabling the live one. - Honest seed_admin_user log/logic under DEFAULT_ADMIN_MUST_CHANGE=false (no more "must change on first login" when no gate was applied). - disable_stale_service_user(skip_username=...) leaves the live row wholly untouched (no inactive window), variant included. - db.commit() failure after the keys file is written leaves a retriable state (published default still authenticates, orphan file password does not). All owned-suite tests pass; ruff clean. Each fix reproduced then mutation-tested. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r3): close the release/CI blocker + major + every release/CI minor M-6 (blocker): commit-lint no longer reds unamendable merge history. - rule 2 now flags ONLY a mis-anchored DECLARATIVE marker (the colon form); a colonless marker-shaped PROSE line the detectors treat as inert (an already-merged body such as "- <MARKER> footer in the body ...") is no longer flagged, so the push-to-main range (before..head, which INCLUDES the PR merge-base) goes green without a history rewrite. Detection of a real mis-anchored marker is unchanged. - deleted the already-merged exemption as dead code: base..head excludes the base by construction, so no scanned commit can ever be an ancestor of it. Removed the BEFORE derivation, _already_merged, tests B3.2/M1.5, and the ~20-line header claim. The release-bot exemption stays. - rule 2 now scans the whole body via _under_detected_markers and reports EVERY mis-anchored marker, not just the first. M-7 (major): secret-scan no longer false-fails a delete-only range. A delete-only commit has rev-list count > 0 but gitleaks scans 0 (it scans added content), so the count-based backstop is replaced by a range- resolvability check plus gitleaks' exit status. Release/CI minors: - release-bot fingerprint single-sourced to scripts/lib/is-release-bot-subject.sh; release.yml's inline copy byte-locked by a parity self-test; dropped the false unforgeability claim and documented the residual honestly. - registry-overwrite-guard: added a fail-closed default arm for an unrecognised/empty probe status (+ malformed/empty test scenarios). - Makefile push-images: FORCE_LATEST now overrides ONLY the recency guard; a new FORCE_OVERWRITE overrides ONLY the immutable-tag guard; fixed the missing-jq remediation text. - registry-tag-probe: the network arm now matches the real doubled "000000" curl-failure shape (was dead code); test fixture reproduces it. - INV-15: single-sourced the marker regex (one canonical value + a detector-parity assertion that every embedded copy is byte-identical). - release.yml Publish summary counts what buildx actually pushed (bake --metadata-file), not the static target list. - registry-tag-probe test enumerates the bake DEFAULT group (scoped), matching the guard's enumeration. - added scripts/tests/secret-scan.test.sh (fake-docker mutation suite). release.yml: added a post-push step running scripts/verify-image-pins.sh so a release cannot complete while shipping an unpublished image pin (script owned by the deploy agent; referenced by path from .release-tooling). Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r3): single-source every deploy version pin + close deploy majors/minors B-1/B-1b: dist/docker-compose{,.local}.yml, dist/.env.example and ibm_cloud_bnk_forge.sh hard-pinned 4.0.0, a tag that has never been published, while Helm pinned 3.1.6 -- two shipped paths naming two versions, one of which does not exist. Bring all of them under sync-version-artifacts.sh (new PIN/ DISTENV readers+writers, --check, --list) so every pin derives from VERSION (3.1.6, which exists) and the release re-stamps them atomically via the existing --write $NEW; drop the dist/ disclaimer. Add scripts/verify-image-pins.sh (+ selftest) that resolves every shipped compose image: pin against the registry and fails on manifest unknown, wired post-push in the release job. M-1..M-5: reword NOTES/compose/chart comments that asserted post-guard behaviour as already-true on the pre-guard pinned image (they land with the guard-carrying release); NOTES now leads with the required ALLOWED_ORIGINS override; dist/README and the install guide stop recommending latest/3.1.6 and the keys-file cat the pinned image does not write; install.sh strips quotes and rejects the known- default MCP passwords so the "MCP not active" warning fires instead of a green lie; add deploy-version-lockstep + helm-known-defaults-lockstep selftests. Deploy minors: MCP_USERNAME "do not set" made consistent across docs/Makefile; chart ENCRYPTION_KEY now emits a valid Fernet key; DEFAULT_ADMIN_* added to the ibm P3 backend env; secrets.mcpUsername defaults to "mcp" on null; ibm mapfile -> portable while-read. Verified: sync --check exit 0; --write round-trip moves every pin and restores; helm lint/template clean (default + origin override); script selftests green; bash -n + shellcheck clean. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r4): unify the at-rest encryption key (B-3), fail-close key marker (M-1), row-matches-client (M-2) + credential minors B-3: validate_production gated ENCRYPTION_KEY while a second, independent generator in core/encryption.py produced the real at-rest Fernet key unchecked — setting ENCRYPTION_KEY (the documented remedy: token_hex(16), not even a Fernet key) turned the gate green while encryption auto-generated a different key. Unify: one key file (_encryption_key_path == core.encryption.ENCRYPTION_KEY_FILE), one generator. When ENCRYPTION_KEY is set it is VALIDATED as a real Fernet key (fail clearly if not), written to that file with a .operator marker, and consumed by core.encryption and services.backup_service; the provenance flag reflects the value that actually protects data. Never clobber an operator-marked key on a mismatch. config.py:319 and .env.example now print the Fernet recipe. M-1: _persist_or_load_key required a regular-FILE marker (os.path.isfile, not os.path.exists — a directory no longer counts) and treats "marker present, key file absent" as a provisioning error: generate but do NOT persist, so the stale-marker rotation gesture can never heal into auto=False on the next boot. M-2 (regression this PR introduced): ensure_service_user normalised the username before lookup/create, so MCP_SERVICE_USERNAME=MCP seeded 'mcp' while the client sends the raw 'MCP' and authenticate_user matched exactly -> login denied. Create/ reconcile under the RAW value (what the client sends); the disable_stale skip keys on the same raw value; only the reserved-name guard normalises. Fixed the false "Matches the Helm chart lower|trim" docstring. Credential minors: non-vacuous localhost-CORS test (valid MCP password so only the CORS branch fails) + wildcard is now an exact origin-list entry, not a substring; new DPU-websocket must-change/unresolvable-user tests mirroring the k8s twin; middleware unresolvable-JWT-subject-refused and exact-vs-suffix exempt-path tests; corrected the denylist copy count (4th copy in dist/install.sh); corrected v2_155's rationale (v2_154 is new in this diff, not "already shipped"); documented why ensure_service_user's adoption branch is kept. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r4): close deploy-surface blocker + majors (B1, M7-M12) and deploy minors B-1: a fresh install of the pinned 3.1.6 bundle seeded an admin nobody could log in as. `${DEFAULT_ADMIN_PASSWORD:-}` delivers the var present-and-empty; 3.1.6's `DEFAULT_ADMIN_PASSWORD: str = "changeme"` is then overridden by "" and the login schema rejects "" (422). The prescribed `${VAR}` form does NOT omit on this compose (map interpolation still renders ""); the working omit-when-unset form is a map entry with NO value (passthrough / `docker run -e KEY` semantics). Converted DEFAULT_ADMIN_PASSWORD to passthrough across all four compose paths (dist base+local, root base+local, IBM embedded). Swept the class: JWT_SECRET_KEY/ENCRYPTION_KEY also converted (3.1.6 uses `if KEY is None`, so "" is used literally, not auto-generated); MCP_SERVICE_PASSWORD kept as `${...:-...}` because omitting it restores 3.1.6's known default "mcp-service-changeme". Added a commented DEFAULT_ADMIN_PASSWORD block to dist/.env.example. Verified via `docker compose config` + real container env both directions (unset -> omitted; set in .env -> forwarded). M-7: chart checksum/secret did not change on mcp-password rotation (3 renders, 3 generated passwords, one identical checksum). Made all generate/rotate fallbacks deterministic (deriveSecret, release-seeded) so the Secret is stable across renders and includes, and hash the RENDERED Secret so the annotation tracks every resolved value. Now stable across renders, identical across the 4 deployments, and it flips when any resolved value changes. M-8: dist/install.sh credential guard failed open on `changeme ` (whitespace). Trim leading/trailing whitespace around the quote-strip before the known-default compare. M-9: removed newly-added forward-dated 4.0.0 prose (install-guide.html x2, DOCKER.md). M-10: default helm install crashlooped (production + localhost). Added a render-time guard mirroring backend validate_production (fail on wildcard under staging/production, localhost under production); defaulted ALLOWED_ORIGINS to empty so the bare render boots (empty is neither wildcard nor localhost). `helm lint` and bare `helm template` stay green; the guard fires with a clear message on a real fatal posture. M-11: portable in-place sed in the IBM installer (`sed -i.bak … && rm`), both sites. M-12: dist/ no longer ships published default DB/redis creds on host networking. install.sh generates strong POSTGRES_PASSWORD/REDIS_PASSWORD on the fresh .env (like Helm/IBM); .env.example ships them empty; a pre-existing default triggers a warning. Deploy minors: extended deploy-version-lockstep.test.sh to the bnk-operator chart (appVersion + image.tag) and dist/VERSION; brought dist/VERSION under sync-version-artifacts.sh (--check/--list/--write green); reworded install.sh's MCP UNHEALTHY assertion to match what the pinned image actually reports; added scripts/tests/ibm-compose-drift.test.sh freezing the credential/hardening env so the IBM embedded compose and dist/docker-compose.yml cannot silently diverge. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r4): make the pin verifier reachable pre-push, de-vacuum the parity/self-test harnesses, and close the release minors B-2 (blocker): scripts/verify-image-pins.sh could never pass where the release job runs it — from the 4-file sparse .release-tooling checkout that holds no compose file (ROOT resolved there), with REGISTRY/VERSION handed in as env vars the script reads only as flags, and the whole step wired AFTER the tag/Release/push/signing. Fixes, end to end: - add a consistency mode (--expect-version) that asserts every shipped first-party pin already renders to $NEW without a registry probe, and run it as the PRIMARY PRE-push gate in release-final and release-manual (before anything irreversible); - fix the post-push existence step to pass REGISTRY/VERSION as FLAGS and the compose files explicitly by --file (they live at the tag checkout at the workspace root), keeping it as a secondary confirmation; - widen the default file set to include the IBM Cloud installer's embedded compose; - add a dryrun-release-tooling job that rebuilds the exact publish-job layout and exercises both invocations against a fake probe, and gate release-publish on it, so a step that cannot execute is caught before it is wired ahead of a signature. The sibling registry-tag-probe.sh / registry-overwrite-guard.sh read nothing $ROOT-relative outside the sparse set, so they are unaffected. M-3: detector-parity.test.sh enumerated the marker copies with the very token that drifts, so a copy that drifted in the token vanished from enumeration (drifting :96-97 dropped the count 5->3 yet stayed green). Enumerate by position/count instead: an exact per-file canonical count plus a stable-anchor site scan that flags any drifted site even under a compensating add. M-4: the filesystem self-test loop checked only a non-empty enumeration and each file's exit 0, so a test gutted to a no-op passed and deleting 7 of 8 stayed green. It now requires each file to emit PASS lines, no FAIL line, and an ALL PASS terminal marker, plus a count floor derived from git's tracked *.test.sh set (detector-parity was conformed to that output convention). M-5: release-rc created and pushed the RC tag before the fail-closed notes step; the tag is now created locally, notes generated, then the tag pushed. M-6: added mutation-tested coverage for this PR's four previously-uncovered lint fixes (the PR-title lint, the pending-message lint, the RANGE fail-closed branch, and the skip-checks trailer rule). LEAD: the anti-vacuity staging floor derived the count from a stale literal while --list grew to 8 paths; both sites now derive it from --list and require every listed path to stage, and the stale comments are corrected. Release minors: scope the release-bot commit-lint exemption to the range tip (a forged release subject buried mid-range is no longer exempt) and add a REACHABLE published-history exemption anchored to the last release tag so a mis-anchored marker in unamendable history cannot red the release; add fixtures for the untested registry probe/guard arms (5xx, unexpected code, unknown status, bake-parse failure); ancestry-filter the LAST_FINAL tag queries so a tag on another branch cannot skew the notes range; reconcile the empty-RANGE handling (commit-lint now fails closed on an explicit empty RANGE, ci.yml leaves it unset); give the pre-push hook a clear message and a fetch fallback when the remote tip is absent locally; derive the cosign verify-identity org from REGISTRY instead of hardcoding it. Flagged: gate Makefile push-customer-build through registry-overwrite-guard.sh, the last documented push path that was still unguarded. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r4): keep M-7 checksum-tracks-rotation WITHOUT predictable secrets The r4 deploy fix closed M-7 (checksum did not move on a secret rotation, so pods never rolled) by making the generated fallbacks deterministic -- deriveSecret = sha256(Release.Name|Namespace|fullname|purpose). Every input is public (they appear in resource labels and the chart source), so that made the JWT signing key, the at-rest Fernet key and the admin/mcp passwords COMPUTABLE by anyone who can read a label -- a forge-any-token / decrypt-all-secrets exposure, strictly worse than the cosmetic churn it fixed. Revert generation to randAlphaNum (unpredictable) and instead hash the DETERMINISTIC inputs that determine the Secret -- values.secrets, the persisted .data (reused via lookup), plus a per-credential "rotating-from-default" marker for admin/mcp whose persisted value is a known published default. That tracks every rotation (operator edit, persisted-value change, rotate-away-from-default) so the pods roll, is stable across renders including a bare no-cluster `helm template` (the hashed inputs carry no randomness), and never derives a secret from public identity. deriveSecret removed. New scripts/tests/helm-secret-checksum.test.sh locks all three: stable-across-renders, changes-on-rotation, and generated-value-is-random -- so the determinism cannot return. Verified: helm lint 0-failed; bare + override template OK; the M-10 render guard still fires on production+localhost; the new selftest ALL PASS. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r4): self-review — close the encryption-key data-loss BLOCKER + deploy minors A cold adversarial self-review (three auditors mirroring the reviewer's method) of the r4 changeset found a data-loss BLOCKER we introduced this round, plus deploy minors. Fixing before it ships. B-3 (BLOCKER, data loss): the r4 encryption-key unification made ENCRYPTION_KEY env OVERWRITE an existing at-rest key file on boot. Traced only to the "operator freshly sets the key" consumer, never to (a) backup_service restore, which writes the backup's key to that file, or (b) the r3->r4 upgrade population, whose data was encrypted under a marker-less auto-gen FILE key (r3 core.encryption used the file regardless of env). The first r4 boot clobbered those -> restored/existing data undecryptable (or bricked the boot on a marker mismatch). A new test even LOCKED the clobber with a false premise. Fix: the at-rest key FILE is the single source of truth. ENCRYPTION_KEY only SEEDS the file when it is ABSENT and never overwrites an existing one; the gate reads the FILE's .operator provenance. backup restore now drops the .operator marker so a restored key passes the gate without a clobber. Rewrote the clobber-locking tests to lock the no-clobber invariant; added upgrade-shape, production-fail-without-data-loss, and restore-marker tests. M-7 (deploy self-review): removed the rotation-marker from secretsChecksum — the auditor proved it redundant (the same .data change already moves the digest; deleting it left the test green) and its admin branch dead. Kept the input-hash; documented the genuine trilemma (cluster-less-template-stable / tracks-generated-rotation / unpredictable-secrets — pick two; determinism is the predictable-secret hole). M-10: the render guard's wildcard check is now an exact comma-split entry, matching the backend's `"*" in cors_origins` since r4, so a legitimate `https://*.example.com` is no longer blocked; the localhost check stays a substring to match the backend. .env.example: the admin-password template was an empty assignment that uncomments into a lockout; it now carries a replace-me placeholder. Verified: backend 8082 passed; config/encryption 66, backup 13; script-selftests all pass; helm lint/template clean (subdomain-wildcard passes, bare '*'/prod+localhost fail); ruff clean. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 * fix(#193 r5): fail closed instead of regenerating over an existing at-rest key (I-1) bonnyr-f5 #193 round-5 closure blocker. B-3 wrote down the invariant "the at-rest key file is the single source of truth; nothing overwrites it once it holds bytes" and config.py honoured it -- but core.encryption.get_encryption_key() did not. A file present but under 32 bytes (truncated / partial write / disk full / bad restore) logged "Invalid key, regenerating" and OVERWROTE it with a fresh key, permanently destroying the key any existing data was encrypted under -- silently, on a GREEN production boot, because the intact .operator marker keeps validate_production passing. Fix: the read path now fails CLOSED. A genuinely absent (or 0-byte) file still generates and persists a new key. A file that HOLDS bytes is validated as a real Fernet key: valid -> returned untouched; unusable -> SystemExit with a clear message, never regenerated. A crashloop is recoverable; an overwritten key is not. This also closes r5 note #3 -- the old `len >= 32` check accepted any blob and surfaced a mis-shaped key as a later cipher error; it now Fernet-validates and says so plainly. Locked by TestAtRestKeyFileNeverRegeneratedOverBytes: a 30-byte truncated key -> SystemExit AND the original bytes survive on disk (recoverable); a valid key -> returned untouched; an absent file -> generates a valid key. Verified: backend 8086 passed; encryption unit tests 19 passed; ruff clean. Claude-Session: https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4 --------- Co-authored-by: John Gruber <john.t.gruber@gmail.com>
Fixes #187 — follow-up to #184 for the same class of shipped default.
The problem (worse than the issue described)
The seeded
mcpservice account isrole=adminand shippedMCP_SERVICE_PASSWORD = "mcp-service-changeme"— a live admin credential with no rotation gate. And the Helm chart hadmcpUsername: admin, so the MCP server logged in as the human admin, not the service account — it only worked because the admin default was alsochangeme. #184 breaks that outright (the admin password is generated now, and must-change would block it), so this PR also un-breaks MCP on Helm.The fix
MCP_SERVICE_PASSWORDdefaults toNone— no shipped value. It's a shared secret (backend seeds the account; MCP server authenticates with it), so it can't be auto-generated:validate_productionfails fast in staging/prod when it's unset or the known default, mirroringJWT_SECRET_KEY/ENCRYPTION_KEY.startup_stepsseeds themcpaccount only ifMCP_SERVICE_PASSWORDis set; unset → not seeded (MCP unavailable until configured), never a default.mcpUsername: admin → mcp,mcp-passwordgenerated (reused across upgrades), and_helpers.tplinjectsMCP_SERVICE_USERNAME/PASSWORDinto the backend from the same secret the MCP server reads asBNK_FORGE_USERNAME/PASSWORD. Both resolve tomcp/ generated; themcpaccount ismust_change_password=Falseso Default admin credential (admin/changeme) is live and API-reachable on every fresh deployment #184's gate doesn't block it.:-mcp-service-changemefallback; unset → empty → the MCP server fails clearly and the backend skips seeding.Testing
Production/staging validation fails when
MCP_SERVICE_PASSWORDis unset or the known default, passes when set;ensure_service_usertests already use explicit passwords.helm lintclean,ruffclean,helm templateshows backend + MCP server pointing at the same secret keys.Overlap
Touches
helm/…/secrets.yaml,values.yaml,_helpers.tpl— the same generated-secret block as #180 and #184. Merge-time rebase, as already flagged on those.Fixes #187
https://claude.ai/code/session_01UpRYiFserdBE5ESHn759N4