Threat Modeler
When to activate
- Conducting security design review on a new system or feature before implementation
- Analyzing a deployed system for previously unmapped threat vectors
- Responding to a suspected attack or security incident to understand root causes and gaps
- Preparing for a formal threat modeling session with stakeholders (architecture, infra, product)
- Validating that threat mitigations implemented in code/config actually address identified risks
When NOT to use
- Vulnerability scanning or penetration testing — use vulnerability assessment tools instead
- Post-incident root cause analysis without architectural context — pair with incident forensics
- Compliance checklist verification (SOC 2, PCI-DSS) — use compliance frameworks directly
- General security advice for code review — use code-review skill with security focus
- One-off security questions about a single component — ask specifically rather than full threat modeling
Instructions
Phase 1: Define System Scope and Boundaries
Identify the system boundary. What components are in scope? What are the external actors and trust boundaries?
- Draw or describe data flows: where does data enter, transform, and exit?
- Identify authentication/authorization boundaries
- Mark external systems and third-party services
List system assets. What are you protecting?
- User data (PII, credentials, secrets)
- Application logic and proprietary algorithms
- Availability/uptime
- Integrity of stored or transmitted data
- Audit logs and forensic capability
Document entry/exit points. How can attackers interact with this system?
- API endpoints (REST, GraphQL, gRPC)
- Network listeners (ports, protocols)
- File upload mechanisms
- Admin consoles or dashboards
- Third-party integrations (webhooks, OAuth, SSO)
Phase 2: Apply STRIDE Framework
For each entry point and trust boundary, systematically walk through STRIDE:
S — Spoofing (Identity Forgery)
- Can an attacker impersonate a legitimate user or service?
- Weak authentication (hardcoded creds, shared secrets, no MFA)?
- Unverified API calls between internal services?
- DNS or network interception?
- Unsigned JWTs or predictable session tokens?
T — Tampering (Modification)
- Can data be modified in transit or at rest?
- Unencrypted or plaintext transmission (HTTP, unencrypted database connections)?
- Missing integrity checks (no HMAC, signatures, checksums)?
- Unsafe deserialization (pickle, Java serialization, YAML)?
- Writable config files or environment variables?
R — Repudiation (Denial of Actions)
- Can an attacker deny performing an action?
- Missing audit logs for sensitive operations?
- Logs that can be modified or deleted?
- Lack of digital signatures or timestamps?
- No nonrepudiation for financial or legal transactions?
I — Information Disclosure
- Can sensitive data be exposed?
- Secrets in logs, error messages, or debug output?
- Information leakage in API responses (user enumeration, data exposure)?
- Readable backup files or cache?
- Metadata exposure (timing attacks, HTTP headers)?
- Unencrypted storage of credentials or PII?
D — Denial of Service (DoS)
- Can an attacker make the system unavailable?
- No rate limiting on endpoints?
- Resource exhaustion via large uploads, queries, or concurrent connections?
- Crash triggers from malformed input?
- External dependencies without timeout or circuit breaker?
- DDoS vulnerability without mitigation?
E — Elevation of Privilege (AuthZ Bypass)
- Can an attacker gain unauthorized access or permissions?
- Missing or weak authorization checks (relying on client-side filtering)?
- Privilege escalation via direct object references (IDOR)?
- Missing permission validation in API calls?
- Session fixation or hijacking?
- Unsafe use of admin accounts or service principals?
Phase 3: Document Threats and Ranking
For each identified threat, record:
- Threat ID: Unique identifier (e.g., TM-001, TM-API-003)
- STRIDE Category: Which one(s) apply
- Description: What is the attack? How would it happen?
- Affected Component(s): Which system parts are vulnerable
- Likelihood: H/M/L — based on required attacker skill, ease of exploitation, attack surface
- Impact: H/M/L — data loss, availability, confidentiality, compliance violation
- Risk Level: H/M/L — combination of likelihood and impact
- Current Mitigations: What controls exist today?
- Recommended Mitigation: How to reduce likelihood or impact
- Effort to Mitigate: Low/Medium/High
Phase 4: Build Attack Tree (Optional)
For high-risk threats:
- Identify the attacker's goal (e.g., "Steal user credentials")
- Work backwards: what must be true for this to succeed?
- Branch into sub-goals and technical conditions
- Identify which branch is most likely or easiest to exploit
- Map mitigations to branches to show coverage
Example structure:
Goal: Steal database credentials
├─ Compromise developer machine
│ ├─ Social engineering email
│ ├─ Malware download
│ └─ Physical theft of laptop
└─ Extract from code/config
├─ Git history (.git folder)
├─ Environment files (dotenv, k8s secrets)
└─ Hardcoded in comments or strings
Phase 5: Prioritize and Plan
- Sort threats by Risk Level (H → M → L)
- Group by component to identify systemic issues
- Identify quick wins (mitigations that are easy and high-impact)
- Schedule remediation — high-risk items into sprint planning
- Track ownership — assign each mitigation to a team (backend, infra, security)
- Follow up — re-threat-model after significant changes
Example
System: Multi-tenant SaaS expense management application
Scope: Web API (Node.js), React frontend, PostgreSQL database, AWS S3 for receipts, Stripe for billing
Selected Threat from STRIDE walkthrough:
| Field |
Value |
| Threat ID |
TM-API-005 |
| Category |
Elevation of Privilege (E) + Information Disclosure (I) |
| Description |
Attacker can view another tenant's expenses via direct object reference (IDOR). API endpoint /api/expenses/{expenseId} returns expense details without verifying the requesting user owns the expense. Attacker increments expenseId parameter to enumerate and read all expenses in the system. |
| Affected Components |
Node.js API, PostgreSQL (expense table), React frontend |
| Likelihood |
High — endpoint is publicly documented, parameter enumeration is trivial, no API key rotation/limit required |
| Impact |
High — exposure of all user PII, financial data (amounts, vendor info, personal card details), business intelligence |
| Risk Level |
High |
| Current Mitigations |
Database encryption at rest; HTTPS for transit |
| Recommended Mitigation |
Add authorization check in API handler: fetch expense, verify expense.tenantId === req.user.tenantId before returning. Add integration tests to verify IDOR is blocked. Implement per-tenant row-level security (RLS) in PostgreSQL as defense-in-depth. |
| Effort to Mitigate |
Low — ~2 hour code change + 1 hour testing |
Attack Tree for High-Risk Threat (TM-API-008):
Goal: Bypass MFA and steal user accounts
├─ Guess or leak session token
│ ├─ Weak token generation (predictable)
│ │ └─ Token not cryptographically random
│ ├─ Token leaked in logs/error messages
│ │ └─ Verbose error handling
│ └─ Token stored insecurely (localStorage, unencrypted)
│
└─ Exploit MFA implementation gaps
├─ No MFA enforcement for high-privilege actions
├─ Time-based OTP (TOTP) brute-force (no rate limit)
└─ SMS-based OTP interception
└─ SIM swap attack (out-of-scope for app, but operational risk)
Mitigation coverage:
- Cryptographically random session tokens → eliminates "predictable" branch
- Structured logging + secret redaction → eliminates "leaked in logs" branch
- HTTPOnly + Secure cookies → reduces localStorage exposure
- Rate limiting on OTP validation → 5 attempts per 15 min per account
- Audit logs for MFA changes → post-incident forensics
1---2name: threat-modeler3description: Threat Modeler4---5# Threat Modeler67## When to activate89- Conducting security design review on a new system or feature before implementation10- Analyzing a deployed system for previously unmapped threat vectors11- Responding to a suspected attack or security incident to understand root causes and gaps12- Preparing for a formal threat modeling session with stakeholders (architecture, infra, product)13- Validating that threat mitigations implemented in code/config actually address identified risks1415## When NOT to use1617- Vulnerability scanning or penetration testing — use vulnerability assessment tools instead18- Post-incident root cause analysis without architectural context — pair with incident forensics19- Compliance checklist verification (SOC 2, PCI-DSS) — use compliance frameworks directly20- General security advice for code review — use code-review skill with security focus21- One-off security questions about a single component — ask specifically rather than full threat modeling2223## Instructions2425### Phase 1: Define System Scope and Boundaries26271. **Identify the system boundary.** What components are in scope? What are the external actors and trust boundaries?28 - Draw or describe data flows: where does data enter, transform, and exit?29 - Identify authentication/authorization boundaries30 - Mark external systems and third-party services31322. **List system assets.** What are you protecting?33 - User data (PII, credentials, secrets)34 - Application logic and proprietary algorithms35 - Availability/uptime36 - Integrity of stored or transmitted data37 - Audit logs and forensic capability38393. **Document entry/exit points.** How can attackers interact with this system?40 - API endpoints (REST, GraphQL, gRPC)41 - Network listeners (ports, protocols)42 - File upload mechanisms43 - Admin consoles or dashboards44 - Third-party integrations (webhooks, OAuth, SSO)4546### Phase 2: Apply STRIDE Framework4748For each entry point and trust boundary, systematically walk through STRIDE:4950#### **S — Spoofing (Identity Forgery)**51- Can an attacker impersonate a legitimate user or service?52- Weak authentication (hardcoded creds, shared secrets, no MFA)?53- Unverified API calls between internal services?54- DNS or network interception?55- Unsigned JWTs or predictable session tokens?5657#### **T — Tampering (Modification)**58- Can data be modified in transit or at rest?59- Unencrypted or plaintext transmission (HTTP, unencrypted database connections)?60- Missing integrity checks (no HMAC, signatures, checksums)?61- Unsafe deserialization (pickle, Java serialization, YAML)?62- Writable config files or environment variables?6364#### **R — Repudiation (Denial of Actions)**65- Can an attacker deny performing an action?66- Missing audit logs for sensitive operations?67- Logs that can be modified or deleted?68- Lack of digital signatures or timestamps?69- No nonrepudiation for financial or legal transactions?7071#### **I — Information Disclosure**72- Can sensitive data be exposed?73- Secrets in logs, error messages, or debug output?74- Information leakage in API responses (user enumeration, data exposure)?75- Readable backup files or cache?76- Metadata exposure (timing attacks, HTTP headers)?77- Unencrypted storage of credentials or PII?7879#### **D — Denial of Service (DoS)**80- Can an attacker make the system unavailable?81- No rate limiting on endpoints?82- Resource exhaustion via large uploads, queries, or concurrent connections?83- Crash triggers from malformed input?84- External dependencies without timeout or circuit breaker?85- DDoS vulnerability without mitigation?8687#### **E — Elevation of Privilege (AuthZ Bypass)**88- Can an attacker gain unauthorized access or permissions?89- Missing or weak authorization checks (relying on client-side filtering)?90- Privilege escalation via direct object references (IDOR)?91- Missing permission validation in API calls?92- Session fixation or hijacking?93- Unsafe use of admin accounts or service principals?9495### Phase 3: Document Threats and Ranking9697For each identified threat, record:98991. **Threat ID**: Unique identifier (e.g., TM-001, TM-API-003)1002. **STRIDE Category**: Which one(s) apply1013. **Description**: What is the attack? How would it happen?1024. **Affected Component(s)**: Which system parts are vulnerable1035. **Likelihood**: H/M/L — based on required attacker skill, ease of exploitation, attack surface1046. **Impact**: H/M/L — data loss, availability, confidentiality, compliance violation1057. **Risk Level**: H/M/L — combination of likelihood and impact1068. **Current Mitigations**: What controls exist today?1079. **Recommended Mitigation**: How to reduce likelihood or impact10810. **Effort to Mitigate**: Low/Medium/High109110### Phase 4: Build Attack Tree (Optional)111112For high-risk threats:113114- Identify the attacker's goal (e.g., "Steal user credentials")115- Work backwards: what must be true for this to succeed?116- Branch into sub-goals and technical conditions117- Identify which branch is most likely or easiest to exploit118- Map mitigations to branches to show coverage119120Example structure:121```122Goal: Steal database credentials123├─ Compromise developer machine124│ ├─ Social engineering email125│ ├─ Malware download126│ └─ Physical theft of laptop127└─ Extract from code/config128 ├─ Git history (.git folder)129 ├─ Environment files (dotenv, k8s secrets)130 └─ Hardcoded in comments or strings131```132133### Phase 5: Prioritize and Plan1341351. **Sort threats by Risk Level** (H → M → L)1362. **Group by component** to identify systemic issues1373. **Identify quick wins** (mitigations that are easy and high-impact)1384. **Schedule remediation** — high-risk items into sprint planning1395. **Track ownership** — assign each mitigation to a team (backend, infra, security)1406. **Follow up** — re-threat-model after significant changes141142## Example143144**System:** Multi-tenant SaaS expense management application145146**Scope:** Web API (Node.js), React frontend, PostgreSQL database, AWS S3 for receipts, Stripe for billing147148**Selected Threat from STRIDE walkthrough:**149150| Field | Value |151|---|---|152| **Threat ID** | TM-API-005 |153| **Category** | Elevation of Privilege (E) + Information Disclosure (I) |154| **Description** | Attacker can view another tenant's expenses via direct object reference (IDOR). API endpoint `/api/expenses/{expenseId}` returns expense details without verifying the requesting user owns the expense. Attacker increments `expenseId` parameter to enumerate and read all expenses in the system. |155| **Affected Components** | Node.js API, PostgreSQL (expense table), React frontend |156| **Likelihood** | **High** — endpoint is publicly documented, parameter enumeration is trivial, no API key rotation/limit required |157| **Impact** | **High** — exposure of all user PII, financial data (amounts, vendor info, personal card details), business intelligence |158| **Risk Level** | **High** |159| **Current Mitigations** | Database encryption at rest; HTTPS for transit |160| **Recommended Mitigation** | Add authorization check in API handler: fetch expense, verify `expense.tenantId === req.user.tenantId` before returning. Add integration tests to verify IDOR is blocked. Implement per-tenant row-level security (RLS) in PostgreSQL as defense-in-depth. |161| **Effort to Mitigate** | **Low** — ~2 hour code change + 1 hour testing |162163---164165**Attack Tree for High-Risk Threat (TM-API-008):**166167*Goal: Bypass MFA and steal user accounts*168```169├─ Guess or leak session token170│ ├─ Weak token generation (predictable)171│ │ └─ Token not cryptographically random172│ ├─ Token leaked in logs/error messages173│ │ └─ Verbose error handling174│ └─ Token stored insecurely (localStorage, unencrypted)175│176└─ Exploit MFA implementation gaps177 ├─ No MFA enforcement for high-privilege actions178 ├─ Time-based OTP (TOTP) brute-force (no rate limit)179 └─ SMS-based OTP interception180 └─ SIM swap attack (out-of-scope for app, but operational risk)181```182183**Mitigation coverage:**184- Cryptographically random session tokens → eliminates "predictable" branch185- Structured logging + secret redaction → eliminates "leaked in logs" branch186- HTTPOnly + Secure cookies → reduces localStorage exposure187- Rate limiting on OTP validation → 5 attempts per 15 min per account188- Audit logs for MFA changes → post-incident forensics