Keys and Key Management
Self-Hosted Only
What Is Sealed, and With What
Section titled “What Is Sealed, and With What”Some of what organizations store is sealed, encrypted inside the database with keys of their own: drafts and their conversations with the assistant, comments, single sign-on client secrets and authenticator-app secrets.
- Data keys. Each organization has its own data keys (AES-256-GCM), one active at a time. The database holds them only wrapped.
- The key-encryption key (KEK) wraps every data key. No sealed value is ever sent to it: it only wraps and unwraps data keys.
- The folder of keys (
Assistant:KeysPath) holds the keys that protect the credentials organizations store, such as their own AI key, and, unless the KEK lives in a key service, the KEK itself asforge-kek.key.
Revisions of models are not sealed: each keeps its SHA-256 fingerprint, which re-encrypting would break. The database’s own storage encryption covers them.
Where the KEK Lives
Section titled “Where the KEK Lives”Encryption:Kek chooses:
| Value | Where | For |
|---|---|---|
file (the default) |
forge-kek.key in the folder of keys, made on first use |
One server, an install with no way to a cloud, development |
aws-kms |
A symmetric key in AWS KMS | An install on AWS |
azure-key-vault |
An AES key (oct-HSM) in an Azure Key Vault Premium vault, or a Managed HSM |
An install on Azure |
gcp-kms |
A symmetric key in Google Cloud KMS | An install on Google Cloud |
With a key service, the KEK never leaves it, every use of it is in the service’s own log, and turning the key off closes the sealed data within ten minutes.
AWS KMS
Section titled “AWS KMS”- Make a symmetric key, usage “Encrypt and decrypt”. Keep the people who manage it apart from the role that uses it.
- Give the API’s role
kms:Encryptandkms:Decrypton that key only, with the conditionkms:EncryptionContext:purposeequalsforge-dek. On EKS use Pod Identity, on ECS the task role. - Set
Encryption:Kektoaws-kmsandEncryption:KmsKeyto the key’s ARN,arn:aws:kms:<region>:<account>:key/<id>. An alias is refused: every data key records the name of the key that wrapped it, and an alias can be pointed elsewhere. - For the FIPS endpoint, as in AWS GovCloud, set
Encryption:AwsUseFipsEndpointtotrue.
Azure Key Vault
Section titled “Azure Key Vault”- Make a Premium vault, with role-based permissions, soft delete and purge protection on; or a Managed HSM.
- Make an
oct-HSMAES-256 key with the operations encrypt and decrypt. RSA keys are refused, because wrapping with one needs only its public key. - Give the API’s managed identity, or its workload identity on AKS, the role Key Vault Crypto User on that key.
- Set
Encryption:Kektoazure-key-vault,Encryption:KmsKeyto the key’s URL without a version (https://<vault>.vault.azure.net/keys/<name>), andEncryption:AzureClientIdwhen the identity is user-assigned. Rotating the key in the vault is safe: what an older version wrapped still opens.
Google Cloud KMS
Section titled “Google Cloud KMS”- Make a key ring in a regional location and a symmetric key in it; protection level HSM for FIPS 140 Level 3.
- Give the API’s service account
roles/cloudkms.cryptoKeyEncrypterDecrypteron that key only. - Set
Encryption:Kektogcp-kmsandEncryption:KmsKeyto the key’s name without a version:projects/<project>/locations/<location>/keyRings/<ring>/cryptoKeys/<key>.
None of these settings is a secret: the API reads only the key’s name, and its credentials come from the platform it runs on.
An Organization’s Own Key
Section titled “An Organization’s Own Key”A customer can have its organization’s data keys wrapped by a key in its own AWS KMS, Azure Key Vault or Google Cloud KMS, in place of the instance’s KEK. Withdrawing the key, or the grant on it, closes that organization’s sealed data within ten minutes, and no one else’s.
Operators give an organization its key in the platform console: see The platform console. The key is tried before it is saved, and the application uses it only while its record opens under the instance’s own KEK, so someone who can write to the database alone cannot point an organization at a key of theirs.
Encryption:CustomerKeys in the instance’s settings does the same, and wins for an organization it names: list each organization’s id, Kek and Key, and for Azure its AzureTenantId.
Moving the KEK, and Changing It
Section titled “Moving the KEK, and Changing It”Change the settings and restart the API. The old KEK stays in the instance’s ring, only to unwrap what it wrapped:
- moving from the key file: the file stays in the folder;
- moving from one key in a service to another: name the old one in
Encryption:EarlierKmsKeys.
The background re-encryption then rewraps every data key under the new KEK, within minutes; the log says how many. When it has finished, the old key can go.
The same background work re-seals values when an organization’s data key is rotated, in small batches, and turns the old data key off once nothing uses it. An operator rotates an organization’s data key in the platform console, under Keys, with a reason; see The platform console. The console’s audit records the rotation and each round of re-sealing.
When the Key Service Cannot Be Reached
Section titled “When the Key Service Cannot Be Reached”- Data keys unwrapped in the last day go on working, so the organizations in use carry on as usual.
- What needs a key this instance has not unwrapped lately, such as after a restart, answers
503 The encryption keys are not available. Nothing is half-written. - A key that is turned off, or a permission withdrawn, closes what it protects within ten minutes.
- A call that takes longer than five seconds counts as unreachable (
Encryption:KmsTimeLimit).
What to Back Up
Section titled “What to Back Up”- The database, with point-in-time recovery.
- The folder of keys, separately from the database, readable by the API’s account alone. Every API instance must share it. With the KEK in a key service the folder still holds the keys of stored credentials.
- The key service’s key is the service’s to keep. Never delete it while anything it wrapped may be restored from a backup.