SecLab
Cryptography & SecretswalkthroughDifficulty 3/526 min

Encryption at rest, and the question "against whom"

Objective: After this lesson you can say which layer of encryption stops which threat, and why disk encryption does not stop SQL injection.

V14V11A04:2025
Step 1 of 5 · read6 min

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:

LayerStopsDoes NOT stop
Disk encryption (LUKS, EBS encryption)Somebody taking the physical drive, or a copied snapshotAnything going through the running database
TDE / database-levelSomebody copying the data files or a backupA SQL query — including an attacker's
Application-levelThe DBA, whoever reads backups, and SQL injection tooAn 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 = @x does 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 salary column cannot be ORDER 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".

View path

Comments

Join the discussion
Sign up to comment

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.

Sign upSign in

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…