Three layers, three different threats
"Our data is encrypted at rest" is an answer to an audit question, and it usually does not answer the real one: who does that encryption stop?
Three layers, each stopping exactly one threat:
| Layer | Stops | Does NOT stop |
|---|---|---|
| Disk encryption (LUKS, EBS encryption) | Somebody taking the physical drive, or a copied snapshot | Anything going through the running database |
| TDE / database-level | Somebody copying the data files or a backup | A SQL query — including an attacker's |
| Application-level | The DBA, whoever reads backups, and SQL injection too | An attacker already running code inside the application |
The most important and most misread point: disk encryption and TDE are transparent to every query. The database decrypts on read, so a SELECT * FROM users returns plaintext — whether that query is yours or an attacker's arriving through SQL injection. Those two layers stop losing the device, not losing access.
Which means if the threat you are worried about is "an application bug leaks card numbers", disk encryption contributes nothing, and only application-level encryption contributes.
But application-level encryption has three genuine costs, and they are why you should not encrypt everything:
- You cannot search it.
WHERE email = @xdoes not work on an encrypted column. To search you must store an additional HMAC column of the value (not a plain hash, since a keyless hash is dictionary-attackable) for exact matching. Partial matching is not possible. - You cannot sort or range-compare. An encrypted
salarycolumn cannot beORDER BY-ed. - Key management becomes your problem. And that is a harder problem than the encryption.
So the practical question is not "is it encrypted" but "which columns, against whom, and what are we giving up".
Comments
Commenting needs an account with at least one completed lesson. That condition is what keeps this thread worth reading: every point belongs to someone who can be asked back, and reputation accrues over time.
You can still read every comment below without an account. Signing in brings you back to this exact spot, not to the top of the page.
Loading comments…