Part 5 of 9 · 1 min read
Secrets and keys
The lock is only as good as the place the key is kept.
A secret is a value that grants access: a password, an API key, a private key. BM's point about data at rest also covers secrets: if you encrypt a database because you fear it will be stolen, and then store the key in the same database, you gained almost nothing. Keys should live elsewhere. BM names two options: a separate security appliance that encrypts and decrypts, or a separate key vault that the service asks when it needs a key. These systems also handle the key life cycle, which means creating, rotating and revoking keys and controlling who may change them. Some databases offer built-in encryption, and BM says to check how those keys are handled and whether the threat is really covered.
Common practice (not from the books): do not put secrets in source code, container images or log files. Pass them to the service at start-up from a secrets store, give each service access only to the secrets it needs, and rotate them on a schedule and after any suspected leak. Logging also needs care. BM says sensitive information must be removed from logs, or the logs themselves become a target (module 3).
Common mistake
Committing a key or password to the code repository. It stays in history, is copied to every clone, and cannot be quietly taken back.
Check yourself: 1. Why not store the encryption key beside the encrypted data? 2. What does a key vault manage besides storage? 3. Why must logs be cleaned of sensitive data?