exoDocs
Decisions (ADRs)

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 Staging and Exo Production for EXO itself (machine accounts exo-staging and exo-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 (or auto). The token may also come from a Render Secret File via the non-secret BWS_ACCESS_TOKEN_FILE. BWS_PROJECT_ID is optional: when unset, every secret the token can see counts, which for these machine accounts is exactly their project. BWS_ORGANIZATION_ID, BWS_API_URL and BWS_IDENTITY_URL are 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.ts register() calls loadSecrets(EXO_SECRET_MANIFEST) once, before the server takes traffic. It uses the official @bitwarden/sdk-wasm 0.1.0 (the napi build has no linux-arm64 binary; same choice as Cosmograph) through src/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 with secret(name) / requireSecret(name). Nothing is written to process.env, so env dumps and child processes never carry them.
  • Fail closed in production. With EXO_SECURE_SOURCE=bitwarden (or auto with a token set) in production, a missing token, an unreachable Bitwarden, or any missing required secret throws in register(): 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, auto tops 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, then file in development or env), file and env. EXO_SECURE_SOURCE defaults to env, which reads process.env exactly as before and warns in staging and production. Any other value is treated as env with a warning.
  • Local development uses either bws run -- pnpm dev (resolved values exist only in that child process; default env source) or EXO_SECURE_SOURCE=file with a gitignored .env.secrets.local (the .env.* rule already ignores it). file is refused in production.
  • Convex deploys without a Mac. scripts/convex/deploy-from-bitwarden.mjs reads CONVEX_DEPLOY_KEY from Bitwarden with the same token, refuses a key whose deployment is not the expected one (EXO_CONVEX_EXPECTED_DEPLOYMENT, defaulting to the deployment EXO_CONVEX_URL names), refuses production (befitting-bullfrog-619) unless EXO_DEPLOYMENT_ENVIRONMENT=production and EXO_ALLOW_PROD_CONVEX_DEPLOY=1, runs npx convex deploy -y with the key only in the child environment, then runs the push-staging.sh smoke checks. Exo staging runs it as the Render pre-deploy command; with no BWS_ACCESS_TOKEN it logs one line and exits 0. Production is not wired. scripts/convex/push-staging.sh stays 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:

OptionWhat it meansVerdict
A. Convex env (interim)Bird, Exo ID signing keys, OAuth client secrets, AI keys stay in the Convex deployment envRecommended now
B. Convex pulls from BitwardenA "use node" internal action reads an Exo Convex project and caches per isolateLater, 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>"} with Authorization: Bearer <EXO_GATEWAY_CLIENT_SECRET> (in the Exo Staging project). Convex stores only EXO_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, same kid as access tokens): iss = the Exo ID issuer, aud = exo-gateway:<app>, sub = exo-gateway, token_use = gateway, random jti, 5-minute lifetime. EXO caches one per App until a minute before expiry and forwards it in x-exo-gateway-token.
  • Each App verifies against the public JWKS (<issuer origin>/exo-key/.well-known/jwks.json) with verifyGatewayToken (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 (no token_use). Apps hold no gateway secret at all.
  • Flag EXO_GATEWAY_TOKENS on 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):

  1. Generate the gateway client secret (48+ random bytes) into EXO_GATEWAY_CLIENT_SECRET in the Exo Staging project; set its SHA-256 (base64url) as EXO_GATEWAY_CLIENT_SECRET_SHA256 in the staging Convex deployment.
  2. Move the current shared value into STAGING_GATEWAY_SECRET in the Exo Staging project, switch the EXO staging service to EXO_SECURE_SOURCE=bitwarden (or auto), delete STAGING_GATEWAY_SECRET from it.
  3. Set EXO_GATEWAY_TOKENS=dual on EXO staging. Verify with a request through staging.exo.now/{app} that both headers reach the upstream.
  4. For each App (Moonshot, Overwatch, Observatory, Universe; then Construct, Rampart, Cosmograph, Vector, Dropship as they adopt the gateway): ship verifyGatewayRequest with acceptLegacy: true, deploy, confirm requests verify as token; then set acceptLegacy: false and delete STAGING_GATEWAY_SECRET from that App's service.
  5. 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

