Skip to content

Lesson 12 of 14 · 15m

KMS: Who Can Decrypt Is the Real Security Boundary

Envelope encryption means useToDecrypt turns storage reads into plaintext — split encrypt, decrypt, and admin across principals.

What the key actually protects

Cloud storage encryption is envelope encryption: your data is encrypted by a data encryption key; the DEK is wrapped by a key encryption key held in KMS. The service does the wrapping silently — GCS encrypts each object's DEK under the bucket's KEK, for instance. So the security question is never "is the bucket encrypted" — it always is — but "whose KEK, and who can unwrap."

On GCP, that permission is cloudkms.cryptoKeyVersions.useToDecrypt. Whoever holds it converts ciphertext access into plaintext. roles/storage.objectViewer plus useToDecrypt means encryption at rest is a formality. The role split exists for precisely this reason: roles/cloudkms.cryptoKeyEncrypter, cryptoKeyDecrypter, cryptoKeyEncrypterDecrypter, and cloudkms.admin are separate roles — the administrator manages keys but cannot encrypt or decrypt with them. The service writing backups gets encrypt; the restore path gets decrypt; the operator gets admin. Three principals, no overlap, and the composition nobody should hold.

Key rings and the destroy window

Keys live in key rings pinned to a location — a key cannot leave its ring or region, so plan rings per environment up front rather than retrofitting. Rotation (rotationPeriod) affects only new encryptions; old ciphertext still decrypts under old versions until the versions are destroyed. destroyScheduledDuration — 24 hours by default, configurable up to 120 days — is the window between "schedule destroy" and "cryptographically gone."

That window is a double-edged feature. Deliberate destruction is crypto-shredding: destroy the only versions holding a ciphertext and the data is unrecoverable by anyone, including you — the cleanest deletion-compliance mechanism in either cloud. Careless destruction of a version still wrapping live data is an outage you caused yourself. On data that matters, lengthen the window and rehearse the destroy path.

Three more tools in the box. Asymmetric keys serve asymmetricSign — workloads sign while the private half never leaves KMS. Key Access Justifications, paired with EKM, attach a stated reason to every decrypt you can approve or deny — visibility into why, not just who. And BYOK import jobs let you bring keys generated on your own HSM for the regulated cases where "the provider generated the key" is itself the objection.

CMEK, and what you're actually buying

Google-managed keys mean the provider's key hierarchy and the provider's IAM are your boundary — fine for most data. Customer-managed encryption keys move the boundary to your key ring's IAM and buy you the kill switch: revoke useToDecrypt or destroy the versions and every ciphertext under the key dies on your word, not the provider's. The costs are explicit — rotation discipline is now yours, region pinning constrains architecture, every dependent service must support CMEK, and external key management (EKM, hold-your-own-key) adds latency plus a dependency whose outage becomes your outage.

Azure's equivalents land in the same vault you already learned: Key Vault keys with Key Vault Crypto Officer (manage) versus Key Vault Crypto User (use), Managed HSM when you need FIPS 140-3 Level 3, and Customer Lockbox gating Microsoft's own support access to subscriptions.

The wrong model is "CMEK everywhere for compliance theater." CMEK buys control and revocability, not more encryption — the data was already encrypted. Pay the ops cost where a revoke or an audited destruction actually matters: regulated data, customer data, anything you'd need to kill on demand.

Land it

Split encrypt, decrypt, and admin across principals. Key ring per environment. Destroy windows sized to the data's real recovery needs. Monitor Decrypt and useToDecrypt calls in audit logs — decrypts are the money events. And rehearse restore under key revocation before the incident, not during it. Azure's per-key equivalent is az keyvault key rotation-policy — same discipline, different name.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.