This article delves into the critical system design challenge of securely managing shared secrets among multiple administrators without compromising security or operational efficiency. It highlights the pitfalls of naive approaches and presents envelope encryption as a robust solution. The core of the solution is a two-tier key hierarchy that allows individual admins to unlock a master secret using their unique credentials, decoupling authentication from the master secret's lifecycle.
Read original on Dev.to #architectureManaging sensitive secrets like database passwords or API keys in a growing team presents significant security and operational hurdles. Traditional methods, such as sharing a single password or storing it in a basic vault, lead to issues like lack of auditability, difficult revocation of access, and a high operational burden when a secret needs to be rotated or an admin leaves the team. A robust system requires multiple administrators to access a shared secret using their *individual* credentials, with no plaintext exposure of the master secret and efficient admin lifecycle management (adding/removing).
Envelope encryption provides an elegant solution by introducing a two-tier key hierarchy. Instead of directly encrypting the master secret with individual admin passwords, a randomly generated data key is used. This data key encrypts the master secret once. Then, each administrator's derived key (from their unique password) encrypts a *copy* of this data key. This architecture ensures that the master secret is never directly exposed to admin passwords and facilitates independent management of admin access.
Key Benefits of this Design
Revocation: Removing an admin only requires deleting their encrypted data key. The master secret and other admins' access remain unaffected. Adding Admins: New admins generate their derived key and encrypt a copy of the existing data key. The master secret does not need to be present in plaintext. Security: The master secret and data key are never stored in plaintext. Individual admin passwords do not directly encrypt the master secret, enhancing security.