Permissions: applications and administration
Without a keyring, the principals that write values and the ones that only read them differ in their KMS rights, see With kms-aead alone. A keyring adds an administration side that builds with another feature, calls another handle and writes the keyring store, and the sections below give each side its checklist and its rights.
Two sides of a keyring
A keyring has two sides, each with its own handle and its own rights:
- the application decrypts and runs sweeps on a
Keyring, whichKeyringRegistry::openreturns in every build, and encrypts, computes beacons and re-encrypts on theEncryptortheKeyringhands out for each write; - the administration creates keyrings, rotates, promotes, retires and destroys versions, flags
compromised ones, re-encrypts DEKs, exports keysets and shreds keyrings, on a
KeyringAdmin, whichKeyringRegistry::create,open_or_createandadminreturn with theadminfeature.
The application builds without the admin feature and runs under a principal with the rights of
its row only:
| Side | Handle | KMS | Keyring store |
|---|---|---|---|
| Application | Keyring | decrypt | read, and listen or watch |
| Administration | KeyringAdmin | encrypt and decrypt, or under an asymmetric KEK decrypt and read of the public key | read, write and delete |
Sweeps run on the application’s side: re-encrypting a value encrypts it under a DEK the record
already holds, and never asks the KMS to encrypt a DEK. Every call that encrypts a DEK, writes
or deletes the record is a KeyringAdmin call. The exact roles per KMS are in
KMS rights, and the permissions per store in
Store rights.
The admin feature keeps the administrative calls out of the application’s build, and the rights
keep them out of its reach: without the KMS encrypt right and write access to the store, those
calls fail in any build.
An application opens only keyrings that exist: open on a keyring the store holds no record of
fails with KeyringError::RecordMissing. So the administration creates each keyring before an
application opens it:
- from infrastructure: a job, a CLI or a deployment step, built with the
adminfeature and run with the administrative rights, callscreateoropen_or_create; - or from an application that provisions lazily, such as one keyring per tenant on the tenant’s
first request. Such an application enables
adminand is given the administrative rights deliberately, and is then trusted as the administration is, see Keyring limits and Creating the keyrings.
An application’s own tests that create keyrings in MemoryKeyringStore enable admin for the
tests only:
[dependencies]
kms-aead-keyring = { version = "0.34", features = ["ring", "firestore-tls-roots"] }
[dev-dependencies]
kms-aead-keyring = { version = "0.34", features = ["ring", "firestore-tls-roots", "admin"] }
The application
- builds without the
adminfeature, withcargo build -p <application>: Cargo unifies the features of the packages one command builds, so acargo buildof a workspace with both the application and an administrative job gives the applicationadmintoo; - calls
KeyringRegistry::open, and on theKeyringit returnsencryptor,decrypt, the beacons and the probes, and runs the sweeps. None of its calls asks the KMS to encrypt; - runs as a principal with KMS decrypt on the KEK and read access to the keyring store, listen included, see KMS rights and Store rights;
- where records are signed, opens its registry with
RecordSignaturePolicy::Requiredand the public key of the record signer, from its configuration and never from the store, see Protect the keyring record; - awaits
registry.shutdown(None)before it exits.
The administration
- builds with the
adminfeature, andbigquery-exportwhere it exports BigQuery keysets; - calls the registry’s
createoropen_or_createfor each new keyring, andadmin, and on theKeyringAdminthey return the lifecycle calls (rotate,promote,change_algorithm,mark_compromised,retire,reinstate,destroyanddangerously_destroy_all_versions),dangerously_shred,reencrypt_deksand the keyset exportsexport_bigquery_keysetandexport_tink_keyset, see Key versions and lifecycle; - runs in a job or in infrastructure automation, never in a request handler, as the only principal with KMS encrypt and decrypt on the KEK, or under an asymmetric KEK decrypt and the read of the public key and no encrypt right, and with write access to the keyring store;
- holds the record signer where records are signed: a
Signeron a KMS signing key, with the right to sign and no other principal holding it, passed tocreate_signed,open_or_create_signedorwith_record_signer, see Protect the keyring record; - logs every call it makes, since a version its log does not show is the start of A version the administrative job did not create;
- opens its registry with the longest
record_ttlin the fleet, which the promotion guard waits.
KMS rights
A keyring record is signed only where the administration holds a record signer, see Signing the keyring record and Keyring deployment, so a deployment splits the two sides above into two principals.
With kms-aead alone
An envelope that writes needs KMS encrypt on the KEK: one encryption per value with a per-call envelope, and one per renewed DEK with store-less DEK reuse. An envelope that reads needs KMS decrypt, on every DEK cache miss. A principal that does both needs both, and so does a re-encryption of stored DEKs, see Re-encrypt DEKs after a KEK rotation. The local KMS has no rights to grant.
| KMS | Writer: encrypt | Reader: decrypt |
|---|---|---|
| GCP | cloudkms.cryptoKeyVersions.useToEncrypt | cloudkms.cryptoKeyVersions.useToDecrypt, as in roles/cloudkms.cryptoKeyDecrypter |
| AWS | kms:Encrypt on the key | kms:Decrypt on the key |
| Azure Key Vault | keys/wrap/action on the key | keys/unwrap/action on the key |
| Vault Transit | update on <mount>/encrypt/<key> | update on <mount>/decrypt/<key> |
roles/cloudkms.cryptoKeyEncrypterDecrypter carries both GCP permissions. With the KMS random
generator on, the writer also needs cloudkms.locations.generateRandomBytes on the location under
GCP, and kms:GenerateRandom under AWS. See the page of each provider in
KMS providers.
With a keyring
The rights of the two sides, per KMS:
| KMS | Application | Administration |
|---|---|---|
| GCP | roles/cloudkms.cryptoKeyDecrypter | roles/cloudkms.cryptoKeyEncrypterDecrypter |
| AWS | kms:Decrypt on the key | kms:Encrypt and kms:Decrypt on the key, plus kms:GenerateRandom with the KMS random generator |
| Azure Key Vault | a role with keys/unwrap/action on the key | a role with keys/wrap/action and keys/unwrap/action on the key |
| Vault Transit | update on transit/decrypt/<key> | update on transit/encrypt/<key> and transit/decrypt/<key> |
Under an asymmetric KEK
Under an asymmetric KEK the public key encrypts new DEKs in the administration’s own process, so no
side has the KMS encrypt right: Cloud KMS useToEncrypt, AWS kms:Encrypt, Key Vault
keys/wrap/action and Transit transit/encrypt leave the administration’s grant. The
administration needs the read of the public key beside the applications’ decrypt:
| KMS | Application | Administration |
|---|---|---|
| GCP | cloudkms.cryptoKeyVersions.useToDecrypt, as in roles/cloudkms.cryptoKeyDecrypter | decrypt, and cloudkms.cryptoKeyVersions.viewPublicKey, as in roles/cloudkms.publicKeyViewer |
| AWS | kms:Decrypt on the key | kms:Decrypt and kms:GetPublicKey on the key |
| Azure Key Vault | keys/unwrap/action | keys/unwrap/action and keys/get |
| Vault Transit | update on transit/decrypt/<key> | update on transit/decrypt/<key>, and read on transit/keys/<key> or transit/export/public-key/<key> |
Two built-in roles fall short of what the administration needs:
roles/cloudkms.cryptoKeyDecrypterdoes not carryviewPublicKey;- Azure’s “Key Vault Crypto Service Encryption User” carries read,
wrapandunwrapand no decrypt.
The KMS audit log does not show who encrypted a DEK, since the encryption is local, and anyone
holding the public key can encrypt one: a keyring under an asymmetric KEK runs with
RecordSignaturePolicy::Required on every application, see
Keyrings under an asymmetric KEK. The
public_key call of each provider is in KMS providers.
The permissions of each store are below.
Store rights
The store’s access control is what the record’s integrity rests on, unless the record is signed: only the administration writes the record, and the applications read it and listen to its changes, see above:
| Store | Application | Administration |
|---|---|---|
| Firestore | read of the keyring documents, which the listener uses too, such as roles/datastore.viewer | read, write and delete of the keyring documents, such as roles/datastore.user |
| PostgreSQL | SELECT on the table, and LISTEN, which needs no grant | SELECT, INSERT, UPDATE and DELETE on the table; each write and delete also sends the NOTIFY |
| Cloud Storage | storage.objects.get | storage.objects.get, storage.objects.create and storage.objects.delete, since a write replaces the object |
| S3 | s3:GetObject | s3:GetObject and s3:PutObject |
dangerously_shred() needs more of the administration on the object stores:
| Store | Also needed |
|---|---|
| Cloud Storage | storage.objects.list, to find the object’s generations |
| S3 | s3:ListBucketVersions, s3:DeleteObject and s3:DeleteObjectVersion |
What to alert on
Each side logs events an operator acts on, such as a refused record, a failed revalidation or a
re-encryption that failed, and records metrics with the opentelemetry feature. The list, with the
next step for each, is in Monitoring and alerts.