Decisions and roadmap
ADR 0014: Exo Secure loads secrets from Bitwarden Secrets Manager at boot; no secrets in platform env vars
2026-11-13: secrets provider changed to Bitwarden. Bitwarden Secrets Manager is the only secrets provider (Samir, 2026-11-06, confirmed 2026-11-13). This ADR now states the Bitwarden design throughout; the rule it set on 2026-10-21 (secrets load at boot into memory, and the host holds one read-only bootstrap token and nothing else secret) is unchanged.
- Status: proposed (draft PR; owner decision pending on the open items below)
- Date: 2026-10-21 (provider amended 2026-11-06 and 2026-11-13)
- Decided by: Samir (owner), standing rule set 2026-10-21
- Relates to: ADR 0004 (Exo ID issuer and JWKS), ADR 0005 (Simulator), roadmap item "Exo Secure"
Context
On 2026-10-21 Railway disclosed that an unauthorized party accessed systems that store customer environment variables, obtained the decrypted contents of some of them, and appears to have been hunting for AI provider keys; Railway recommends rolling every variable and paused all deployments (Railway disclosure).
Every EXO secret that lives in a platform env store (Railway, Vercel, Convex) is exposed to a breach
of that platform, and an env var also leaks through crash reports, child processes, env dumps and
build logs. Separately, staging.exo.now proves the gateway to five upstream Apps (Exo, Moonshot,
Overwatch, Observatory, Universe) with one shared STAGING_GATEWAY_SECRET in the
x-exo-gateway-secret header, so one leaked App env lets anyone impersonate the gateway to all of
them (security review item M1).
Standing rule from the owner: Exo Secure must never store secrets as platform env vars. The only exception is a single bootstrap token per app.
Decision
1. One read-only Bitwarden machine account per app environment
- Each app environment gets its own Bitwarden Secrets Manager project and one read-only machine
account limited to only that project:
Exo StagingandExo Productionfor EXO itself (machine accountsexo-stagingandexo-production); every managed app follows the same pattern (Moonshot Staging, …). - The platform holds only
BWS_ACCESS_TOKEN(the machine account's access token, the bootstrap token) plus non-secret config:EXO_SECURE_SOURCE=bitwarden(orauto). The token may also come from a Render Secret File via the non-secretBWS_ACCESS_TOKEN_FILE.BWS_PROJECT_IDis optional: when unset, every secret the token can see counts, which for these machine accounts is exactly their project.BWS_ORGANIZATION_ID,BWS_API_URLandBWS_IDENTITY_URLare optional and not secret. - Secrets are looked up by key, and the key is the variable name (for example
TWENTY_API_KEY), never a hard-coded secret id. The list of names lives in code (src/lib/exo-secure/manifest.ts), so what an app needs is reviewed like code.
2. Resolve at boot into memory, never back into process.env
src/instrumentation.tsregister()callsloadSecrets(EXO_SECRET_MANIFEST)once, before the server takes traffic. It uses the official@bitwarden/sdk-wasm0.1.0 (the napi build has no linux-arm64 binary; same choice as Cosmograph) throughsrc/lib/exo-secure/bitwarden.mjs, with one batched read.- Values go into an in-memory store on
globalThis(a registered symbol, so the Next proxy bundle and route bundles share it). Server code reads them withsecret(name)/requireSecret(name). Nothing is written toprocess.env, so env dumps and child processes never carry them. - Fail closed in production. With
EXO_SECURE_SOURCE=bitwarden(orautowith a token set) in production, a missing token, an unreachable Bitwarden, or any missing required secret throws inregister(): the new deploy never becomes healthy and the previous one stays live. Staging and development log a warning instead. - After loading, the server warns (by name, never value) about any managed secret that is still
also set as a platform variable, so leftovers get deleted. Outside production,
autotops up a name Bitwarden does not hold yet from platform env and names it (a host part-way through the move); production never does. - Sources.
bitwarden,auto(Bitwarden, thenfilein development orenv),fileandenv.EXO_SECURE_SOURCEdefaults toenv, which readsprocess.envexactly as before and warns in staging and production. Any other value is treated asenvwith a warning. - Local development uses either
bws run -- pnpm dev(resolved values exist only in that child process; defaultenvsource) orEXO_SECURE_SOURCE=filewith a gitignored.env.secrets.local(the.env.*rule already ignores it).fileis refused in production. - Convex deploys without a Mac.
scripts/convex/deploy-from-bitwarden.mjsreadsCONVEX_DEPLOY_KEYfrom Bitwarden with the same token, refuses a key whose deployment is not the expected one (EXO_CONVEX_EXPECTED_DEPLOYMENT, defaulting to the deploymentEXO_CONVEX_URLnames), refuses production (befitting-bullfrog-619) unlessEXO_DEPLOYMENT_ENVIRONMENT=productionandEXO_ALLOW_PROD_CONVEX_DEPLOY=1, runsnpx convex deploy -ywith the key only in the child environment, then runs thepush-staging.shsmoke checks. Exo staging runs it as the Render pre-deploy command; with noBWS_ACCESS_TOKENit logs one line and exits 0. Production is not wired.scripts/convex/push-staging.shstays as the manual fallback. - Trade-off. The staging runtime token can also read the staging Convex deploy key, because both live in the one "Exo Staging" project. Accepted for staging; for production, consider a separate project and machine account for the deploy key before wiring it.
3. Bird and other Convex-only secrets: Convex env as the interim home
Bird SMS already runs only in Convex (convex/lib/bird.ts, convex/communications.ts
sendSms internal mutation and deliverSms internal action). No Next code reads BIRD_* or calls
the Bird API; tests/int/exo-secure-boundaries.int.spec.ts now fails if that ever changes. Both
functions are registered internal, so only Convex code (phone sign-in in convex/phoneAuth.ts, or
a deploy-key caller) can trigger a send; they need no entry in the public-write allowlist of
tests/int/convex-auth-guards.int.spec.ts. When Bird email arrives it follows the same shape.
Convex env is also a platform env store. Options:
| Option | What it means | Verdict |
|---|---|---|
| A. Convex env (interim) | Bird, Exo ID signing keys, OAuth client secrets, AI keys stay in the Convex deployment env | Recommended now |
| B. Convex pulls from Bitwarden | A "use node" internal action reads an Exo Convex project and caches per isolate | Later, for the highest-value keys |
Why A now: the breach was Railway's, and Convex is a separate vendor and blast radius; Convex
functions run inside Convex, so these secrets never touch Railway or the Next server; and B still
needs a BWS_ACCESS_TOKEN in Convex env (the bootstrap exception moves, it does not disappear),
adds a Bitwarden round trip to Node-action cold starts, and cannot serve the default (V8) runtime
that most EXO functions use. Revisit B for
EXO_ID_PRIVATE_KEY and AUTH_PRIVATE_KEY when Convex supports a secret-manager integration or
if Convex's posture changes. Run the new platform-env check against npx convex env list output
with an explicit allowlist to keep that store reviewed.
4. Per-app Exo Key gateway tokens replace STAGING_GATEWAY_SECRET (M1)
- The gateway asks Exo Key for a token per upstream App:
POST <exo key site>/exo-key/v1/gateway-token {"app": "<slug>"}withAuthorization: Bearer <EXO_GATEWAY_CLIENT_SECRET>(in theExo Stagingproject). Convex stores onlyEXO_GATEWAY_CLIENT_SECRET_SHA256, which is not a secret. The route answers 404 until that hash is set, so it ships dark. - The token is an RS256 JWT signed by the existing Exo ID issuer key (
convex/lib/gatewayToken.ts, samekidas access tokens):iss= the Exo ID issuer,aud=exo-gateway:<app>,sub=exo-gateway,token_use=gateway, randomjti, 5-minute lifetime. EXO caches one per App until a minute before expiry and forwards it inx-exo-gateway-token. - Each App verifies against the public JWKS (
<issuer origin>/exo-key/.well-known/jwks.json) withverifyGatewayToken(src/platform/delivery/gatewayTokens.ts). A token minted for one App fails at every other App, and an ordinary Exo ID access token is never accepted (notoken_use). Apps hold no gateway secret at all. - Flag
EXO_GATEWAY_TOKENSon the EXO service:off(default; shared header only, today's behaviour),dual(both headers),only(token only; a missing token fails closed with 503). Caller-supplied copies of either header are always stripped.
Per-app migration (each step is reversible by flipping the flag back):
- Generate the gateway client secret (48+ random bytes) into
EXO_GATEWAY_CLIENT_SECRETin theExo Stagingproject; set its SHA-256 (base64url) asEXO_GATEWAY_CLIENT_SECRET_SHA256in the staging Convex deployment. - Move the current shared value into
STAGING_GATEWAY_SECRETin theExo Stagingproject, switch the EXO staging service toEXO_SECURE_SOURCE=bitwarden(orauto), deleteSTAGING_GATEWAY_SECRETfrom it. - Set
EXO_GATEWAY_TOKENS=dualon EXO staging. Verify with a request through staging.exo.now/{app} that both headers reach the upstream. - For each App (Moonshot, Overwatch, Observatory, Universe; then Construct, Rampart, Cosmograph,
Vector, Dropship as they adopt the gateway): ship
verifyGatewayRequestwithacceptLegacy: true, deploy, confirm requests verify astoken; then setacceptLegacy: falseand deleteSTAGING_GATEWAY_SECRETfrom that App's service. - When every App is on tokens only, set
EXO_GATEWAY_TOKENS=only, delete the legacy secret from the project, and remove the legacy code path.
5. Simulator enforces it
exo-simulator security gains a built-in platform-env check
(packages/exo-simulator/lib/level1/platform-env.mjs, plain Node, no git, no network). Given a
variables export (railway variables --json, a [{name,value}] list, or dotenv; file path or
stdin) it fails on values that look like secrets: known prefixes (sk-, sk_live_, ghp_,
github_pat_, xox[bpas]-, re_, bk_, AKIA, Bitwarden machine-account tokens other than
BWS_ACCESS_TOKEN, Stripe whsec_, Google AIza, Convex deploy keys), JWT and PEM shapes, JSON carrying private JWK
members, high-entropy strings, and names ending _KEY, _SECRET, _TOKEN, _PASSWORD. An
allowlist (BWS_ACCESS_TOKEN plus explicit non-secret config) is the only escape; Railway ${{ }}
references pass. Findings name the variable and the reason, never
the value. No export provided means a skip (advisory), so builds without one stay green. Standalone:
pnpm simulator:platform-env <file|->.
Threat model
| Threat | Before | After |
|---|---|---|
| Platform env store breach (Railway, 2026-10-21) | Every secret on the service leaks | Only BWS_ACCESS_TOKEN leaks: read-only, one project, revocable in one click |
| Env dump, crash report, child process inherits env | Secrets included | Secrets not in process.env |
| One App's env leaks the gateway secret | Impersonate the gateway to all five Apps | No App holds a gateway secret; a token is good for one App for at most 5 minutes |
| Stolen gateway token | n/a | Valid only for its App, expires in 5 minutes |
| Stolen bootstrap token | n/a | Attacker can read that one project until revoked; it cannot write or see other projects. Revoke the access token in Bitwarden and issue a new one |
| Bitwarden outage at boot | n/a | Production deploy fails closed; the running deploy keeps serving from memory |
| Code exfiltrates memory (RCE in the server) | Secrets readable | Still readable: Exo Secure does not defend against code execution in the app |
Rotation
- Rotate a secret by editing it in the Bitwarden project, then restarting (redeploying) the app; no platform change is needed. Restart is required because values are read once at boot.
- Rotate the bootstrap token by creating a new machine-account access token, setting it on the platform, redeploying, then revoking the old one.
- Gateway tokens rotate themselves every 5 minutes. Rotating the signing key follows the existing
Exo ID JWKS procedure (publish the new key first; Apps fetch JWKS by
kid). - The 2026-10-21 Railway advice to roll every variable is a separate, owner-approved action; this ADR does not rotate or revoke anything.
Blast radius
One machine account per app environment, read-only, one project. A leak of Exo Staging's token
exposes only EXO staging's few secrets, never production, never another app. Today a Railway leak
exposes every variable on every service in the project.
Cost and unit economics
- Bitwarden Secrets Manager runs in the Interspace Ventures organization. Its free plan (checked 2026-11-05) allows 3 projects and 3 machine accounts: enough for EXO's two projects, not for every managed app's staging and production pair. A paid Secrets Manager plan is an owner decision.
- Exo Secure makes one sign-in and one batched read per boot, so even 100 deploys and restarts a day across every app is a handful of API calls.
- Cost per unit: $0 marginal per app, per deploy and per request on the current plan. Gateway tokens cost one Convex HTTP action per App every ~4 minutes while traffic flows (about 360 calls per App per day), well inside the Convex plan's included function calls. The platform-env check adds well under a second to the gate.
- Margin note: Exo Secure is not a cost driver, so it is not a pricing metric; include it in every plan, unmetered. If Exo later hosts secrets for customers, price per seat or per project, never per secret.
Migration table
Every secret-shaped variable the exo repo reads today (grep of process.env and app.env across
src/, convex/, packages/, scripts/, plus .env.example), with its destination. Owner is
Samir (Interspace) for every row unless noted; the provider column is who issues the value.
| Variable | Read by (today) | Current location | Destination | Owner / issuer |
|---|---|---|---|---|
TWENTY_API_KEY | src/platform/crm/twenty.ts (Next) | Railway env (EXO service) | Bitwarden app project, key TWENTY_API_KEY; read via secret() | Samir / Twenty |
STAGING_GATEWAY_SECRET | src/platform/delivery/stagingGateway.ts (Next proxy); each upstream App | Railway env on EXO staging and on Moonshot, Overwatch, Observatory, Universe | Bitwarden Exo Staging, key STAGING_GATEWAY_SECRET, then retired (section 4) | Samir |
EXO_GATEWAY_CLIENT_SECRET (new) | src/platform/delivery/gatewayTokens.ts | none | Bitwarden Exo Staging, key EXO_GATEWAY_CLIENT_SECRET | Samir |
EXO_GATEWAY_CLIENT_SECRET_SHA256 (new) | convex/lib/gatewayToken.ts | none | Convex env (not a secret: a hash) | Samir |
BWS_ACCESS_TOKEN (new) | src/lib/exo-secure | none | Platform env: the one bootstrap exception | Samir / Bitwarden |
BIRD_API_KEY | convex/lib/bird.ts | Convex env | Convex env (interim, section 3); never Railway | Samir / Bird |
EXO_ID_PRIVATE_KEY | convex/lib/exoIdCrypto.ts | Convex env | Convex env (interim; candidate for option B) | Samir |
AUTH_PRIVATE_KEY | convex/convex.config.ts (Convex Auth) | Convex env | Convex env (interim; candidate for option B) | Samir |
AUTH_GOOGLE_CLIENT_SECRET | convex/convex.config.ts | Convex env | Convex env (interim) | Samir / Google Cloud |
AUTH_GITHUB_CLIENT_SECRET | convex/convex.config.ts | Convex env | Convex env (interim) | Samir / GitHub |
ARCH_ROUTER_KEY | convex/ai/assessors.ts | Convex env | Convex env (interim) | Samir |
ARTIFICIAL_ANALYSIS_API_KEY | convex/ai/benchmarks.ts | Convex env | Convex env (interim) | Samir / Artificial Analysis |
EXO_AI_BROKER_TOKEN | convex/aiOpenAICompat.ts, convex/lib/callerAuth.ts (legacy path); packages/exo-simulator review | Convex env; CI env for review | Convex env (interim); retire the legacy shared token in favour of Exo Key tokens | Samir |
EXO_INTAKE_SECRET_UNIVERSE / _COSMOGRAPH / _OBSERVATORY | convex/lib/intakeProtocol.ts | Convex env; each App's own env | Convex env (interim); App side moves to that App's Bitwarden project | Samir |
EXO_VERIFY_TOKEN | convex/verifyHttp.ts; packages/exo-simulator report posting; Dockerfile build ARG | Convex env; Railway build variable | Convex env (verifier side). Build side: open item (a build-time token cannot come from a runtime secrets store); replace with a short-lived Exo Key token | Samir |
EXO_STATE_MIGRATION_TOKEN | scripts/*-exo-state-staging.ts (operator) | operator shell | bws run from the operator's Bitwarden access; never a platform variable | Samir |
RESEND_API_KEY, CRON_SECRET, ENTIRE_API_KEY, ENTIRE_WEBHOOK_SECRET, GITHUB_APP_PRIVATE_KEY, GITHUB_WEBHOOK_SECRET, GITHUB_TOKEN, RAILWAY_API_TOKEN, TYPESAFE_API_KEY | not read by code today (listed in .env.example only) | possibly Railway env (unverified) | Delete from Railway if present; any future use goes in the Bitwarden app project via the manifest | Samir |
AUTH_GOOGLE_CLIENT_ID, AUTH_GITHUB_CLIENT_ID, AUTH_JWKS, EXO_ID_JWKS | Convex | Convex env | not a secret (public); keep EXO_ID_JWKS public-only (the check flags private JWK members) | Samir |
EXO_CONVEX_URL, NEXT_PUBLIC_CONVEX_URL, NEXT_PUBLIC_SERVER_URL, EXO_CONVEX_SITE_URL, CONVEX_SITE_URL, EXO_KEY_SITE_URL, EXO_ID_ISSUER, EXO_ID_AUTHORIZE_URL, EXO_KEY_DEVICE_URL, EXO_DOCS_URL, ARCH_ROUTER_URL, TWENTY_API_URL, BIRD_API_HOST | various | platform env | not a secret (URLs) | n/a |
*_STAGING_ORIGIN (9), EXO_STAGING_HOSTS, EXO_CONTROL_PLANE_HOSTS, EXO_DEPLOYMENT_ENVIRONMENT, EXO_DELIVERY_STAGE, EXO_IDENTITY_PLANE, EXO_SERVICE_PROVISIONING_ENABLED, EXO_WORK_REGISTER_ENVIRONMENT, EXO_MCP_ALLOWED_ORIGINS, EXO_PROTECTED_RESOURCES, EXO_AI_MODEL, EXO_AI_ASSESSOR, TWENTY_INTERSPACE_OPPORTUNITY_STAGE, BIRD_SMS_FROM, EMAIL_*, DROPSHIP_RAILWAY_*, EXO_SECURE_SOURCE, BWS_PROJECT_ID, EXO_GATEWAY_TOKENS | various | platform env | not a secret (config and flags) | n/a |
EXO_STAGING_GRANTS | src/proxy.ts | Railway env | not a credential (user ids and scopes); keep as config, review as access policy | Samir |
Consequences
- EXO's Railway service ends with one secret-shaped variable. Every other managed app adopts the same
module (copy
src/lib/exo-secure) and the same gate check. - A boot now depends on Bitwarden being reachable; a failed deploy stays on the previous version.
- Secrets change only on restart. Hot reload of secrets is out of scope.
- Open items for the owner: create the projects and machine accounts; decide whether the free
Secrets Manager plan's limits are enough or a paid plan is needed; approve option A for Convex; decide how the build-time
EXO_VERIFY_TOKENis replaced.