fix(cli): generate per-install secrets instead of using fixed values - #6433
Conversation
The launcher passed the same built-in BETTER_AUTH_SECRET and ENCRYPTION_KEY to every install. Generate them once per install, persist them 0600 at ~/.simstudio/secrets.env, and reuse them on later runs so data already in the Postgres volume stays readable. Also passes INTERNAL_API_SECRET, which the realtime container requires and never received.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Secret handling adds validation (invalid or missing keys are regenerated), atomic writes via a temp file + rename, and mode Reviewed by Cursor Bugbot for commit e658a88. Configure here. |
Greptile SummaryThe CLI now generates and persists distinct per-install authentication and encryption secrets, atomically rewrites invalid secret files, enforces restrictive file permissions, and supplies the secrets to both application containers.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/cli/src/index.ts | Adds persistent per-install secret resolution, atomic replacement, permission enforcement, and container environment propagation; the previously reported permission exposure is fixed. |
Reviews (3): Last reviewed commit: "fix(cli): write the secrets file atomica..." | Re-trigger Greptile
writeFileSync's `mode` applies only when it creates the file, and the write is skipped entirely when the stored values are already valid — so a secrets file left with permissive permissions kept them. chmod it on every run.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
1 issue from previous review remains unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 610b9ea. Configure here.
Regenerating any one key rewrites all of them, and a plain write truncates first — a crash mid-rewrite would strand a still-valid ENCRYPTION_KEY and orphan the data it protects. Write to a temp file and rename into place.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e658a88. Configure here.

Summary
BETTER_AUTH_SECRETandENCRYPTION_KEYto every install. It now generates them once per install and reuses them.~/.simstudio/secrets.env(written0600). Reuse matters:ENCRYPTION_KEYdecrypts data already in the Postgres volume under~/.simstudio/data, so a fresh key each launch would orphan it.INTERNAL_API_SECRET, which the realtime container requires and never received.Type of Change
Testing
Exercised the secret resolution directly: values are 64-hex and distinct per key, stable across repeated runs, a non-conforming stored value is replaced, a valid uppercase hex key is preserved rather than rotated, and the file is written
0600. Typecheck and lint clean.Checklist