ThreatBeforeAfter
Platform env store breach (Railway, 2026-10-21)Every secret on the service leaksOnly BWS_ACCESS_TOKEN leaks: read-only, one project, revocable in one click
Env dump, crash report, child process inherits envSecrets includedSecrets not in process.env
One App's env leaks the gateway secretImpersonate the gateway to all five AppsNo App holds a gateway secret; a token is good for one App for at most 5 minutes
Stolen gateway tokenn/aValid only for its App, expires in 5 minutes
Stolen bootstrap tokenn/aAttacker 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 bootn/aProduction deploy fails closed; the running deploy keeps serving from memory
Code exfiltrates memory (RCE in the server)Secrets readableStill 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.

VariableRead by (today)Current locationDestinationOwner / issuer
TWENTY_API_KEYsrc/platform/crm/twenty.ts (Next)Railway env (EXO service)Bitwarden app project, key TWENTY_API_KEY; read via secret()Samir / Twenty
STAGING_GATEWAY_SECRETsrc/platform/delivery/stagingGateway.ts (Next proxy); each upstream AppRailway env on EXO staging and on Moonshot, Overwatch, Observatory, UniverseBitwarden Exo Staging, key STAGING_GATEWAY_SECRET, then retired (section 4)Samir
EXO_GATEWAY_CLIENT_SECRET (new)src/platform/delivery/gatewayTokens.tsnoneBitwarden Exo Staging, key EXO_GATEWAY_CLIENT_SECRETSamir
EXO_GATEWAY_CLIENT_SECRET_SHA256 (new)convex/lib/gatewayToken.tsnoneConvex env (not a secret: a hash)Samir
BWS_ACCESS_TOKEN (new)src/lib/exo-securenonePlatform env: the one bootstrap exceptionSamir / Bitwarden
BIRD_API_KEYconvex/lib/bird.tsConvex envConvex env (interim, section 3); never RailwaySamir / Bird
EXO_ID_PRIVATE_KEYconvex/lib/exoIdCrypto.tsConvex envConvex env (interim; candidate for option B)Samir
AUTH_PRIVATE_KEYconvex/convex.config.ts (Convex Auth)Convex envConvex env (interim; candidate for option B)Samir
AUTH_GOOGLE_CLIENT_SECRETconvex/convex.config.tsConvex envConvex env (interim)Samir / Google Cloud
AUTH_GITHUB_CLIENT_SECRETconvex/convex.config.tsConvex envConvex env (interim)Samir / GitHub
ARCH_ROUTER_KEYconvex/ai/assessors.tsConvex envConvex env (interim)Samir
ARTIFICIAL_ANALYSIS_API_KEYconvex/ai/benchmarks.tsConvex envConvex env (interim)Samir / Artificial Analysis
EXO_AI_BROKER_TOKENconvex/aiOpenAICompat.ts, convex/lib/callerAuth.ts (legacy path); packages/exo-simulator reviewConvex env; CI env for reviewConvex env (interim); retire the legacy shared token in favour of Exo Key tokensSamir
EXO_INTAKE_SECRET_UNIVERSE / _COSMOGRAPH / _OBSERVATORYconvex/lib/intakeProtocol.tsConvex env; each App's own envConvex env (interim); App side moves to that App's Bitwarden projectSamir
EXO_VERIFY_TOKENconvex/verifyHttp.ts; packages/exo-simulator report posting; Dockerfile build ARGConvex env; Railway build variableConvex 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 tokenSamir
EXO_STATE_MIGRATION_TOKENscripts/*-exo-state-staging.ts (operator)operator shellbws run from the operator's Bitwarden access; never a platform variableSamir
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_KEYnot 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 manifestSamir
AUTH_GOOGLE_CLIENT_ID, AUTH_GITHUB_CLIENT_ID, AUTH_JWKS, EXO_ID_JWKSConvexConvex envnot 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_HOSTvariousplatform envnot 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_TOKENSvariousplatform envnot a secret (config and flags)n/a
EXO_STAGING_GRANTSsrc/proxy.tsRailway envnot a credential (user ids and scopes); keep as config, review as access policySamir

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_TOKEN is replaced.

Source: docs/adr/0014-exo-secure-secrets-from-bitwarden.md

On this page