Security Fundamentals
Security rarely gets its own interview question, but it shows up in almost all of them. Your interviewer asks "how do you secure this?", or "what stops someone from calling this endpoint for another user?", or "this stores medical records, what changes?" A vague answer ("we'll use HTTPS and encrypt everything") is a missed opportunity. A structured one, that names what you're protecting, from whom, and with which specific mechanism, is one of the clearer senior signals you can give.
We'll cover the pieces that come up most, from first principles to what you'd say at the whiteboard:
- Threat modeling: deciding what to protect before choosing how.
- Encryption in transit: TLS, where to terminate it, and mTLS between services.
- Encryption at rest: the layers, envelope encryption with a KMS, and key rotation.
- Request signing: proving a request is authentic and unmodified, and stopping replays.
- Secrets management: getting credentials to services without leaking them.
- Privacy and GDPR: deletion, data minimization and data residency as design constraints.
Authentication and authorization (passwords, sessions, JWTs, OAuth, RBAC) are covered in their own post, /system-design/authentication-authorization. We'll refer to them here without repeating them.
Threat Modeling: Start With What You're Protecting
Security mechanisms only make sense relative to a threat. Encrypting a database's disks protects against someone walking off with a hard drive. It does nothing against an attacker who steals the application's database password, because the database decrypts the data for anyone who logs in. If you can't say which attack a control stops, you can't say whether you need it.
A threat model answers four questions:
- What are we protecting? The assets: user credentials, payment details, private messages, health records, the integrity of account balances, availability of the service.
- Who might attack, and how capable are they? An anonymous internet user, a logged-in user poking at other users' data, a malicious insider, a compromised dependency, a cloud provider employee, a nation-state.
- Where are the trust boundaries? Every point where data crosses from a less trusted zone to a more trusted one: the public internet into your edge, your edge into internal services, a service into the database, a third-party webhook into your API.
- What can go wrong at each boundary, and what do we do about it?
A handy checklist for question 4 is STRIDE, a mnemonic for six classes of threat, each with a matching property and a typical control:
| Threat | Property violated | Typical control |
|---|---|---|
| Spoofing (pretending to be someone else) | Authentication | Passwords + MFA, OAuth tokens, mTLS between services |
| Tampering (changing data or requests) | Integrity | TLS, request signatures (HMAC), checksums, database constraints |
| Repudiation (denying you did something) | Non-repudiation | Append-only audit logs, digital signatures |
| Information disclosure (reading what you shouldn't) | Confidentiality | Authorization checks, encryption in transit and at rest |
| Denial of service (making it unavailable) | Availability | Rate limiting, CDN/WAF, autoscaling, quotas |
| Elevation of privilege (doing more than allowed) | Authorization | Least privilege, server-side permission checks, sandboxing |
You won't run a formal STRIDE exercise in a 45-minute interview. But walking along your diagram from client to database, naming the boundary and the control at each hop, takes two minutes and covers most of what an interviewer wants.
The most common real vulnerability in the kind of systems you design in interviews isn't broken crypto. It's a missing authorization check:
GET /orders/{orderId}that returns any order to any logged-in user. Always derive the user from the session or token, never from the request body, and check ownership on the server. Saying this unprompted is worth more than any amount of encryption talk.