Back to blog

Photos, tokens, secrets: what protects them when you are not looking?

Thắng Đoàn
Thắng Đoàn

A courier loses a signed backup disk with FotoFlow's nightly archive, and the on-call engineer's phone lights up at 3am: the TLS certificate expired and the app is refusing connections. Neither incident involves a hacker breaking in. Encryption work is mostly this: protecting data at rest, keeping certificates alive, and keeping secrets out of the code.

In transit: TLS everywhere

Every connection uses TLS, with certificates from Let's Encrypt that renew automatically, plus HSTS so browsers refuse to ever send an unencrypted request to the domain again. Certificate expiry is the classic 3am page, so monitor renewal the way you monitor servers, with an alert 30 days ahead. Inside the cluster, traffic between services is often plain HTTP on a trusted network; zero-trust shops close that hole with mTLS, both sides presenting certificates, which a service mesh like Istio or Linkerd can wire up for every service at once.

At rest: envelope encryption

Disk-level encryption protects against a stolen drive, but the database still needs to serve photos and payment rows. The standard pattern is envelope encryption: each object or row is encrypted with a fresh data key, and only the data keys are encrypted with a master key that lives in a KMS, a hardware-isolated key service. Rotation means re-wrapping small data keys, not re-encrypting terabytes of photos. Encrypt everything in transit and at rest: the rest of the job is key management.

Payment data gets an even stricter treatment: tokenization swaps the real card number for a meaningless token, tok_4f2c, so the systems that never need the raw number never hold it, which is most of what PCI DSS compliance asks for.

Secrets do not live in git

An engineer commits a database password to make the build pass. It works, the repo is public, and it is now compromised forever; git history forgets nothing. Secrets belong in Vault or the cloud Secrets Manager, injected into services at runtime, with CI scanners that block a commit containing anything that looks like a key. A secret committed to git is a secret given away.

What this does not solve

Private albums deserve a stronger promise: not even FotoFlow's servers can read them. End-to-end encryption puts the keys on the users' devices, using the Signal protocol's forward secrecy, so a server breach yields only ciphertext. The cost is real: no server-side search, no ML features over content, no simple multi-device sync of history. End-to-end encryption trades server features for privacy. Each product picks where that trade lands; for most data, TLS plus at-rest encryption plus short-lived tokens is the honest answer.

Every secret your services use: where does it live, and who could read it today?
If the database backup leaked tomorrow, what would still be safe, and why?

Data is protected, but FotoFlow ships changes every week now. Next in the series: How do you ship every week without breaking the feed?

Sources

Cloudflare: What is TLS?

OWASP Password Storage Cheat Sheet

OAuth 2.0 and OpenID Connect

Share:

Recommended for you

Enjoyed this article?

Subscribe for new articles. No spam. Unsubscribe anytime.

No pasting. This is the challenge.0/200

Typed live, never pasted.