Skip to content

fix(cli): generate per-install secrets instead of using fixed values - #6433

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/cli-install-secrets
Aug 8, 2026
Merged

fix(cli): generate per-install secrets instead of using fixed values#6433
waleedlatif1 merged 3 commits into
stagingfrom
fix/cli-install-secrets

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The launcher passed the same built-in values for BETTER_AUTH_SECRET and ENCRYPTION_KEY to every install. It now generates them once per install and reuses them.
  • Secrets persist at ~/.simstudio/secrets.env (written 0600). Reuse matters: ENCRYPTION_KEY decrypts data already in the Postgres volume under ~/.simstudio/data, so a fresh key each launch would orphan it.
  • Also passes INTERNAL_API_SECRET, which the realtime container requires and never received.

Type of Change

  • Bug fix

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

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

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.
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 8, 2026 8:18pm

Request Review

@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes how auth, encryption, and internal API secrets are sourced for local Docker runs; mistakes could break sessions or decrypt stored credentials, but persistence and atomic writes reduce data-loss risk.

Overview
The Docker CLI no longer injects the same placeholder auth and encryption secrets into every install. It now generates per-install 32-byte hex values for BETTER_AUTH_SECRET, ENCRYPTION_KEY, and INTERNAL_API_SECRET, stores them in ~/.simstudio/secrets.env, and reuses them on later runs so encrypted Postgres data under ~/.simstudio/data stays decryptable.

Secret handling adds validation (invalid or missing keys are regenerated), atomic writes via a temp file + rename, and mode 0600 on every run. The realtime and app containers receive the resolved values, including INTERNAL_API_SECRET for realtime, which was missing before.

Reviewed by Cursor Bugbot for commit e658a88. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The 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.

  • Generates three persistent 32-byte secrets under ~/.simstudio/secrets.env
  • Reuses valid stored values to preserve access to encrypted data
  • Reasserts mode 0600 on every launch
  • Supplies the shared internal API secret to the realtime and application containers

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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

Comment thread packages/cli/src/index.ts Outdated
Comment thread packages/cli/src/index.ts
Comment thread packages/cli/src/index.ts Outdated
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.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

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.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ 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.

@waleedlatif1
waleedlatif1 merged commit 33fe043 into staging Aug 8, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/cli-install-secrets branch August 8, 2026 20:22
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