Insights / Encryption

Encryption at rest, in transit and in use: what each one actually protects

When someone says data is "encrypted", the useful follow-up questions are: where, against which attacker, and who holds the keys. Each type of encryption defends against a different threat, and none of them covers everything.

In transit

TLS protects data moving between a client and a server, and between your own services. It defends against eavesdropping and tampering on the network. It does nothing once the data has arrived: the receiving system holds it in the clear.

  • Use TLS 1.2 or later, and prefer 1.3.
  • Enable HSTS on public sites so browsers never fall back to plain HTTP.
  • Encrypt internal traffic too (service-to-service TLS or mutual TLS). "Inside the network" is not a security boundary.

At rest

Disk, volume and database encryption protect against stolen drives, lost backups and leaked snapshots. They do not protect against someone who has valid application or database credentials: the database decrypts the data for them automatically. It is a baseline, and a very worthwhile one, but it answers a narrow threat.

Application-level and field-level

For your most sensitive fields, encrypt in the application with keys the database never sees. Now a compromised database, a curious administrator or a leaked backup yields ciphertext. The trade-off is that you cannot easily search or sort on those fields. Techniques such as tokenisation or keyed hashes ("blind indexes") can restore limited lookups.

In use

Data being processed sits in memory in the clear. Hardware-backed confidential computing is maturing and suits some high-assurance cases, but for most organisations the practical controls are to minimise how much sensitive data is loaded, keep it there for as short a time as possible, and restrict who and what can reach it.

Keys are the real security

Encryption only moves the problem to the key. Strong designs:

  • Keep keys separate from the data they protect, in a managed key service or hardware security module.
  • Use envelope encryption: a data key encrypts the data, and a master key encrypts the data key.
  • Rotate keys, and log and alert on every use of a decryption key.
  • Apply least privilege: very few identities should be able to decrypt.
A quick checklist. For each sensitive dataset, write down: where it is stored and moves, which encryption applies at each point, who can decrypt it, and what attacker each layer is there to stop. Gaps become obvious very quickly.

Encryption works best alongside access control and data minimisation. The safest data is the data you never collected.