Skip to content

fix(config+sec): align TRINITY_PASSWORD across compose files + close changeme propagation paths (#692) - #718

Closed
AndriiPasternak31 wants to merge 4 commits into
Abilityai:devfrom
AndriiPasternak31:AndriiPasternak31/claim-692
Closed

AndriiPasternak31 wants to merge 4 commits into
Abilityai:devfrom
AndriiPasternak31:AndriiPasternak31/claim-692

Conversation

@AndriiPasternak31

Copy link
Copy Markdown
Contributor

Summary

Closes #692. The validator flagged 5 config issues; this PR fixes those + 2 more sibling-bugs surfaced by adversarial review on the diff itself.

What started as a 5-line config-validation PR walked the full review gauntlet (autoplan dual-voice, /review with codex+subagent, /cso --diff). Each pass caught real issues that grew the diff into a more complete fix. Final scope is still small (10 files / 80 inserts / 15 deletes) and all changes are in the same blast radius — the changeme / ADMIN_PASSWORD / TRINITY_PASSWORD enforcement triangle.

What changed

Config alignment (originally-flagged validator findings):

  • docker-compose.yml: TRINITY_PASSWORD now reads ADMIN_PASSWORD directly so devs don't set the same secret twice.
  • docker-compose.prod.yml: both ADMIN_PASSWORD (line 24) and TRINITY_PASSWORD (line 287) switch from silent fallback to fail-loud ${VAR:?...}. Matches the convention already used by Redis password vars on lines 26 and 135.
  • .env.example: collapse duplicate FRONTEND_URL block; add missing entries for GOOGLE_API_KEY, LOG_RETENTION_DAYS / LOG_ARCHIVE_ENABLED / LOG_CLEANUP_HOUR, TRINITY_DATA_PATH, and HOST_TEMPLATES_PATH.

MCP server hardening (added during review):

  • src/mcp-server/src/server.ts:85: drop the || "changeme" fallback. Add a startup guard that throws when MCP_REQUIRE_API_KEY=false, no TRINITY_API_TOKEN, AND no TRINITY_PASSWORD. Closes the only path where the well-known password could ever reach client.authenticate(). Default-mode (MCP_REQUIRE_API_KEY=true, the shipped configuration) is unaffected.

Deploy script + config template (caught by adversarial review):

  • scripts/deploy/gcp-deploy.sh:135: previously baked ADMIN_PASSWORD=${ADMIN_PASSWORD:-changeme} into the prod .env, which would have defeated the new compose :? guard at the source. Now refuses to deploy if the var is unset or literally "changeme".
  • deploy.config.example:48: drop the ADMIN_PASSWORD="changeme" template default. Empty default + REQUIRED comment matches the .env.example pattern.

Doc sync:

  • docs/memory/feature-flows/mcp-orchestration.md: update stale code snippet that quoted the now-removed || "changeme" line; add note about the new throw guard.
  • docs/user-docs/guides/deploying/single-server.md: note that ADMIN_PASSWORD now drives both admin login and MCP auth, and that prod compose refuses to render without it.
  • src/mcp-server/TEST_REPORT.md: flag the frozen 2025-11 Default Credentials: admin / changeme entry as HISTORICAL pre-Config Validation: 5 critical config issues found (TRINITY_PASSWORD P0, 4x undocumented vars) #692.
  • docs/memory/feature-flows.md: add one-row Recent Updates entry.

Behavior delta

  • Default config (MCP_REQUIRE_API_KEY=true, the shipped value): zero behavior change.
  • Prod deploys without ADMIN_PASSWORD set: previously rendered with changeme and a wide-open admin login. Now docker compose -f docker-compose.prod.yml config exits non-zero with the message ADMIN_PASSWORD must be set in .env (admin login + MCP auth). Verified empirically — fails on both unset and explicitly-empty values.
  • Legacy MCP auth path (MCP_REQUIRE_API_KEY=false) without creds: previously authenticated as admin/changeme. Now throws on container startup with a message that names all three preconditions. Container exits before serving any request.
  • GCP operators using gcp-deploy.sh without setting ADMIN_PASSWORD in deploy.config: previously got a working prod stack with the changeme password live on the admin login. Now the script exits non-zero before writing the remote .env.

Verification

  • tsc --noEmit clean on src/mcp-server (new string | undefined narrows correctly to string after the throw)
  • Prod compose :? guard fires on unset (env -i ... --env-file /dev/null) AND explicitly-empty (ADMIN_PASSWORD="")
  • Prod compose with ADMIN_PASSWORD=test renders both ADMIN_PASSWORD and TRINITY_PASSWORD to test; no changeme literal anywhere
  • .env.example lint: FRONTEND_URL count = 1; all 6 new vars present
  • Repo-wide grep: remaining changeme literals are guards (gcp-deploy.sh, password_validation.py blocklist) or HISTORICAL-flagged docs
  • /review found 3 critical findings outside the original diff (gcp-deploy.sh, deploy.config.example, doc drift); all addressed in commit 3
  • /cso --diff: 0 findings at 8/10 daily-mode gate; verdict IMPROVEMENT (verified by independent subagent)

Test plan

  • Cold-start prod stack with a real ADMIN_PASSWORD — verify admin login works and MCP server boots clean
  • Try cold-start prod stack without .env — verify docker compose config exits with the new error message
  • Run gcp-deploy.sh env against a test instance with ADMIN_PASSWORD="" — verify script refuses
  • Re-run /validate-config — verify 0 findings from the original list

Out of scope (deliberately deferred)

  • Adding FRONTEND_PORT, VITE_API_URL, SCHEDULER_LOG_LEVEL, MCP_REQUIRE_API_KEY, TRINITY_USERNAME to .env.example (have sensible defaults; mostly debug knobs)
  • .env.example advertises SMTP/SendGrid vars that compose doesn't forward (separate cleanup)
  • SLACK_CLIENT_ID/SECRET, GITHUB_CLIENT_ID/SECRET, NOTION_CLIENT_ID/SECRET parity between local and prod compose

Commits

16960765 docs(feature-flows): add #692 Recent Updates entry
74786a82 fix(deploy+docs): close changeme propagation paths surfaced by /review (#692)
4cb8b75f fix(mcp): refuse to start MCP server on missing backend credential (#692)
4bdcf9ab fix(config): align TRINITY_PASSWORD across compose files + .env.example drift (#692)

Closes #692

🤖 Generated with Claude Code

AndriiPasternak31 and others added 4 commits May 8, 2026 00:56
…le drift (Abilityai#692)

- docker-compose.yml: TRINITY_PASSWORD now reads ADMIN_PASSWORD directly so
  devs do not have to set the same secret twice.
- docker-compose.prod.yml: replace silent ${ADMIN_PASSWORD:-changeme} with
  fail-loud ${ADMIN_PASSWORD:?...} on both backend and mcp-server. Matches
  the convention already used by the Redis password vars.
- .env.example: collapse duplicate FRONTEND_URL block; add missing entries
  for GOOGLE_API_KEY, LOG_RETENTION_DAYS / LOG_ARCHIVE_ENABLED / LOG_CLEANUP_HOUR,
  TRINITY_DATA_PATH, and HOST_TEMPLATES_PATH (the last caught by autoplan
  dual-voice review — same pattern as TRINITY_DATA_PATH).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…bilityai#692)

Drop the silent ` || "changeme"` fallback in trinityPassword resolution and
add a guard that throws when MCP_REQUIRE_API_KEY=false, no token, and no
TRINITY_PASSWORD/ADMIN_PASSWORD are set. Closes the only path through which
the well-known "changeme" literal could ever reach client.authenticate().

Default-mode (MCP_REQUIRE_API_KEY=true, the shipped configuration) is
unaffected — that branch never references trinityPassword.

Audit-trail rationale: autoplan dual-voice review (Codex + Claude subagent)
both flagged the original plan's choice to leave server.ts:85 alone as
"defensible only as a narrow config-only scope trim." User confirmed this
was small enough to land in the same PR rather than file a follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Abilityai#692)

Adversarial review on the Abilityai#692 diff caught two siblings of the same bug
the issue was filed to fix: the GCP deploy script and its config template
still bake "changeme" into prod .env files, defeating the new prod compose
:? guard at the source.

- scripts/deploy/gcp-deploy.sh: refuse to write the prod .env if
  ADMIN_PASSWORD is unset or literally "changeme". Fail-loud at script
  time instead of silently shipping a known password.
- deploy.config.example: drop the "changeme" default; add REQUIRED
  comment matching the .env.example pattern.
- docs/memory/feature-flows/mcp-orchestration.md: update stale code
  snippet that quoted the now-removed `|| "changeme"` line.
- docs/user-docs/guides/deploying/single-server.md: note that
  ADMIN_PASSWORD now drives both admin login and MCP auth, and that
  prod compose refuses to render without it.
- src/mcp-server/TEST_REPORT.md: flag the frozen 2025-11 test report's
  "Default Credentials: admin / changeme" entry as HISTORICAL pre-Abilityai#692.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
mcp-orchestration.md was already updated in the previous commit;
this just adds the one-row index entry. No other flow docs needed
touching — admin-login.md and first-time-setup.md describe the auth
flow itself (unchanged); only the upstream config layer changed,
and that's documented in docs/user-docs/guides/deploying/single-server.md
(also already updated).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated against Trinity development methodology. All 5 originally-flagged #692 issues addressed plus 2 siblings caught during adversarial review. Security scan clean, documentation updated, zero behavior change in the default MCP_REQUIRE_API_KEY=true path. LGTM.

@vybe

vybe commented May 8, 2026

Copy link
Copy Markdown
Contributor

Squash-merged manually to dev as commit 1a1980e — PR was from a fork so couldn't update the branch directly. All 10 files landed correctly; conflict in feature-flows.md (simultaneous #708 entry from dev) resolved by keeping both rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants