Technical Article

Envelope Encryption in Object Storage

A private storage bucket resolves storage-level access control, but it does not ensure application-level data confidentiality. If cloud IAM policies, operational credentials, or storage buckets are misconfigured or compromised, "private" quickly ceases to provide an adequate security boundary.

When handling sensitive or regulated data, architectures must explicitly decouple three distinct concerns:

  1. Who has permission to access the storage container or raw object?
  2. How is the underlying payload encrypted at rest?
  3. Who manages and controls the keys capable of decrypting ciphertext back into plaintext?

The Mechanics of Envelope Encryption

A standard pattern for scalable confidentiality is envelope encryption:

  • Each object is encrypted with a unique, randomly generated Data Encryption Key (DEK) using authenticated encryption (such as AES-256-GCM).
  • The DEK is itself encrypted using a Key Encryption Key (KEK) managed by a Key Management Service (KMS, such as AWS KMS or HashiCorp Vault).
  • Only the encrypted DEK (ciphertext key) is persisted alongside the file payload, while the plaintext DEK is securely discarded from memory immediately after encryption.

Alongside the encrypted payload, the application stores only the metadata required to decrypt the file upon authorized retrieval:

  • The encrypted DEK (ciphertext key).
  • The initialization vector (IV) or nonce.
  • The authentication tag verifying payload integrity.
  • The KMS key identifier and version.

The cryptographic material capable of unlocking the payload never resides in unencrypted form within the object storage bucket.

Efficient Key Rotation and Cryptographic Erasure

This cryptographic hierarchy simplifies operational lifecycle management:

  • Fast Key Rotation: When rotating the master key (KEK), the system only needs to re-encrypt the small wrapped DEKs stored in metadata. There is no need to download, decrypt, re-encrypt, and upload gigabytes or terabytes of historical objects.
  • Cryptographic Erasure: Deleting the wrapped DEK or revoking KMS key permissions renders the underlying file irrecoverable, even if an attacker retains a copy of the raw ciphertext.

Defense in Depth: Threat Modeling

Clear threat modeling remains vital: leaking a raw bucket object will not reveal confidential data, but an attacker who compromises both the application layer and its KMS decryption permissions can still decrypt ciphertext.

Therefore, encryption never replaces access authorization; it provides defense in depth. The real architectural benefit lies in making security boundaries explicit:

  • Object Storage enforces binary read and write access.
  • Application Logic enforces domain authorization and payload validation.
  • Key Management controls the cryptographic authority to decrypt.

When each layer has an unambiguous, single responsibility, the entire security posture becomes measurably simpler to audit and verify.