#Why this matters
In the earlier lesson on Secure SDLC, you saw how abuse cases turn user stories into testable security requirements. Before coding begins, teams need a structured way to review the whole system design. Threat modeling exposes missing authentication checks, exposed internal endpoints, and unprotected data paths while architecture diagrams are still cheap to change.
Without a threat model, teams fix isolated bugs while missing structural flaws between services. Modeling data flows early makes trust assumptions explicit so defenders fix design flaws before deployment.
#The four-question workflow
Effective threat modeling answers four questions:
- Scope1. What are we working on? (DFD and assets)
- Identify2. What can go wrong? (STRIDE per element)
- Mitigate3. What are we going to do about it? (Controls)
- Verify4. Did we do a good enough job? (Review and tests)
Scope each review to one feature or change, answer these four questions, and update the model whenever a new data flow or trust boundary appears.
#Data-Flow Diagrams and trust boundaries
To answer "What are we working on?", build a Data-Flow Diagram (DFD) with five elements:
| Element | Meaning | Examples |
|---|---|---|
| External entity | Actor outside your control | Customer browser, payment gateway |
| Process | Code transforming or routing data | API gateway, order service |
| Data store | Persistent or cached storage | PostgreSQL database, Redis, log file |
| Data flow | Data moving between elements | HTTPS POST request, SQL query |
| Trust boundary | Line where trust level changes | Internet-to-VPC edge, user-to-admin |
Trust boundaries are the highest-value lines on a DFD. Whenever data crosses a boundary, the receiving process must not assume the caller is honest, authenticated, or authorized.
Consider a checkout flow at shop.example.test:
The webhook returns across Trust Boundary 2 into your service. Without signature verification at that boundary, any external caller could forge a "paid" notification.
#Analyzing threats with STRIDE
Apply STRIDE to each element and boundary crossing to answer "What can go wrong?":
| Category | Violated property | Checkout DFD example |
|---|---|---|
| Spoofing | Authentication | Forged webhook or stolen session token |
| Tampering | Integrity | Altered item price in checkout JSON |
| Repudiation | Non-repudiation | Missing user IDs in audit logs |
| Information Disclosure | Confidentiality | Verbose errors or plaintext internal traffic |
| Denial of Service | Availability | Unbounded checkout requests exhausting DB |
| Elevation of Privilege | Authorization | Customer calling an unguarded refund route |
Use STRIDE-per-element mapping to keep reviews focused:
- External entity: Spoofing, Repudiation
- Process: Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege
- Data store: Tampering, Repudiation, Information Disclosure, Denial of Service
- Data flow: Tampering, Information Disclosure, Denial of Service
A data flow does not execute code, so you inspect it for tampering, disclosure, and flooding rather than Elevation of Privilege.
#Documenting mitigations in OWASP Threat Dragon
Each threat needs an engineering decision: mitigate with a control, eliminate the risky feature, transfer risk, or accept residual risk with sign-off. Chosen mitigations become testable security requirements in your issue tracker.
OWASP Threat Dragon lets teams draw DFDs, mark trust boundaries, attach STRIDE threats, and save the model as JSON alongside application code.
{
"id": "TM-PAY-002",
"element": "Payment Gateway -> Order Service (Webhook)",
"stride_category": "Spoofing",
"severity": "High",
"status": "Mitigated",
"description": "External callers can POST a forged payment_status=succeeded webhook.",
"mitigation": "Verify HMAC-SHA256 signature header and reject timestamps older than 5 minutes."
}Storing threat models as versioned JSON in Git keeps design decisions visible in pull-request reviews.
#Common mistakes
- Drawing a deployment chart instead of a DFD: Server hostnames and VLANs without data flows and trust boundaries hide application flaws.
- Omitting trust boundaries: Without boundaries, reviewers treat webhooks and partner callbacks as trusted internal traffic.
- Listing generic threats: Writing "SQL injection exists" without naming the specific process-to-datastore flow makes fixes vague.
- Modeling once and forgetting: Models drift out of date when teams add new endpoints or integrations.
#Summary
Threat modeling structures design reviews around four questions: scope, threats, mitigations, and verification. Data-Flow Diagrams expose external entities, processes, data stores, data flows, and trust boundaries where assumptions fail. Applying STRIDE per DFD element uncovers concrete risks that OWASP Threat Dragon tracks as versioned mitigations in your repository.