Secrets

The key that seals saved integration passwords: making it, backing it up apart from the database, rotating it, and private networks.

On this page

Stater connects to other systems for some features: an email server, a company directory, an AI provider, a SIEM, threat-intelligence feeds, off-site backup storage and accounting software. Their passwords and tokens are saved encrypted. This page says how, and what you need to look after.

What is encrypted, and what is not#

  • Encrypted: every password, token and secret key an owner types into a connector screen, and the tokens accounting software hands back when an owner connects it (accounting.<id>.client_secret, .refresh_token, .access_token and .company_file_password; disconnecting deletes all four). Each is sealed with AES-256-GCM in the secrets table, under a key that is never stored in the database. The API never returns one: screens only learn whether one is saved (password_set). They never appear in the audit log, in events sent to webhooks or in the server log.
  • Not encrypted: webhook signing secrets (whsec_…). The receiving system holds the same secret to check signatures, and the dispatcher reads it for every delivery, so it stays in the webhooks table as before. Treat database backups as sensitive for this reason too.
  • Staff passwords and PINs are not "secrets" in this sense: they are hashed with argon2id and can never be read back.

Make a key#

stater secrets keygen -out /etc/stater/secret.key

This writes a new 32-byte key with mode 0600 and never overwrites a file. Then set STATER_SECRET_KEY_FILE=/etc/stater/secret.key for the server. If that file is empty the server refuses to start, rather than carry on without the key (or make another one in STATER_DATA_DIR). stater secrets keygen without -out prints a key instead, for STATER_SECRET_KEY.

With compose, put the key in .env as STATER_SECRET_KEY=…. Every replica reads the same .env, so they share it. Every server that uses the same database must have the same key.

Until a key is set, passwords cannot be saved: connector screens say so, and the setup wizard offers to set email up later. GET /api/v1/system/secrets (owners) and the strip at the top of each connector screen show the state.

Back the key up apart from the database#

A database backup holds the sealed passwords but not the key. That is the point: someone with a stolen backup cannot read them. It also means a restored database without its key cannot read the saved passwords. Keep a copy of the key somewhere safe and separate from your database backups, such as a password manager. Without it, you can still restore, but every connector password must be typed in again.

Single-server installs: the data directory#

When no key is given, a server with STATER_DATA_DIR set makes its own key at <STATER_DATA_DIR>/secret.key (mode 0600) on first start and logs that it did. Packaged installs set this to /var/lib/stater.

This is weaker than a key you manage: the key sits on the same machine as the database, so a copy of the whole machine has both. Back the file up apart from the database. Do not use it with several replicas: each would make a different key (see "Mismatch" below).

Rotating the key#

  1. Make a new key: stater secrets keygen -out /etc/stater/secret.key.new.
  2. On every server, set STATER_SECRET_KEY_FILE to the new key and STATER_SECRET_KEY_OLD to the previous one, and restart. Old secrets can still be read; new ones are sealed with the new key.
  3. Run stater secrets rotate once, with the same two settings. It re-encrypts every saved secret with the new key in one transaction, records secrets.rotate in the audit log and prints "Re-encrypted N secrets with key k…".
  4. Run stater secrets check. It prints the key id, how many secrets each key can open, and whether the key check matches. It exits with an error if any secret cannot be opened, so it suits a deployment check. It only looks: it never makes a key file or saves a key check.
  5. Remove STATER_SECRET_KEY_OLD once every server has restarted.

Mismatch#

Stater keeps a check row (_check) sealed with the key. On start, each server opens it. A server whose key does not open it logs an error and refuses to save passwords, rather than sealing secrets the other servers cannot read. Admin screens show: "This server's secret key is not the one the saved passwords were sealed with. Give every server the same STATER_SECRET_KEY." GET /system/secrets reports mismatch: true.

Saved secrets sealed with a key no server has (for example after restoring onto a new install without the old key) are counted as unreadable. Set that key in STATER_SECRET_KEY_OLD, or type the passwords again.

Private networks: STATER_PRIVATE_CONNECTORS#

Connectors refuse private and loopback addresses unless an owner ticks On my own network on that connector, for example for an email relay or LDAP server in the back office. STATER_PRIVATE_CONNECTORS=false turns that option off for the whole server, which hosted deployments should do. Addresses are checked after DNS resolution, so a name that resolves to an internal address is refused too.

Link-local addresses and cloud metadata (169.254.169.254, AWS's fd00:ec2::254 and fd00:ec2::23, Alibaba Cloud's 100.100.100.200) are refused always, whatever the settings, for connectors and webhooks alike. STATER_WEBHOOK_ALLOW_PRIVATE still lets webhooks reach private and loopback addresses for testing, but never link-local ones, and not at all when STATER_PRIVATE_CONNECTORS=false.