Web Security & OWASP (50 Qs)•Part 3: Authentication, Authorization & Cryptographic Standards (26 - 35)
Envelope Encryption & Key Management: Data Encryption Keys (DEK) vs. Key Encryption Keys (KEK).
The Envelope Encryption Architecture
Encrypting terabytes of application data directly with a central cloud Key Management Service (AWS KMS or HashiCorp Vault) is slow, expensive, and subject to API rate limits. Cloud architectures solve this using Envelope Encryption.
ini
1. Generate Keys via KMS:
[ App calls kms:GenerateDataKey ] ---> [ AWS KMS ]
|
[ App receives two keys: ] <---------------+
- Plaintext DEK (Data Encryption Key)
- Encrypted DEK (CiphertextBlob encrypted by Master KEK)
2. Encrypt Data Locally:
[ Plaintext Data (Large File) ] + [ Plaintext DEK ] ---> [ AES-256-GCM ]
|
v
[ Encrypted Data File ]
3. Security Critical Step:
WIPE Plaintext DEK from RAM memory!
Store the Encrypted DEK alongside the Encrypted Data File in S3/Database.
Why Envelope Encryption is Resilient
- Even if an attacker steals the encrypted file and the encrypted DEK from your database, they cannot decrypt the data without having explicit IAM permissions to call
kms:Decrypton the master Key Encryption Key (KEK). - When rotating keys, you only rotate the root KEK in KMS; you never have to re-encrypt petabytes of existing historical database records.