NodeMotion
Live Canvas
Back to Guides & eBooks Hub
Fundamentals · Lesson 1 / 8
LESSON 014-Question FrameworkAssets & Entry PointsShift-Left ROIAdversarial Thinking

Beginner’s Guide to Threat Modeling: Thinking Like an Adversary

Adam Shostack’s 4-Question Framework, Assets, Entry Points & Shift-Left Economics

THREAT MODELING ACADEMY · LESSON 01⏱ 10 min read

“Every system has a threat model—either one you designed on purpose, or one an attacker discovers for you on a Friday night.”

— Nova, Principal Security Architect
TL;DR in 15 Seconds:Threat modeling is structured brainstorming before code ships: identify what you are building, ask what can go wrong, decide how to defend it, and verify your defenses worked—saving 100× in engineering rework.
Nova's Field Tip:You do not need a PhD in cryptography to threat model. If you can draw four boxes and ask "Wait—who is allowed to call this?", you are already ahead of 80% of teams.
COST TO FIX A SECURITY FLAW$100 Design$10,000+ ProdDesign → Code → Test → Production IncidentNova (Security Architect)4 QUESTIONS1. What are we building?2. What can go wrong?3. What will we do?4. Did we do a good job?“Catching a missing auth check on a napkin costs $100. Catching it in prod costs $10,000+!”Nova's Rule #1: Think like an adversary before anyone opens an IDE.
Nova demonstrates the $100 design-time fix vs. $10,000+ production breach curve alongside the 4-Question Framework.

Imagine building an entire house, pouring concrete, wiring the electricity, hanging drywall—and only THEN asking an architect, "Hey, shouldn’t the front door have a lock?" You would never build a house that way. Yet software teams do it every quarter: they ship a new microservice, wire up a database, expose a webhook, and ask security to "bless it" two days before launch.

By that point, fixing a fundamental design flaw—like realizing tenant A can query tenant B’s invoices because authorization lives in the UI instead of the API—requires ripping out database schemas, migrating live rows, and delaying the release by three weeks. On a whiteboard during sprint planning, that exact fix takes five minutes and a marker.

Threat modeling is simply the discipline of thinking like an adversary while your architecture is still cheap to change. It turns vague anxiety ("Are we secure?") into concrete engineering decisions.

Section 2 · Core Theory & Visual Architecture Diagrams

The 4-Question Framework, Assets & Entry Points

The simplest, most battle-tested structure in security engineering is Adam Shostack’s 4-Question Framework: (1) What are we building?, (2) What can go wrong?, (3) What are we going to do about it?, and (4) Did we do a good job? Notice there is no mention of magic tools or 90-page compliance binders. It works equally well for a 3-person startup and a global bank.

To answer Question 1 without drowning in detail, focus on Assets (what attackers want: PII, payment tokens, signing keys, proprietary models) and Entry Points (every door into the building: REST endpoints, GraphQL mutations, gRPC ports, S3 upload buckets, CI webhooks, and admin consoles).

To answer Question 2, adopt Adversarial Thinking: stop assuming users click buttons in the intended order. Assume an attacker sends raw curl requests with forged headers, replays expired tokens, uploads 4 GB XML bombs, and pivots sideways from your least-important internal worker.

Question 1: What are we building?

Sketch the components, data stores, actors, and boundaries so everyone shares one mental model.

Question 2: What can go wrong?

Walk each entry point and ask how an attacker could spoof identity, tamper with data, or escalate privileges.

Question 3: What will we do about it?

Choose concrete mitigations (auth checks, rate limits, encryption) or consciously accept low-severity risks.

Question 4: Did we do a good job?

Verify controls were actually implemented in code/tests and update the model when requirements shift.

The 4-Question Threat Modeling LoopANNOTATED VISUAL WALKTHROUGH
1What are we building?Scope, Assets & Flows2What can go wrong?Entry Points & Threats3What will we do?Controls & Mitigations4Did we do well?Verify & Retrospective
1
Scope First

Keep the diagram focused on the feature or system change—never boil the entire company ocean on day one.

2
Hunt Entry Points

Every open port, webhook, file parser, and admin route is an invitation for untrusted input.

3
Verify Closure

Question 4 closes the loop—make sure the mitigation made it into the pull request.

A repeatable 4-step engineering loop that catches architectural flaws at $100 design cost instead of $10,000+ prod cost.ANNOTATED ARCHITECTURE DIAGRAM
Section 3 · Real-World Case Study & Attack Walkthrough

Case Study: The $120,000 "Forgot-to-Check-Org-ID" BOLA Bug

A fast-growing SaaS team shipped a PDF invoice export endpoint /api/v1/invoices/{invoiceId}/pdf. It passed unit tests, lint checks, and even a static code scanner—yet weeks later a researcher discovered any logged-in user could download any enterprise customer’s invoice by incrementing invoiceId.

Design Miss

Trusted the UI Instead of the API

Engineers assumed users would only click invoice links shown on their own dashboard. Nobody drew the API entry point receiving arbitrary invoiceId parameters.

Exploit

Sequential Enumeration (BOLA / IDOR)

An attacker authenticated with a free trial account and scripted GET /api/v1/invoices/1001..9999, exfiltrating confidential billing PDFs.

How Threat Modeling Catches It

10 Minutes on Question 2

Asking "What if a valid user supplies someone else’s ID at this entry point?" immediately flags Broken Object Level Authorization—fixed cleanly with WHERE id = ? AND org_id = jwt.org_id before line 1 is written.

Design Lesson Learned:Static scanners rarely catch missing business-logic authorization. Threat modeling catches it effortlessly because it asks what the attacker can reach, not just whether syntax looks clean.
Section 4 · Cognitive Breaks & Self-Check

There Are No Dumb Questions

Candid answers to the skeptical questions every security engineer asks first.

Q:When is the best time to run a threat model—before coding or before release?
A:Always before coding (during RFC / design review). Running a threat model two days before launch only creates panic because architectural changes are expensive by then.
Q:Does a threat model have to cover our entire 200-service platform at once?
A:Never! Scope it to one feature, one new integration, or one service boundary. Small, frequent models beat giant annual documents every time.
Q:Aren’t penetration tests and SAST scanners enough?
A:SAST checks code syntax and pentests happen after you already built the system. Threat modeling prevents flawed architectures from being built in the first place.
FIRESIDE CHAT · CONCEPT DEBATE

Design-Time Threat Modeling vs. Post-Release Penetration Testing

Annual Pentest OnlyLate-Stage Audit

“We hire an external firm every November to hack our production staging environment. Isn’t that enough?”

NovaShift-Left Architect

“A pentest in November tells you that the basement flooded in June. Threat modeling in June makes sure you installed a sump pump before the rain started!”

INTERACTIVE EXERCISE

Sharpen Your Pencil · 60-Second Brain Challenge

Your team is designing a new webhook receiver /webhooks/stripe that updates customer subscription tiers. According to the 4-Question Framework, what is the FIRST critical question to ask in Step 2 ("What can go wrong?")?

Lesson 01 Sticky-Note Recap
  • ▸Threat modeling is structured adversarial thinking before code is written—fixing flaws 100× cheaper than in production.
  • ▸Use the 4-Question Framework: What are we building? What can go wrong? What will we do? Did we do a good job?
  • ▸Always map Assets (what attackers want) and Entry Points (every untrusted door into the system).
  • ▸Keep models small, iterative, and scoped to the feature or boundary you are changing.
Optional Interactive Practice

Practice mapping Assets, Entry Points, and the 4-Question Framework visually in NodeMotion’s Live Canvas →

Practice This Pattern in NodeMotion's Live Canvas