Notes
Envelope encryption
Cloud encryption uses envelope encryption, the pattern from Part four. The key management service holds master keys that never leave it. A data key encrypts the actual data locally and fast, and is wrapped by the master key and stored alongside the ciphertext. To read the data, the service unwraps the data key, and every unwrap checks the key policy and logs it. So every decryption is access-controlled and logged, the whole security value. The provider does this behind the encryption checkbox.
- KMS holds master keys; they never leave it
- a data key encrypts the data (fast, local)
- the data key is wrapped by the master key, stored with the data
- to read: ask KMS to unwrap, which checks policy and logs
- exactly the Part 4 pattern
Managed vs customer keys
You choose between two kinds of key. A provider-managed key is the default and easiest, but you have little control or visibility over it. A customer-managed key is one you create, where you set the policy and rotation and, crucially, can disable it. That last power matters: disabling the key instantly revokes the ability to decrypt all data it protects, a strong containment tool in an incident. For anything sensitive, use customer-managed keys, because control over the key is control over the data.
- provider-managed key: easy, but you have little control or visibility
- customer-managed key (CMK): you set the policy, rotation, and can disable it
- CMK lets you revoke access to data by disabling the key
- use CMKs for anything sensitive
Access is the control
The core lesson: the key policy, not the cryptography, is what protects the data. Nobody breaks AES; they get the permission to decrypt. Separate key administrators, who manage the key, from key users, who decrypt with it, so no single role does both. Grant decrypt with least privilege, to specific roles on specific keys, never on everything. And use encryption context, which is associated data, to bind a decryption to a particular resource or tenant. Access to the key is the real security boundary.
- the algorithm is unbreakable; the policy is the target
- who can use the key to decrypt?
- separate key admins from key users
- least privilege on kms:Decrypt; not on "*"
- encryption context binds a decrypt to a resource/tenant
Rotation
Rotation in the cloud is mostly automatic, but know its limits. Turn on automatic rotation and the service creates new key material on a schedule; the key identifier stays the same, and old material is retained so old data still decrypts, so your code changes nothing. But it does not re-encrypt existing data. That is fine for routine rotation. After an actual compromise it is not enough: you need a new key and must re-encrypt the data the old one protected. Routine rotation and incident response are different.
- turn on automatic rotation: new key material yearly (or faster)
- the key id stays the same; old material is kept to decrypt old data
- it does NOT re-encrypt existing data
- after a compromise: new key AND re-encrypt
- as in Part 4
What to encrypt
A practical approach to what you encrypt. Encrypt everything at rest, because it is nearly free and usually on by default. Reserve the stronger controls, customer-managed keys and tight policies, for the sensitive data: personal information, secrets, regulated records. Use separate keys per data classification and environment, so one key is never a single point of exposure. Encrypt in transit with TLS, and for the most sensitive fields consider field-level encryption in the app.
- encrypt everything at rest; nearly free, on by default
- customer-managed keys for sensitive data (PII, secrets, regulated)
- separate keys per data class and environment
- encrypt in transit too (TLS)
- field-level encryption for the most sensitive columns
Attacks on KMS
Attackers do not steal keys from the hardware; they abuse access. A compromised role with decrypt permission on every key is as good as holding the keys. In cloud ransom attacks, they schedule your key for deletion or re-encrypt data under a key they control, so you lose access entirely. The defences are least privilege on key use, the mandatory deletion waiting period so a scheduled deletion can be reversed, and alerts on key events like disable, delete and policy change.
- a compromised role with kms:Decrypt on * is as good as the keys
- ransom: schedule your key for deletion, or re-encrypt data under an attacker key
- disabling your key denies all access to that data
- defence: least privilege, deletion waiting period, alerts on key events
Common mistakes
Mistakes. Declaring data encrypted while nearly every role can decrypt it, so the encryption protects nothing. Using provider-managed keys for sensitive data, giving up control and the ability to revoke. Granting decrypt on all keys in a role. Not separating key admins from key users. No alerts on key deletion or policy changes, so a ransom attack is invisible until too late. And believing encryption stops a public-bucket leak, when an authorised read returns the decrypted data.
- "data is encrypted" but everyone can decrypt it
- provider-managed keys for sensitive data (no control)
- kms:Decrypt on * in a role
- key admins and users not separated
- no alerts on key deletion or policy changes
- thinking encryption stops a public bucket leak
Say it like this
In the interview: cloud encryption uses envelope encryption, where KMS master keys wrap data keys and every decryption is access-checked and logged. Encrypting data is easy, so the real question is who can decrypt. For sensitive data I use customer-managed keys, so I control policy and rotation and can disable the key to revoke access in an incident. The key policy, not the algorithm, is the control: separate key admins from users, grant decrypt with least privilege, and alert on key events.
- "Envelope encryption: KMS
- master keys wrap data keys, every decrypt checked and logged. For sensitive data I
- use customer-managed keys so I
- control policy, rotation and can disable them. The key
- policy, not the cipher, is the control: least privilege on decrypt, and alert on key events."