Security

The parts of gateway operations that are invisible in a happy demo and decisive in an incident.

Key custody

SecretWhere it livesWhere it must never appear
Provider keys (sk-…)env file 0600 on the host, or a secrets manager; readable only by the gateway process userlogs, error bodies, client responses, git, container images, backups in plaintext
Virtual keys (vk-…)hashed at rest in the gateway DB anywhere in full after creation — the UI shows a one-time reveal, logs show a prefix
Admin credentialspassword manager; TOTP enabled shared chats, .env files in repos

Least privilege

Log redaction

Gateways sit on the request path, so their logs are a honeypot by default. The deployment redacts:

The demo request log shows exactly this shape: enough to operate, nothing worth stealing.

Recovery flows (rehearsed, not theoretical)

IncidentResponse
Virtual key leakedRevoke the key (requests fail closed), review its usage window in the audit log, issue a replacement with the same policy. Blast radius: that key’s quota.
Provider key suspectedRotate at the provider, update the vault entry, restart the gateway (seconds of downtime behind a retrying proxy), verify with a canary request.
Host compromise suspectedFreeze: revoke provider keys at the provider first — they are the crown jewels. Rebuild from a clean image plus the encrypted backup; never restore executables from the compromised host.
Data lossRestore last night’s encrypted dump; usage rows since the dump are gone and acknowledged as gone — billing reconciles against provider dashboards.