THN Interview Prep

Security (FE & BE)

Treat this hub as something you rehearse out loud. Senior interviewers probe whether you describe trust boundaries, specific controls, and what you'd watch in logs—not whether you memorized acronym lists.


How to use this page

  1. Memorize contrasts in AuthN/Z + sessions vs tokens.
  2. Use Recognition to map interviewer phrases to exploit classes instantly.
  3. Run timed drills (below) weekly.

Topic study plan (deep pages)

Each topic: /security/topics/... with Core details → Understanding → Senior understanding → Diagram.

TopicFocus
Identity: sessions vs bearerCookies, JWT trade space, rotation
TLS, secrets & rotationTermination, vaults, leak response
Injections & safe sinksSQLi, CMDi, deserialization
SSRF & controlled outbound HTTPEgress, allowlists
XSS & Content-Security-PolicySinks, CSP depth
CSRF & session cookiesSameSite, tokens, origins
Audit logging & redactionPII scrubbing, immutable audit

Future topic scaffolding: `content/core-docs/security/topics/topic-page-template.mdx` (`publishDocs: false`) — synced by `utils/sync-core-docs-publish.mjs`.


Core basics — identity & sessions

AuthN vs AuthZ

TermMeansTypical staff trap
AuthNprove who you areweak MFA rollout
AuthZwhat you may do on object XIDOR-style gaps
Federation/OIDC-ishIdP-mediated loginsloppy redirect_uri + PKCE hygiene

Interview script:

“The SPA cannot enforce authZ. Every mutation API must authorize with server-side tenancy + resource ownership—even if FE hides navigation.”

Session cookies (HttpOnly + Secure + SameSite)

WinsObligations
JS cannot casually exfil credentialProvide CSRF defenses for ambient cookie replay
Server can revoke rapidlyOperational session-store scaling

JWT / bearer tokens

WinsObligations
Good for horizontal servicesStored in hostile JS ⇒ XSS amplification
Short verification latencyMention aud, iss, exp + rotation

Transport & secrets hygiene

Operational checklist you'll say verbatim:

ItemGoal
TLS automationno manual cert drift
protocol/cipher posturephased tightening
HSTS rolloutdegrade SSL stripping gradually
clear termination topologyLB/mesh/pod—who decrypts

Secrets: vault-backed, short TTL creds—not infinite env vars pasted in chats.

Leak response choreography:

Rotate → quantify exposure window → forensic logs scope → playbook-notify stakeholders per policy tier.


Input handling & injections (backend)

ClassBoundaryPrimary control
SQListrings → queriesparameterized SQL / safe ORM idioms
Command injectionuser text → shellnever shell interpolate—call structured APIs
Path traversalpath strings → filesystemcanonicalization + sandbox roots
Template injectiondata → templating enginesescaping discipline + hardened templates
Unsafe deserializationbytes → graphsdisallow untrusted formats; schemas + signatures

Defense-in-depth layering: narrowing input shapes does not substitute parameterized sinks—pair both.


SSRF — high-signal senior topic

Threat story: attacker-supplied fetch URL → internal or metadata-style endpoints → lateral movement.

Controls you should list fast:

