🛡️ Application Security CheatSheet

Threat Modeling (Beginner → Elite)

Threat modeling is the habit of thinking like an attacker before writing code.

In real incidents: threat modeling only works when it changes decisions (defaults, architecture, acceptance criteria) — not when it becomes a document exercise.

Instead of asking “Is this code vulnerable?”, threat modeling asks:

Beginner mental hook: Threat modeling is like planning security for a house before it’s built (locks, cameras, safe rooms), not after a robbery.
Common misconception: Threat modeling is not a scanner or checklist. It’s a structured way of thinking that produces concrete design decisions.

Where threat modeling fits in SDLC

Elite reality: Threat modeling is a living process. Every major feature change should update the model.

The 4-step mental model (simple and repeatable)

  1. Assets — what matters most (money, identities, tokens, PII, admin powers).
  2. Data flows — where data travels and where it crosses trust boundaries.
  3. Threats — what can go wrong (attacker mindset).
  4. Mitigations — what design changes reduce risk the most.
experienced takeaway: Threat modeling is about architecture risk. Many breaches come from “the system worked as designed” — the design was the problem.

Step 1: Identify assets (what attackers want)

An asset is anything valuable to an attacker or critical to the business.

Common assets

Beginner tip: If losing it makes leadership panic, it’s an asset.

Step 2: Draw the data flow (and mark trust boundaries)

Threat modeling becomes powerful when you visualize how data moves.

Example: typical banking/fintech flow

Trust boundary = where trust level changes:

Rule: Every trust boundary is a potential attack point. Most “high severity” bugs sit on boundaries.

Step 3: Identify threats (STRIDE)

The most common framework is STRIDE. The key is applying it with real examples.

STRIDEThreatReal-world example
SSpoofingAttacker pretends to be another user (stolen tokens, weak auth)
TTamperingAttacker modifies transfer amount or beneficiary ID
RRepudiationUser denies making a transaction (insufficient logs/audit)
IInformation DisclosurePII leak via insecure API (BOLA/IDOR)
DDenial of ServiceBot floods login/OTP endpoint causing outages or lockouts
EElevation of PrivilegeNormal user becomes admin via broken authorization
Interview tip: STRIDE is useful, but don’t be robotic. Show you can think: “What would a real attacker do here?”

Elite technique: Attack trees (think in attacker steps)

STRIDE is a checklist of categories. Attack trees are a path An attacker can actually follow.

Attack tree example: “steal money via transfer abuse”

Elite takeaway: Attack trees help you discover chaining risk (small issues combine into big impact).

Real-world example #1: Fund transfer feature (banking-grade)

Assets

Data flow (simplified)

Threats (attacker mindset)

Mitigations (design-level)

Interview power move: Mention idempotency + atomicity. Many candidates miss these.

Real-world example #2: Password reset workflow abuse

Why it’s high risk

Password reset is an attacker’s favorite because it can convert small weaknesses into full account takeover.

Threats

Mitigations

Real-world example #3: Third-party webhook integration

Webhooks are common in payments, shipping, KYC, and messaging. They are also commonly abused.

Threats

Mitigations

Elite signal: Mention “verify event authenticity + replay protection” every time webhooks appear.

Common failure modes (what goes wrong in real companies)

Elite truth: Most major incidents are not “unknown vulns.” They are known classes (authZ, trust assumptions, integration flaws) that were missed in design.

Threat modeling deliverables (what you should produce)

Best practice: Convert the output into engineering work: tickets, acceptance criteria, and test cases.

Interview Questions & Answers (Easy → Expert)

Easy (foundation)

  1. What is threat modeling?
    A: A design-time process to identify assets, data flows, trust boundaries, attacker paths, and mitigations before implementation.
  2. Why do threat modeling before coding?
    A: Design flaws are expensive to fix later. Threat modeling reduces rework and prevents architectural security gaps.
  3. Is threat modeling the same as security testing?
    A: No. Threat modeling focuses on design/architecture risk; testing focuses on implementation flaws.
  4. Who should participate?
    A: Security, developers, architects, and product owners — because threats map to design and business workflows.

Medium (applied knowledge)

  1. What is an asset? Give examples.
    A: Anything valuable to attackers: credentials, tokens, PII, money movement, admin functions, availability of critical APIs.
  2. What is a trust boundary?
    A: Where trust changes (client→server, internet→internal, your system→third-party). Trust boundaries are common attack points.
  3. Explain STRIDE with examples.
    A: Spoofing (stolen token login), Tampering (change transfer amount), Repudiation (deny action), Info disclosure (IDOR), DoS (flood OTP), Elevation (role escalation).
  4. How do you prioritize threats?
    A: By business impact, likelihood, ease of exploitation, and exposure. Focus first on money, identity, and high-privilege paths.

Hard (experienced-level depth)

  1. Threat model a fund transfer feature quickly.
    A: Assets: balances/beneficiaries. Threats: BOLA, tampering, replay, race conditions. Mitigations: strict authZ, idempotency keys, atomic ledger ops, limits/step-up, audit logs.
  2. How do you threat model third-party integrations?
    A: Identify shared data, validate authenticity (signatures), prevent replay (event IDs), design failure handling, add monitoring and rate-limits.
  3. What’s the biggest mistake teams make?
    A: Treating threat modeling as a one-time document rather than linking it to tickets, tests, and ongoing feature changes.
  4. How does threat modeling differ for web vs API vs mobile?
    A: Web: sessions/CSRF/XSS; API: authZ/object-level access/replay; mobile: client trust, reverse engineering, token storage.

Expert (principal/architect level)

  1. How do you threat model business logic?
    A: By mapping workflows and abuse cases: valid actions used in invalid sequences (refund abuse, coupon stacking, workflow bypass, privilege chaining).
  2. How do you measure success of threat modeling?
    A: Fewer high-severity findings late in SDLC, reduced re-architecture, faster security reviews, fewer production incidents, and clearer security requirements.
  3. What does “assume breach” change in threat modeling?
    A: It shifts focus to containment: strong identity, least privilege, segmentation, tamper-evident logging, monitoring, and safe failure modes.
  4. How do you handle ambiguous ownership in multi-tenant systems?
    A: Explicit tenant isolation rules, consistent authorization middleware, ownership checks on every object, and tests for cross-tenant access (BOLA prevention).
Elite closing line (say this in interviews): Threat modeling is a design-time discipline that identifies trust assumptions and attacker paths early, turning them into security requirements, tests, and monitoring before production.

Checklist

Remediation playbook (how to operationalize it)

  1. Pick the highest-risk feature (auth, money movement, admin, integrations).
  2. Draw a simple DFD with trust boundaries.
  3. Apply STRIDE and write 10–20 realistic threats.
  4. Turn mitigations into security requirements (authZ rules, idempotency, logging).
  5. Create abuse-case test cases and add them to security tests.
  6. Add monitoring/alerting for the threats you care about most.
  7. Update the model whenever the feature changes.