Case FF5790 · Cryptography · L3 Applied
Encrypting Sensitive Database Fields
Interview questionWe store national ID numbers in Postgres and TDE is already on. Is that enough, and if not, what would you build?
- 01 Answer
- 02 Example
- 03 Trade-offs
What a strong answer covers
Try it out loud first. Then check yourself:
- TDE and disk encryption only stop stolen media or backups; SQL injection, app compromise and DBAs still see plaintext.
- App-layer AEAD with envelope keys from KMS; bind row ID and column as associated data so ciphertexts cannot be swapped.
- Search: an HMAC blind index with a separate key gives equality lookups; deterministic encryption leaks equality and frequency.
- Alternative: a tokenization vault removes the data from most systems entirely, shrinking compliance scope at a latency cost.
- Trade-offs: no range queries or LIKE, key rotation needs re-encryption jobs, and KMS access logs become your audit trail.
If the interviewer pushes back
- A low-entropy field like a 9-digit ID makes the blind index brute-forceable if its key leaks. How do you reduce that risk?