Control 01
The problem
A database that holds PII in clear text is a risk. Security compliance requires PII to be encrypted at rest, and requires the keys to change over time.
Control 02
What I built
An encryption layer between the application and its storage. The application sends records as before. The layer finds the PII fields and encrypts them before they are written.
Control 03
Key rotation
Keys rotate on a schedule with no manual step. A team needs no runbook, and nobody has to remember to rotate.
Control 04
Design choices
Only PII fields are encrypted, so other columns stay fast to query. Keys are stored apart from the data, so a stolen database dump cannot be decrypted. Each value records which key version encrypted it, so old and new keys work together while data moves to the new key.
Control 05
Trade-offs
An encrypted field cannot be searched with a plain LIKE query. Where search is needed, a separate lookup value can be stored next to the field. Each field needs a decision on whether the search is worth that cost.
What I learned
A control that runs on its own keeps working.
Key rotation is easy to plan and easy to skip. When a person has to remember it, it slips in the month with a deadline.
I made rotation a scheduled job with no manual step, so compliance no longer depends on anyone's memory. I now ask of every control what happens in a month when nobody remembers it.