ENCRYPTION_KEYS and rotating them — is covered in Deployment.
Envelope encryption
Secrets are encrypted in two layers:- Key encryption keys (KEKs) come from the
ENCRYPTION_KEYSenvironment variable, a comma-separated list. The last key encrypts; earlier keys only decrypt. KEKs never touch the database. - Data encryption keys (DEKs) are random 32-byte keys, one per workspace, generated when the workspace is created. Each DEK is stored in the workspace row wrapped (encrypted) by the active KEK.
v2:<keyId>:… for KEK data, v2:dek:… for workspace data), so the right key is found again after keys are added or removed.
Outside development, the core API refuses to start unless the active key is random and at least 32 characters long. A default or example value is rejected.
Key rotation
Rotation is additive. Append a new key toENCRYPTION_KEYS and restart: on boot, an upgrade pass re-wraps every workspace DEK and rewrites every stored secret under the new active key, then logs how many values it changed and whether any value is still readable only with an older key. Only drop an old key once that log says nothing needs it. The pass runs under a distributed lock, so with several API replicas exactly one of them does the work.
What is encrypted
Which fields count as secret
Integrations and connectors describe their configuration with a JSON Schema, so secrets are identified by the schema, not by hand-written code per tool. A field is sensitive when the schema renders it as a password widget, or when its name looks like a credential (password, secret, token, api_key, access_key, …). Sensitive fields are:
- encrypted before they are written,
- masked in every API response (
****plus at most the last four characters), - kept unchanged when a client sends the masked value back on update, so editing other fields of a form never overwrites a stored secret with its mask.
Getting a secret to the scanner
A scan job may need the plaintext — a Nessus API key, a repository token — on a worker that may run on another network. Three controls apply on the way.Release policy
Before anything is decrypted for a worker, the core API checks that the worker is allowed to receive it:- a workspace worker only receives jobs of its own workspace,
- a provider worker only receives jobs of its own tool,
- a cloud worker (operated by the platform) may receive any job.
Sealed job secrets
On first start each worker generates an HPKE key pair (RFC 9180; DHKEM P-256, HKDF-SHA256, AES-256-GCM) and sends the public half when it joins. From then on, the core API seals each job’s configuration and credential inputs to that key, binding the ciphertext to the job id and the worker id. Only the process holding the private key can open it, so a secret is not readable by anything that sits between the core API and the worker — a TLS-terminating proxy, a packet capture, or a message replayed to a different worker. A registered key is never replaced on rejoin, so a stolen worker token cannot swap in an attacker’s key. If a job cannot be sealed, it is failed rather than sent in the clear. See Worker and connector runtime.Masking on the way back
Scanners sometimes echo their command line or configuration. The worker collects the secrets of each job and replaces them with*** in container logs, raw results and error messages before anything is sent back to the core API. A tool that prints its own API key cannot leak it into the job registry, the console or a notification.
Repository credentials for Git organization targets are decrypted only at dispatch and never persisted on the job.
Secrets in events
Every domain event passes through the event bridge, from which it may reach webhooks, Slack, Telegram and ticketing systems. Payloads are therefore redacted once, at the producer: fields whose name looks like a credential are dropped, and values that look like one (ansk- key, an AKIA access key, a PEM block, a long opaque token) are replaced with ***. The audit table applies the same redaction again as defence in depth.
Audit trail integrity
The audit log is append-only in PostgreSQL itself, not just in application code. A database trigger refuses everyUPDATE, DELETE and TRUNCATE on the audit table, with two narrow exceptions that both require a dedicated maintenance role and a transaction-local flag:
- the retention job, which first archives expired rows to daily JSONL files and deletes only after the archive is complete,
- the personal-data sweep, which pseudonymizes the actor of a removed member.
Related
Tenancy and access control
How workspaces are kept apart
Worker and connector runtime
Where sealed secrets are opened and how connector containers are isolated
Event bridge
Redaction at the producer and the lanes that consume events
Deployment
Generating and rotating
ENCRYPTION_KEYS