LayerControl
Networkegress default deny
Applicationdeterministic host/port allowlists
Parsingdeny odd URL schemes (file://, unexpected handlers); beware IP-encoded bypass attempts
Cloud awarenesshardened metadata access posture when relevant

Interview line: “Treat server-side HTTP fetch URLs as hostile input—assume metadata-style pivot risk until egress and allowlists prove otherwise.”


Browser platform defenses

Cross-site scripting (XSS)

SinkTypical missControls
HTML interpolationnaive string concatcontextual encoding helpers
URL attributes (href)pasted user URLsanitization lists
Dangerous sinks (innerHTML-class)copy-pasta HTMLsanitization + CSP narrowing

Content-Security-Policy narrows blast radius. Nonces/hashes imply build pipeline choreography—mention cost honestly.

CSRF

Happens where cookies carry ambient authority hitting state-changing verbs.

Mitigations toolbox:

SameSite cookies; synchronous anti-CSRF tokens when needed; Origin / Referer checks acknowledging corporate proxy privacy caveats.

Clickjacking

frame-ancestors CSP / legacy X-Frame-Options compatibility awareness.


OAuth / OIDC pitfalls (conceptual bullets)

Mis-scoped redirect_uri, missing PKCE for SPA/native, refresh tokens mishandled, mixing public vs confidential client assumptions without audit.

Keep vendor specifics optional—pattern recognition wins.


Cryptography pragmatic boundaries

No custom primitives. Mention platform-supported categories only:

Use platform authenticated encryption (AEAD-style APIs)—no custom primitives. Centralize password hashing (argon2 / bcrypt-class) instead of per-service invention.

Distinguish disk encryption at rest vs field-level app crypto motivating compliance segregation of duties.


OWASP thematic map

Macro themeNarrative snippet
Broken access controlIDOR enumeration + missing tenant predicates
Cryptographic gapslingering weak TLS remnants
Injectiontemplating/database confusion rows above
Misconfigurationpublic buckets/debug toggles accidental
Sensitive data mishandlinglogs/traces/screenshots exposures
Vulnerable depsCVE intake SLA upgrades
Logging failuresintrusion invisible until invoices

Treat as mapping aid—not exhaustive memorization fetishizing numeric category IDs verbatim.


Supply chain safeguards

  • Pin versions + deterministic installs (lockfiles).
  • Automated dependency updates with a CVE response SLA (Renovate/Dependabot-class).
  • Immutable, signed release artifacts + protected default branches.
  • Least-privilege CI tokens (contents: write only where unavoidable).

Auditing vs noisy logs

Keep immutable audit logs (who changed IAM, roles, tenancy) separate from noisy developer debug telemetry so investigations remain trustworthy.

Automatically redact bearer tokens PAN-like PHI patterns at ingestion boundary—not optional grep hope culture.


STRIDE tactical micro-pass

Pick two letters relevant per scenario (verbosity dilutes credibility):

LetterQuick question
Sspoofing feasible? MFA binding?
Tattacker tampering transport/stored payload unnoticed? integrity controls?
Rdisputed actions undeniable? audits?
Itelemetry oversharing?
Dbrute force / resource abuse possible? quotas?
Eescalate privilege via mis-tokened API? scopes tight?

Recognition cues (speed map)

If interviewer says…Lead with
JWT debatesTTL + rotation + revocation + XSS story
CSRF mechanismambient cookies + verbs + defenses
SSRF remediationegress + allowlisting + layering
IDOR probingreproducible enumeration + ACL tests
Secret leakblast rotation + scanners + IaC leakage
“Top risks” succinctBroken access control + SSRF + supply chain succinct triad plausible

Memory hooks

  • Treat fetch URLs like shell.
  • AuthZ repeats per object—even when cookies look trusted.
  • CSP + encoding are partners, never substitutes.

Study drills (timed)

Drill A — 10 min tabletop

Pick a feature such as upload-triggered preview fetch. Outline attacker path → two concrete controls → one metric (ssrf_denied_total by rule id, for example).

Drill B — 12 min verbal STRIDE skim

Identify two STRIDE facets + two engineering controls referencing concrete artefacts (middleware, policy tests, egress ACL).

Drill C — Incident compression 8 min

Contain → eradicate → automated regression guard example (integration test asserting ACL failure path deterministic).


Diagram — trust boundaries

Loading diagram…

Diagram — defense layering

Loading diagram…

Pitfalls (lose credibility fast)

Pure tool-name dropping lacking boundary narrative.

Treating CSP as substitution for escaping.

Ignoring object-level ACL regressions disguised behind role-level RBAC only.

JWT without rotation TTL clarity — silent security debt.

Recording raw tokens / PII in analytics warehouse—silent compliance catastrophe.


  • /backend — SSRF egress, outbound service identity.
  • /frontend — DOM sinks & bundle hygiene.
  • /gen-ai + /dsa/interview-prep/generative-ai — injection via documents + risky tools.

Mark this page when you finish learning it.

Spotted something unclear or wrong on this page?

On this page