# Secure deployment checklist (/docs/operate/secure-deployment)



Go through this before the first real call, and again after any change to the proxy, the
database or the identity setup. Each item says how to check it. Variable meanings are in
[Configuration](/docs/self-host/configuration); the reasoning is in the
[Threat model](/docs/operate/threat-model).

## Secrets and configuration [#secrets-and-configuration]

* [ ] `NODE_ENV=production`. The API refuses to start in production with a short or default
  secret, and turns on `Secure` session cookies and e-mail verification.
* [ ] `API_KEY_PEPPER`: at least 32 random characters. **Rotating it invalidates every API key.**
* [ ] `CREDENTIALS_ENCRYPTION_KEY`: 32 random bytes, base64 (`openssl rand -base64 32`), kept in a
  secret manager and **backed up separately from the database**. Without it the stored
  credentials are unreadable. Rotation steps are in [Security posture](/docs/operate/security).
* [ ] `WEBHOOK_SIGNING_SECRET`: a random value (the built-in default is refused in production).
* [ ] `AUDIT_SIGNING_KEY`: an Ed25519 key, so audit exports are signed. Keep the public key where an
  auditor can find it.
* [ ] `METRICS_TOKEN` is set, and `/metrics` is not reachable from the internet.
* [ ] The seed was **not** run, or its default admin account was removed or its password changed.
* [ ] `OUTBOUND_ALLOWED_HOSTS` lists only the internal services flows must reach. The example in
  `.env.example` (`127.0.0.1,localhost`) is for the local demo; **remove it**.
* [ ] `WEB_ORIGIN` is the exact `https://` origin of the console; `CORS_EXTRA_ORIGINS` is empty
  unless a second origin really needs the session cookie.

## Network and proxy [#network-and-proxy]

* [ ] TLS terminates at a proxy in front of the console. Check HSTS arrives:
  `curl -sI https://console.example.com/ | grep -i strict-transport`.
* [ ] `TRUST_PROXY=true` **only** if a proxy in front overwrites `X-Forwarded-For`, and
  `TRUST_PROXY_HOPS` equals the number of proxies. Wrong either way lets callers choose their
  address and walk past per-address limits (or puts every caller behind the proxy's).
* [ ] Postgres and Redis accept connections from the API and worker only, not from the internet.
* [ ] Only the console (nginx) is published. The API is reached through it, or through a gateway you
  control.
* [ ] The console answers with its Content-Security-Policy and the other headers:
  `curl -sI https://console.example.com/login | grep -iE 'content-security|permissions-policy|x-frame'`.
  `script-src` must be `'self'` (only `/demo` may add `'unsafe-eval'`). If a CDN or proxy
  rewrites headers, check again from outside.

## Database [#database]

* [ ] The application role cannot run DDL. A separate role runs `prisma migrate deploy`, with
  `lock_timeout` set (see the Migrations section below).
* [ ] Backups are taken, **a restore has been tried**, and the retention of the backups matches your
  data-retention promise (an erased person must age out of backups too).
* [ ] `DB_POOL_MAX` is sized so replicas × pool + worker stays under `max_connections`.
* [ ] `DB_STATEMENT_TIMEOUT_MS` is set on API-only replicas, not on the worker.

## Limits [#limits]

* [ ] `MAX_CONCURRENT_EXECUTIONS` and the rate limits are set from a load test on separate machines,
  not from the defaults.
* [ ] `EXECUTION_TIMEOUT_MS` (default 30 s) is below the timeout of anything in front of the API.
* [ ] `EXECUTION_PAYLOAD_LIMIT_BYTES`, `EXECUTION_MAX_TOTAL_STEPS` and
  `EXECUTION_MAX_COMPOSITE_BYTES` match what your largest legitimate decision needs.

## Personal data [#personal-data]

* [ ] Each decision's input model marks personal fields **sensitive**, and the output model too if
  it echoes them.
* [ ] A retention period is set per project (Settings → Data protection) or platform-wide with
  `EXECUTION_RETENTION_DAYS`. The default keeps executions for ever.
* [ ] Someone knows how to erase a person's data (Settings → Data protection, or
  `POST /personal-data/erasures`) and that callers must send an `identifier` for the person to be
  findable.

## Identity [#identity]

* [ ] The first owner has two-factor authentication on, and **Require 2FA** is on for the workspace.
* [ ] Single sign-on is configured where the company has an identity provider, with **Require SSO**
  for its domains; owners keep password sign-in as the way back in.
* [ ] Registration is restricted (mode and domain allowlist, plus CAPTCHA if the console is public).
* [ ] Four-eyes publishing is on for decisions that move money (Settings → Governance).

## Migrations [#migrations]

* [ ] CI runs `db:lint-migrations`. A migration that touches a large table was rehearsed with
  `db:rehearse` at a realistic row count (the policy is in `apps/api/docs/MIGRATIONS.md`).
* [ ] The migration role has `ALTER ROLE … SET lock_timeout = '5s'`.

## Supply chain and operations [#supply-chain-and-operations]

* [ ] The Security workflow (dependency audit, secret scan, image scan) is green on the commit you
  deploy, and any waiver (`bun audit --ignore`, `.gitleaks.toml`, `.trivyignore`) has a reason
  and a date.
* [ ] Container images are rebuilt regularly, so base-image fixes arrive.
* [ ] Alerts from `monitoring/` have an owner and a place to go.
* [ ] You know where the logs are and that they are JSON on stdout; they do not contain credentials
  or sensitive fields, but do contain identifiers and request metadata.
