Skip to main content

Security Knowledge Base

Security is not a feature you add at the end — it's a property you design in from the start.


Why Security Matters for Engineers

Security vulnerabilities are almost always caused by engineering decisions, not bad luck:

  • A parameterized query prevents SQL injection
  • An HttpOnly cookie flag prevents XSS-based session theft
  • A short JWT expiry limits the blast radius of a token leak
  • A GDPR-compliant erasure flow protects users and avoids €20M fines

You don't need to be a security specialist. You need to know enough to write safe code and enough to ask the right questions in a design review.


What's Covered

TopicDescription
Authentication & AuthorizationSessions, JWT, OAuth 2.0, OIDC, MFA, RBAC, ABAC, passkeys
Web Vulnerabilities & DefensesOWASP Top 10 — SQL injection, XSS, CSRF, SSRF, IDOR and mitigations
Cryptography & Secure DesignAES-GCM, RSA, HMAC, signatures, TLS internals, key management
Privacy & ComplianceGDPR, CCPA, PCI-DSS, HIPAA, data classification, right to erasure
Network SecurityFirewalls, WAF, DDoS, DNS security, zero trust, mTLS
Secure SDLC & DevSecOpsThreat modeling, SAST, DAST, SCA, secrets scanning, container security
Identity & Access ManagementSSO, SAML, LDAP, service accounts, Vault, JIT access, cloud IAM
API SecurityOWASP API Top 10, input validation, rate limiting, GraphQL security
Incident ResponseIR lifecycle, detection, containment, recovery, post-mortem
Interview Questions21 deep-dive answers + quick-fire reference table

Security Mental Model

Think of security in layers — every layer can fail, so you never rely on just one.

┌─────────────────────────────────────────────────────┐
│ PERIMETER WAF · DDoS protection · Firewall │
├─────────────────────────────────────────────────────┤
│ TRANSPORT TLS 1.3 · mTLS · Certificate mgmt │
├─────────────────────────────────────────────────────┤
│ IDENTITY AuthN · MFA · SSO · Token rotation │
├─────────────────────────────────────────────────────┤
│ APPLICATION AuthZ · Input validation · OWASP │
├─────────────────────────────────────────────────────┤
│ DATA Encryption at rest · Masking · PII │
├─────────────────────────────────────────────────────┤
│ AUDIT Immutable logs · SIEM · Alerting │
└─────────────────────────────────────────────────────┘

Attackers always find the weakest layer. Defence in depth means there is no single point of failure.


The OWASP Top 10 at a Glance

#RiskOne-Line Fix
A01Broken Access ControlAlways verify ownership server-side
A02Cryptographic FailuresAES-256-GCM at rest, TLS in transit
A03Injection (SQL, Command)Parameterized queries, never concatenate
A04Insecure DesignThreat model before you build
A05Security MisconfigurationDisable defaults, no verbose errors
A06Vulnerable ComponentsSCA scan in CI, auto-update patches
A07Auth FailuresMFA, short tokens, account lockout
A08Integrity FailuresNever deserialize untrusted data
A09Logging FailuresLog every auth event, no PII in logs
A10SSRFBlock private IPs, allowlist domains

Key Security Principles

PrincipleIn Practice
Least PrivilegeGrant only the minimum permissions needed — to users, services, and DB accounts alike
Defense in DepthAssume every control can fail; never rely on a single layer
Fail SecureDefault to deny; errors should lock down, not open up
Don't Roll Your Own CryptoUse BCrypt, AES-GCM, TLS 1.3 — not home-grown algorithms
Secure by DefaultSecure configuration out of the box, not opt-in
Minimize Attack SurfaceEvery unused endpoint, port, and dependency is a liability
Assume BreachDesign so that a compromised component limits blast radius
Zero TrustVerify every request — network location is not a trust boundary

Common Vulnerabilities by Layer

Code Level

  • SQL / NoSQL / Command injection
  • XSS (Stored, Reflected, DOM)
  • Insecure deserialization
  • Hardcoded secrets

Authentication / Session

  • Weak passwords, no MFA
  • Token leakage (logging, error messages)
  • Session fixation, no logout invalidation
  • JWT alg: none acceptance

Authorization

  • IDOR (Insecure Direct Object Reference)
  • Privilege escalation via mass assignment
  • Missing function-level authorization
  • Overly broad IAM permissions

Infrastructure

  • Misconfigured cloud storage (public S3 buckets)
  • Exposed admin endpoints (Actuator, Swagger)
  • Unencrypted data at rest
  • Outdated dependencies with CVEs

Learning Path

For Interview Preparation

  1. Authentication & Authorization — most common interview topic
  2. Web Vulnerabilities — OWASP Top 10 is expected knowledge
  3. Cryptography — hashing vs encryption, TLS basics
  4. Privacy & Compliance — GDPR basics, PCI-DSS rules
  5. Interview Questions — practise with answers

For Production Systems

  1. Start with Secure SDLC — embed security early
  2. API Security — your primary attack surface
  3. IAM — get service identities right
  4. Incident Response — prepare before you need it

For Compliance Projects

  1. Privacy & Compliance — regulatory requirements
  2. Cryptography — encryption obligations
  3. Audit Logging — evidence trail
  4. Network Security — infrastructure controls

Quick Reference: Technology Choices

NeedRecommended
Password hashingArgon2id (best) · BCrypt (standard)
Symmetric encryptionAES-256-GCM
Asymmetric encryption / signingRS256 / ES256 (JWT), RSA-OAEP (encryption)
TLSTLS 1.3 (minimum TLS 1.2)
Token formatJWT (RS256) + short TTL + refresh rotation
SSO protocol (enterprise)SAML 2.0 or OIDC
SSO protocol (consumer)OAuth 2.0 + OIDC
Secrets managementHashiCorp Vault · AWS Secrets Manager
SAST (Java)SpotBugs + Find Security Bugs · SonarQube
Dependency scanningOWASP Dependency-Check · Snyk
Secrets scanningGitleaks
Container scanningTrivy
DASTOWASP ZAP
WAFAWS WAF · Cloudflare · nginx ModSecurity

Interview tip

Security questions in system design interviews almost always touch one of three areas: how do you authenticate/authorize, how do you protect sensitive data, and what do you do when something goes wrong. Make sure you can answer all three confidently.

Never do this
  • Store passwords in plaintext or MD5
  • Concatenate user input into SQL queries
  • Commit secrets to version control
  • Return stack traces in API error responses
  • Trust the user_id sent by the client — always derive it from the validated token