Security Basics for System Design
Cover authentication, authorization, encryption in transit and at rest, secrets management and the common web threats every design should address.
Intermediate · about 3 hours · difficulty 3/5
Learn first: API Design: REST, gRPC and GraphQL
Interviewers increasingly expect at least a short security pass on every design, and for payments or health data it is central.
Identity
- Authentication: sessions with secure cookies for web apps, or tokens (JWTs) for APIs and mobile. Keep access tokens short-lived with refresh tokens. Use OAuth 2.0 / OpenID Connect for "Login with Google" and third-party access.
- Authorization: check permissions on every request, server-side. RBAC (roles) for most products, attribute or relationship-based checks for fine-grained sharing. Broken object-level authorization (changing /orders/123 to /orders/124) is one of the most common real bugs.
- Service-to-service: mTLS or signed service tokens; do not trust traffic just because it is internal.
Protecting data
- In transit: TLS everywhere, including inside the VPC for sensitive systems.
- At rest: disk and database encryption, with keys in a KMS. Encrypt or tokenise especially sensitive fields (card numbers, Aadhaar). Hash passwords with bcrypt or Argon2, never plain SHA.
- Secrets: in a secrets manager (Vault, AWS Secrets Manager), never in code or Git.
- Data minimisation and residency: store only what you need; know rules like RBI payment data localisation and India's DPDP Act.
Common threats to design against
Injection (SQL, command), XSS, CSRF, SSRF, credential stuffing (rate limits plus MFA), DDoS (CDN and WAF), and abuse of business logic (coupon farming, OTP bombing). The OWASP Top 10 is the standard checklist.
Pitfalls
- Trusting client-side checks or IDs sent from the app.
- Long-lived JWTs that cannot be revoked.
- Logging tokens, passwords or full card numbers.
You are ready to move on when you can add a security section to any design covering authn, authz, encryption, secrets and the top three threats specific to that product.
Key concepts
- Sessions vs tokens (JWT)
- OAuth 2.0 and OpenID Connect
- RBAC and object-level authorization
- Encryption in transit and at rest
- Password hashing
- Secrets management and KMS
- OWASP Top 10
- mTLS between services
Mini project
Take one of your earlier mini-project APIs and write a threat model: list assets, entry points and the top five threats, then implement short-lived JWTs with refresh, object-level authorization checks and secrets loaded from a secrets manager or vault container.
Check yourself
A user changes the order ID in GET /orders/{id} and sees someone else's order. What class of bug is this and where should the fix live?
Free resources
- OWASP Top 10 (OWASP)
- OWASP Cheat Sheet Series (OWASP)
- OAuth 2.0 (oauth.net)
- Introduction to JSON Web Tokens (jwt.io)