Photos, tokens, secrets: what protects them when you are not looking?
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
Recommended for you
- Craft & Skills
One server, 10 million users: how does a photo app survive that?
A 40-post series that follows FotoFlow, a photo app, from one server and 100 users to 10 million users with direct messages. One problem, one fix, one honest cost at a time.
- Craft & Skills
Ten million users want direct messages: could you design the chat system?
The final design: 20 million open sockets and a promise that every message arrives, in order, exactly once. Dumb gateways, a connection registry, store-first durability and sync by cursor.
- Craft & Skills
Five million home feeds: how do you build the page everyone opens?
The home feed must load in 200 ms from two hundred followed accounts. Fan-out on read melts at 4.6 million lookups a second; fan-out on write melts on celebrities; the hybrid survives both.
- Craft & Skills
FotoFlow wants short share links: could you design one today?
The first full design walkthrough: turn a one-line brief into numbers, the simplest system, then fix codes, caching, storage and abuse one bottleneck at a time. The method is the point.
Enjoyed this article?
Subscribe for new articles. No spam. Unsubscribe anytime.
Typed live, never pasted.