From e1b86417649acb9634a10f10eb73fe850dc28619 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sat, 8 Aug 2026 13:38:54 -0700 Subject: [PATCH] fix(cli): validate each install secret against its own requirement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every secret was held to the 64-hex AES form, but only the encryption keys need it — BETTER_AUTH_SECRET and INTERNAL_API_SECRET are HMAC secrets that just need 32 characters. An operator-chosen passphrase was silently replaced on the next run, invalidating every sign-in. Reject the repository's published example values at any length: they are longer than the 32-character minimum and would otherwise pass as real. Back the file up and say so when replacing a value that was already there, rather than reporting it as a routine generation. Generate and pass API_ENCRYPTION_KEY, without which the app stores workspace API keys in plain text; values predating it lack the encrypted shape and are still read as-is. Resolve secrets before any container starts, so a filesystem problem reports a usable message instead of leaving a half-started stack behind. --- packages/cli/README.md | 21 ++++++ packages/cli/src/index.ts | 135 ++++++++++++++++++++++++++++++++------ 2 files changed, 135 insertions(+), 21 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index ce5430c1ad2..cddcfe564d4 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -27,6 +27,27 @@ simstudio - Docker must be installed and running on your machine. +## Data and secrets + +Everything lives under `~/.simstudio`: + +- `data/postgres` — the database volume. +- `secrets.env` — secrets generated for this install on first run, then reused. + +Keep `secrets.env`. `ENCRYPTION_KEY` and `API_ENCRYPTION_KEY` decrypt data already stored in the +database, so replacing them leaves that data unreadable. Back the file up alongside `data/`. + +You can supply your own values by editing it. The format is `KEY=value`, one per line, with `#` +for comments — quotes are not interpreted, so leave them off. + +| Key | Requirement | +|---|---| +| `ENCRYPTION_KEY`, `API_ENCRYPTION_KEY` | exactly 64 hex characters (`openssl rand -hex 32`) | +| `BETTER_AUTH_SECRET`, `INTERNAL_API_SECRET` | at least 32 characters, otherwise free-form | + +A value that does not meet its requirement is regenerated on the next run. When that replaces +something you had set, the CLI says so and copies the previous file to `secrets.env.bak-