What KMS encryption does
Request logs keep the prompts your applications send and the responses the models return, and each session keeps its memory of the conversation. With KMS encryption on, this content is encrypted under a data key that belongs to your organization alone. The data key is generated by AWS Key Management Service (KMS) and stored only in wrapped form: it can be unwrapped only by the KMS key it was made with.
You choose that KMS key:
- ModelRiver-managed key: ModelRiver's KMS key wraps your organization's data key. Nothing to set up in AWS.
- Your own key: a KMS key in your AWS account wraps it. You decide who can use the key, see every use in AWS CloudTrail, and can revoke ModelRiver's access at any time.
Token counts, timings, models, prices and other request metadata are not affected.
KMS encryption is available on the Enterprise plan. Owners and admins can see the settings; only the owner can change them.
Turn it on
Open the organization menu, select Organization settings, then KMS encryption under Security.
- Choose ModelRiver-managed key or Your own key.
- For your own key, enter its ARN and add the key policy statements the page shows (see below).
- Select Turn on KMS encryption.
New request logs and session memory are encrypted with your organization's data key straight away. Those stored before are re-encrypted in the background, and the page shows how many are left. Cached responses are cleared once, so the next identical request goes to the provider.
Use your own key
Your key is an AWS KMS key. Keys in Google Cloud KMS and Azure Key Vault are available on request; other key managers can't be used. An AWS key must be a symmetric encryption key (SYMMETRIC_DEFAULT, key usage ENCRYPT_DECRYPT) and enabled. To create one, see Set up your own key in AWS.
Before you save, add the statements shown under Key policy statements to the key's policy. Copy them from the page: they name ModelRiver's role and your organization's id. They let ModelRiver:
- create and unwrap data keys (
kms:GenerateDataKey,kms:Decrypt), only when the encryption context carries your organization's id (kms:EncryptionContext:org_id); - check that the key is enabled and of the right type (
kms:DescribeKey).
Because of the organization id condition, another organization that enters your key's ARN is refused by AWS KMS.
When you save, ModelRiver checks the key: that it exists, is enabled, is the right type, and that it can create and unwrap a data key with your organization's context. If a check fails, the message under the ARN field says which permission or setting is missing, and nothing is changed.
Set up your own key in AWS
Create the key in the AWS account that should own it. Its policy needs the two statements shown under Key policy statements when you choose Your own key: they name ModelRiver's role and your organization's id, so copy those values from the page, not from this guide. Below, MODELRIVER_ROLE_ARN and YOUR_ORG_ID stand for them.
Keep your own access to the key as well: every example keeps the statement that lets IAM in your account manage the key. A key policy without it can lock you out.
AWS console
- Open AWS KMS in the region you want the key in, then Customer managed keys → Create key.
- Choose Symmetric and Encrypt and decrypt. Leave the advanced options at their defaults (KMS key material, single-Region key).
- Give it an alias, such as
modelriver-request-logs, and choose your key administrators. - On the review step, edit the key policy: add the two statements from the page to its
Statementlist, after the existing ones. - Create the key, then turn on Automatic key rotation on its Key rotation tab.
- Copy the key's ARN (
arn:aws:kms:<region>:<account>:key/<id>) into KMS key ARN and save.
For a key you already have, open it, select Key policy → Edit, and add the two statements.
AWS CLI
Save the key policy as key-policy.json, with your account id in the first statement:
1{2 "Version": "2012-10-17",3 "Statement": [4 {5 "Sid": "EnableIAMUserPermissions",6 "Effect": "Allow",7 "Principal": { "AWS": "arn:aws:iam::111122223333:root" },8 "Action": "kms:*",9 "Resource": "*"10 },11 {12 "Sid": "ModelRiverDescribeKey",13 "Effect": "Allow",14 "Principal": { "AWS": "MODELRIVER_ROLE_ARN" },15 "Action": "kms:DescribeKey",16 "Resource": "*"17 },18 {19 "Sid": "ModelRiverRequestLogs",20 "Effect": "Allow",21 "Principal": { "AWS": "MODELRIVER_ROLE_ARN" },22 "Action": ["kms:GenerateDataKey", "kms:Decrypt"],23 "Resource": "*",24 "Condition": { "StringEquals": { "kms:EncryptionContext:org_id": "YOUR_ORG_ID" } }25 }26 ]27}Then create the key, turn on rotation and give it an alias:
aws kms create-key --description "ModelRiver request logs" --key-spec SYMMETRIC_DEFAULT --key-usage ENCRYPT_DECRYPT --policy file://key-policy.jsonaws kms enable-key-rotation --key-id <key id from the output>aws kms create-alias --alias-name alias/modelriver-request-logs --target-key-id <key id>create-key prints the key's Arn. For a key you already have, read its policy with aws kms get-key-policy --key-id <key id> --policy-name default, add the two statements, and write it back with aws kms put-key-policy --key-id <key id> --policy-name default --policy file://key-policy.json.
Terraform
1variable "modelriver_role_arn" { type = string }2variable "modelriver_org_id" { type = string }3 4data "aws_caller_identity" "current" {}5 6resource "aws_kms_key" "modelriver" {7 description = "ModelRiver request logs"8 enable_key_rotation = true9 10 policy = jsonencode({11 Version = "2012-10-17"12 Statement = [13 {14 Sid = "EnableIAMUserPermissions"15 Effect = "Allow"16 Principal = { AWS = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root" }17 Action = "kms:*"18 Resource = "*"19 },20 {21 Sid = "ModelRiverDescribeKey"22 Effect = "Allow"23 Principal = { AWS = var.modelriver_role_arn }24 Action = "kms:DescribeKey"25 Resource = "*"26 },27 {28 Sid = "ModelRiverRequestLogs"29 Effect = "Allow"30 Principal = { AWS = var.modelriver_role_arn }31 Action = ["kms:GenerateDataKey", "kms:Decrypt"]32 Resource = "*"33 Condition = { StringEquals = { "kms:EncryptionContext:org_id" = var.modelriver_org_id } }34 }35 ]36 })37}38 39resource "aws_kms_alias" "modelriver" {40 name = "alias/modelriver-request-logs"41 target_key_id = aws_kms_key.modelriver.key_id42}43 44output "modelriver_kms_key_arn" {45 value = aws_kms_key.modelriver.arn46}CloudFormation
1Parameters:2 ModelRiverRoleArn:3 Type: String4 ModelRiverOrgId:5 Type: String6 7Resources:8 ModelRiverKey:9 Type: AWS::KMS::Key10 Properties:11 Description: ModelRiver request logs12 EnableKeyRotation: true13 KeyPolicy:14 Version: "2012-10-17"15 Statement:16 - Sid: EnableIAMUserPermissions17 Effect: Allow18 Principal:19 AWS: !Sub arn:aws:iam::${AWS::AccountId}:root20 Action: kms:*21 Resource: "*"22 - Sid: ModelRiverDescribeKey23 Effect: Allow24 Principal:25 AWS: !Ref ModelRiverRoleArn26 Action: kms:DescribeKey27 Resource: "*"28 - Sid: ModelRiverRequestLogs29 Effect: Allow30 Principal:31 AWS: !Ref ModelRiverRoleArn32 Action:33 - kms:GenerateDataKey34 - kms:Decrypt35 Resource: "*"36 Condition:37 StringEquals:38 kms:EncryptionContext:org_id: !Ref ModelRiverOrgId39 40 ModelRiverKeyAlias:41 Type: AWS::KMS::Alias42 Properties:43 AliasName: alias/modelriver-request-logs44 TargetKeyId: !Ref ModelRiverKey45 46Outputs:47 KeyArn:48 Value: !GetAtt ModelRiverKey.ArnRevoke ModelRiver's access
Remove the two ModelRiver statements from the key policy, or disable the key. ModelRiver can no longer read your organization's request logs within 5 minutes: see If your key becomes unavailable. To stop using your key without losing access to stored request logs, change to ModelRiver's key first and wait until the page shows nothing left to re-encrypt.
Your own key in Google Cloud KMS or Azure Key Vault
Available on request. Google Cloud KMS and Azure Key Vault keys are not on by default, for any plan. Contact [email protected] and we turn the option on for your organization; until then the page offers AWS KMS only, and the sections below don't apply.
When it is on, Your own key on the KMS encryption page asks which cloud the key is in. You choose Google Cloud KMS or Azure Key Vault, enter the key's reference, and run the commands the page shows (they carry your organization's id and ModelRiver's identity, so copy them from the page). ModelRiver reaches your key through workload identity federation: there is no key file, secret or password to give us, and nothing to rotate on your side.
For both clouds:
- The key must carry the label (Google) or tag (Azure)
modelriver-org-idwith your organization's id as its value. ModelRiver checks it when you save and every time it checks the key's health. A key without it, or with another organization's id, is refused with the same message as a key ModelRiver can't reach, so another organization can't use your key by entering its name. - When you save, ModelRiver checks that the key is yours, is enabled and of the right type, and that it can wrap and unwrap a data key with your organization's context. If a check fails, the message under the key field says what to fix, and nothing is changed.
- Change key, rotate and turn off work as above. You can switch between AWS, Google, Azure and ModelRiver's key; keep the previous key usable until the page shows nothing left to re-encrypt.
- If staff later turn the option off, keys already in use keep working; only new setups are hidden.
Set up your own key in Google Cloud KMS
The key must be a symmetric key (purpose ENCRYPT_DECRYPT, algorithm GOOGLE_SYMMETRIC_ENCRYPTION). Software, HSM and external keys in any location work. Enter its name without a version: projects/<project>/locations/<location>/keyRings/<key ring>/cryptoKeys/<key>.
Below, <organization id> and <modelriver service account> are the values the page shows. (Commands untested here; run them in your project.)
# A key ring and a symmetric key, labelled with your organization idgcloud kms keyrings create <key ring> --location <location>gcloud kms keys create <key> --keyring <key ring> --location <location> \ --purpose encryption --labels modelriver-org-id=<organization id> # Let ModelRiver encrypt and decrypt with the key, and read its settingsgcloud kms keys add-iam-policy-binding <key> --keyring <key ring> --location <location> \ --member serviceAccount:<modelriver service account> \ --role roles/cloudkms.cryptoKeyEncrypterDecryptergcloud kms keys add-iam-policy-binding <key> --keyring <key ring> --location <location> \ --member serviceAccount:<modelriver service account> \ --role roles/cloudkms.viewerThe first role lets ModelRiver wrap and unwrap the data key; the second lets it read the key's labels and state to check ownership and health. Both are granted on this key only. To revoke access, remove the bindings or disable the key's primary version.
Set up your own key in Azure Key Vault
The key must be an RSA key (RSA or RSA-HSM) of 3072 bits or more, enabled, with the operations wrapKey and unwrapKey, in a standard or premium vault on the public cloud (<vault>.vault.azure.net). Enter the key's identifier with its version: https://<vault>.vault.azure.net/keys/<name>/<version>. ModelRiver wraps with that version: when you create a new key version in Azure, enter it and save to move to it. ModelRiver also checks that the vault belongs to the tenant it was saved with.
Below, <organization id> and <modelriver application id> are the values the page shows. (Commands untested here; run them in your subscription.)
# An RSA key of 3072 bits, tagged with your organization idaz keyvault key create --vault-name <vault> --name <key> --kty RSA --size 3072 \ --ops wrapKey unwrapKey --tags modelriver-org-id=<organization id> # Add ModelRiver's application to your tenantaz ad sp create --id <modelriver application id> # Vault with Azure RBAC: get, wrap and unwrap on this key onlyaz role assignment create --role "Key Vault Crypto Service Encryption User" \ --assignee <modelriver application id> \ --scope "$(az keyvault show --name <vault> --query id -o tsv)/keys/<key>" # Vault with access policies insteadaz keyvault set-policy --name <vault> --spn <modelriver application id> \ --key-permissions get wrapKey unwrapKey # The identifier to enter on the pageaz keyvault key show --vault-name <vault> --name <key> --query key.kid -o tsvThe tag is on the key version ModelRiver wraps with, so tag a new version when you create one. To revoke access, remove the role assignment or policy, or disable the key.
Until a key is saved, ModelRiver gives one answer for every reason it can't use it (the application isn't in your tenant yet, the role or tag is missing, the key doesn't exist), so the page can't be used to find out which other tenants use ModelRiver. If you add the application after a failed check, wait a minute before you try again: ModelRiver remembers a refused sign-in to a tenant for that long.
Change the key, rotate, or turn it off
- Change key: opens the key choice again, to switch between ModelRiver's key and your own, or enter another ARN. Stored request logs are re-encrypted under the new key in the background.
- Rotate data key: creates a new data key under the same KMS key and re-encrypts stored request logs with it. AWS KMS rotates the KMS key itself, when you turn on automatic rotation for your key.
- Turn off: stored request logs are moved back to ModelRiver's standard encryption in the background.
Keep the previous KMS key enabled, and its policy in place, until the page shows no request logs left to re-encrypt. Request logs still on a key that can no longer be used can't be read or moved. The page counts them, and they are moved once the key works again.
If your organization leaves the Enterprise plan, KMS encryption is turned off and its request logs are moved back to ModelRiver's standard encryption.
If your key becomes unavailable
If you disable or delete your key, or change its policy so that ModelRiver can no longer use it, ModelRiver stops being able to read your organization's stored request logs within 5 minutes.
- Requests keep working. ModelRiver still serves every request and keeps its metadata.
- New request logs are kept without their content. Their content is never stored in plain text or under another key. The log viewer shows "Content not stored: the KMS key was unavailable".
- Stored request logs show "Your organization's KMS key is unavailable" instead of their content, in the console's log viewer and in request log downloads.
- Organization owners get an email when the key stops working, and another when it works again. The KMS encryption settings show the reason.
Turn the key back on, or restore its policy, and stored content can be read again within minutes. Content that was not stored while the key was unavailable can't be recovered.
Who can see and change it
| Action | Owner | Admin | Editor or viewer |
|---|---|---|---|
| See whether KMS encryption is on, and the key in use | Yes | Yes | No |
| Turn it on or off, change the key, rotate | Yes | No | No |
Every change is recorded in the audit log, with who made it and which key it used.