Skip to content

Guard ALLOW_PLAINTEXT_SECRETS against non-local boot - #265

Merged
TheGreatAxios merged 3 commits into
mainfrom
cl-drop-demo-scaffolding
Aug 21, 2026
Merged

Guard ALLOW_PLAINTEXT_SECRETS against non-local boot#265
TheGreatAxios merged 3 commits into
mainfrom
cl-drop-demo-scaffolding

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Summary

Investigated dropping demo-specific scaffolding (CL-6536) so there is one setup path for everyone. A full search of apps/, packages/, workflows/, and scripts/ found no genuine demo-only scaffolding to remove — the setup path is already singular (bun run dev, workbench setup, and workbench seed all resolve to the same default identity and workflow set a real signup gets). Things that merely look demo-ish by name (catalog "demo-card" fields, packages/longevity-sim's load-test personas) are real product surface or legitimate engineering tooling and were left untouched. packages/folded-runs was excluded per an existing pending decision.

The one concrete, already-identified risk item: .env.example ships ALLOW_PLAINTEXT_SECRETS=1 uncommented for local-dev friction. A security review flagged that a real deployment inheriting this unmodified could store secrets — including real provider keys — unencrypted at rest.

  • The hub now refuses to boot when ALLOW_PLAINTEXT_SECRETS is set and BASE_URL is not a loopback address (localhost/127.0.0.1/::1), so the flag can only ever take effect on a developer's own machine — safe by construction rather than trusting an operator to have stripped it.
  • Local bun run dev is unaffected (BASE_URL defaults to http://localhost).
  • ALLOW_UNVERIFIED_EMAILS is deliberately left as-is: no mailer is wired up anywhere in the stack yet, so it's currently the only way self-serve signup can complete in any deployment, not just a demo — gating it the same way would break real deployments' signup, a separate larger gap tracked in CL-6536.

Test plan

  • bun test in apps/hub — 160 pass, 26 skip (DB-gated, no local Postgres), 0 fail
  • New tests assert the boot refusal against a non-loopback BASE_URL, and that it still boots against localhost/127.0.0.1 or with a real CREDENTIAL_ENCRYPTION_KEY
  • bun run check:structural passes
  • tsc --noEmit in apps/hub passes

CL-6536

Assert the hub refuses to boot with ALLOW_PLAINTEXT_SECRETS set unless
BASE_URL is a loopback address, and still boots fine locally or with a
real CREDENTIAL_ENCRYPTION_KEY.
A real deployment that inherits .env.example's dev-friendly
ALLOW_PLAINTEXT_SECRETS=1 would silently store secrets (including
real provider keys) unencrypted at rest. Rather than trust an
operator to have overridden the file, the hub now refuses to boot
when the flag is set and BASE_URL isn't localhost/127.0.0.1/::1 —
so the flag can only ever take effect against a developer's own
machine.
Note that the shipped ALLOW_PLAINTEXT_SECRETS=1 is now safe to copy
verbatim into any deployment's .env: it can only take effect when
BASE_URL is a loopback address.
@TheGreatAxios
TheGreatAxios merged commit bfa3d7d into main Aug 21, 2026
5 checks passed
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.

1 participant