Reliability, Security & ObservabilityAdvanced15 min read2 questions

Security in System Design

The security decisions an interviewer expects you to raise unprompted: how users authenticate, how services trust each other, where secrets live, and what a breach costs you.

Covers: Authentication vs authorisation, sessions vs JWT, OAuth2 and OIDC, encryption in transit and at rest, secrets, defence in depth

Security rarely gets its own interview, but it gets mentioned in every one - and candidates who raise it before being asked stand out. You do not need to be a specialist. You need to make the standard decisions correctly and know what each one protects against.

Filter
0/2 mastered
AdvancedauthenticationjwtsessionsAsked at Auth0, Stripe

30-second answer

Server-side sessions store state in Redis and hand the client an opaque ID: revocation is instant because you delete the record, at the cost of a lookup per request. JWTs are self-contained and signed, so any service can verify them without a lookup - but that same property means you cannot revoke one before it expires. The standard resolution is short-lived access tokens of 5–15 minutes paired with a long-lived refresh token that is stored server-side and therefore revocable. That gives you stateless verification on the hot path and a real logout.

AdvancedencryptionsecretssecurityAsked at Amazon, Stripe

30-second answer

Encrypt in transit with TLS 1.3 everywhere including internal traffic, and at rest with per-tenant or per-field keys managed by a KMS using envelope encryption - a data key encrypts the data, and the KMS master key encrypts the data key, so rotation re-encrypts keys rather than terabytes of data. Secrets belong in a managed secret store with short-lived dynamic credentials wherever possible, never in source control, container images or plain environment variables. For particularly sensitive fields, application-level encryption means a database compromise alone does not reveal the data.

Showing 2 of 2 questions for security-in-system-design.

Check your understanding

4 questions · no sign-up, nothing stored

0/4 answered
Question 1

1.What is the primary security weakness of a long-lived JWT?

Question 2

2.Why use envelope encryption rather than encrypting data directly with a KMS key?

Question 3

3.An attacker gains your application's database credentials. What still protects sensitive fields?

Question 4

4.Where should a browser store an access token?

Hands-on challenge

Build it - this is what you talk about in a deep-dive round.

Write the security design for a multi-tenant SaaS

Produce the security section of a design document for a B2B product holding customer financial records.

Requirements

  • Specify the authentication flow, token lifetimes and the logout/revocation path.
  • Define the service-to-service trust model and how identities are issued and rotated.
  • Design encryption at rest with per-tenant keys, including the envelope-encryption flow and rotation.
  • Specify secret storage and how a database credential is issued, used and expired.
  • For one concrete threat, list controls at all four layers: prevent, limit, detect, contain.

Stretch goals

  • Design tenant isolation so a bug cannot return one tenant's rows to another.
  • Write the incident response for a leaked refresh token, with detection and containment steps.