English
Content encryption
Each instance encrypts the content it keeps before writing it: the PostgreSQL database and the blob storage only ever receive ciphertext. The key derives from ENCRYPTION_KEY, the instance key: no two instances share it.
What is encrypted
| Content | Where | How |
|---|---|---|
Raw message (.eml): body, HTML, headers | Blob storage | AES-256-GCM, one key per object, in 64 KiB segments |
| Attachments, files added to runs, instance files, document templates, emails composed before sending | Blob storage | same |
| Message preview, body excerpt used by search | PostgreSQL | AES-256-GCM, random nonce |
| Draft proposed to an approver, and its edits | PostgreSQL | same |
Still readable in the database: the subject, the sender, the recipients, the dates, the folders and the labels. The product needs them to sort, filter and group threads; they also appear in the audit logs. Workflow run data (step outputs) is not encrypted yet; it is purged according to retention.
Every encrypted value is authenticated: a modified byte, an object moved under another key or a value copied into another column is rejected on read.
Search
The database no longer sees the text. To keep searching email bodies, the instance stores, next to each message, a secret fingerprint of each word (truncated HMAC-SHA256 with a derived key): the database can answer "this message contains this word" without containing the word.
- A whole word is found, ignoring accents and case, in the subject, the preview, the sender and the body.
- A word fragment (
invoforinvoice) is only found in the subject and the sender. - A quoted phrase is searched as its words, regardless of their order.
Turning it on for an existing instance
Deploy the version. Encryption is on from the first boot (
CONTENT_ENCRYPTION=auto): all new content is encrypted, and older content stays readable.Migrate the existing data, in a separate container:
bashdocker compose run --rm -T app node dist/cli.js content:encrypt run docker compose run --rm -T app node dist/cli.js content:encrypt statusThe migration works in batches and records its progress after each one: interrupted, it resumes where it stopped; run again, it rewrites nothing that is done. Exit code
4reports content that could not be migrated (lastErrorsays which).Once
statusreportsremaining: 0formessagesandapprovalsand afinishedAtdate forblobs, you can setCONTENT_ENCRYPTION=required: content still stored in clear is then refused instead of served.
On a versioned bucket, the old clear versions stay until your lifecycle rules expire them: delete the noncurrent versions if you do not want to wait.
Key rotation
Rotation renews the content key without stopping the service:
Pick a new generation and keep the old one for reading:
bashCONTENT_ENCRYPTION_KEY_ID=c2 CONTENT_ENCRYPTION_PREVIOUS_KEYS=c1If
ENCRYPTION_KEYitself changed (after a leak, for instance), give the old key to the old generation:CONTENT_ENCRYPTION_PREVIOUS_KEYS=c1=<previous key in hexadecimal>. Stored credentials (tokens, IMAP passwords) have no rotation yet: changingENCRYPTION_KEYstill means entering them again.Restart, then run
content:encrypt runagain: everything sealed by another generation is resealed with the new one.When
statussays everything is done, removeCONTENT_ENCRYPTION_PREVIOUS_KEYSand restart.
What it changes for you
ENCRYPTION_KEYnow protects the content of the emails. Without it, a backup no longer makes the emails readable: keep it off the server (see Backups).- The cost is low: encrypting and decrypting 20 MB takes a few tens of milliseconds; the migration handles a few thousand messages in a few seconds.
- Your storage provider's server-side encryption (SSE) is still worth having, but does not replace this: it protects against access to the provider's disks, not against access with your own S3 credentials.