Linora

0906. Safe defaults and least privilege for self-hosters: refuse published dev secrets, read-only blob readers, no master key in realtime, guarded prod:env --force

Status: Accepted (2026-11-30). Phase 1 (clean-up) of the open-source plan: its open security items and safe defaults for self-hosters. Tightens 0903 and finishes 0310 in the prod-like compose.

Context

Once the repo is public, people will copy docker-compose.prod.yml and .env.example as they are. The second security pass over the S3 client, the prod compose file and the changes after 7e799f3 (review, second pass) found that the prod-like stack gave tiers more than they need:

Decision

  1. Refuse published development secrets in production. loadServerConfig (every tier with a database) reports a problem when NODE_ENV is production or unset and the DATABASE_URL password or LINORA_S3_SECRET_ACCESS_KEY is a published dev value (DEV_DB_PASSWORDS, DEV_S3_SECRETS in packages/server-common/src/config.ts). The value itself is never echoed. A test keeps the lists in step with .env.example, docker-compose.yml and ci.yml.
    • LINORA_ALLOW_DEV_SECRETS=1 lifts it for tests and benchmarks that run production mode against the dev database (the API test harness, deploy/measure-rss.mjs, the load-test server). It is documented as never for a deployment.
    • A missing password (peer auth, a passfile) is not a dev secret and stays allowed.
  2. Realtime gets only its keyrings: LINORA_TOKEN_KEYS_RT, _CG and _SVC_DOCWORKER. The TEMPORARY master line is gone, and no container receives LINORA_TOKEN_MASTER.
  3. Only the compactors write blobs. api, realtime and the doc worker mount blobs read-only. No tier gets an S3 secret while LINORA_BLOB_STORE=local; switching to s3 gives the compactors a read-write bucket user and the readers a read-only one, never the root key.
  4. Metrics of edge-facing tiers stay on loopback. api and realtime keep the 127.0.0.1 default. Doc workers and compactors sit only on internal and keep 0.0.0.0 there. A Prometheus for api and realtime needs pinned internal addresses (follow-up when one is added).
  5. prod:env --force refuses while the compose project has volumes, or when Docker cannot be asked. When it does run, it backs up the old file (mode 0600) and sets 0600 on the new one even when the file existed.
  6. deploy/prod-compose.test.mjs asserts 2-5 on the compose file: keyrings per tier, own DB login per tier, read-only blob readers, no S3 secret with the local store, loopback metrics on the edge network, and the --force guard.

Consequences

Alternatives considered