Threat Model Analyze (Question 2: What Can Go Wrong?)
Use this skill to systematically uncover real, code-grounded security vulnerabilities and design weaknesses across a repository and write a complete, actionable threat model.
Prerequisites
- If architecture discovery has not been completed yet, run the
threat-model-discoverworkflow first so you have an accurate stack inventory, asset list, entry points, trust boundaries, and Mermaid DFD. - Activate every stack-specific
tm-*skill that matches the detected stack (for exampletm-nextjs-react,tm-rust-web,tm-apis-rest-graphql-grpc,tm-auth-oauth-oidc-jwt,tm-databases-sql-nosql,tm-ai-llm-mcp,tm-cicd-supply-chain).
Evidence & Quality Rules (Non-Negotiable)
- Zero hallucinated findings: Every threat MUST cite real
file:lineevidence (or exact config/IaC path) that you directly read. - Trace mitigations before reporting: Check middleware, guards, ORM parameterization, framework auto-escaping, and upstream validation before flagging an issue. Do not pad the report with theoretical boilerplate already mitigated in code.
- Label confidence honestly:
confirmed: Exploitable vulnerability or broken control verified directly in code/config.design-gap: Missing defense-in-depth control (e.g., no rate limit, no RLS, no audit log on sensitive action).assumption-dependent: Secure only if an external runtime control holds (e.g., reverse proxy strips spoofed headers).
- Read-only by default: Write the threat model artifacts (
docs/THREAT-MODEL.mdand optionallydocs/threat-model.json), but do not modify application code until the user invokesthreat-model-remediate(or explicitly asks to threat model and fix in one pass).
Workflow
Step 1: Apply STRIDE-per-Element Across Every Trust Boundary
Walk through each trust boundary (TB-*) and entry point from discovery using references/stride-per-element.md:
- Spoofing: Auth bypasses, missing middleware on routes, weak JWT/cookie/session verification, spoofable forwarded headers, unverified webhooks.
- Tampering: SQL/NoSQL/Command/Template/Header injection, mass assignment/BOPLA, CSRF, unsafe deserialization, path traversal, TOCTOU races, unsigned state/artifacts.
- Repudiation: Missing structured security logs for auth, privilege changes, exports, deletes, config changes; log injection (CWE-117); sensitive secrets logged (CWE-532).
- Information Disclosure: Cross-tenant BOLA/IDOR, verbose stack traces/errors, client bundle secret leaks, SSRF to cloud metadata/internal services, sensitive data in caches/URLs/logs, LLM/RAG cross-tenant leaks.
- Denial of Service: Missing rate limits or payload size caps, unbounded pagination/queries/GraphQL depth, ReDoS, archive/image decompression bombs, lock/resource exhaustion, unhandled panics/exceptions (OWASP A10:2025), unbounded LLM loops.
- Elevation of Privilege: Missing function-level authz (BFLA), horizontal/vertical IDOR, client-controlled role/tenant fields, container/IAM over-privilege, CI/CD
pull_request_targettakeover, AI tool misuse / excessive agency.
Step 2: Run Deep Stack-Specific Threat Hunts
Using the matching tm-* skills, actively inspect high-risk code paths:
- Every route/controller/action/resolver/RPC/MCP tool for default-deny authn + object-level authz + tenant scoping.
- Every database query, shell call, file operation, template render, deserializer, and outbound HTTP request.
- Auth flows (login, OAuth/OIDC callback, password reset, MFA, session rotation, API keys, webhooks).
- Configuration, secrets, CORS/CSP/cookies, Dockerfiles, Kubernetes/IaC manifests, and CI workflows.
- Error handling paths to verify fail-closed behaviour (OWASP A10:2025).
Step 3: Risk-Rate & Map Every Finding to Standards
For each real issue found, assign a unique ID (TM-001, TM-002, ...) and record:
- Severity:
critical|high|medium|low(derived from Likelihood x Impact, noting unauthenticated reachability and cross-tenant blast radius). - Confidence:
confirmed|design-gap|assumption-dependent. - STRIDE category(ies).
- Standards mapping:
- OWASP Top 10:2025 (
A01:2025throughA10:2025) - OWASP ASVS v5.0 chapter/control (
V1–V17) - Specialized OWASP when relevant (
API1:2023–API10:2023,LLM01–LLM10,ASI01–ASI10,MASVS-*) - CWE ID (
CWE-639,CWE-89,CWE-918, etc.) - MITRE ATT&CK technique (
T1190,T1078,T1552, etc.)
- OWASP Top 10:2025 (
- Attack Scenario: Concrete step-by-step exploit path an attacker would execute.
- Existing Controls: What partial defenses already exist.
- Recommended Remediation: Specific, idiomatic fix tailored to the repository's existing frameworks and OWASP Cheat Sheets.
- Verification / Regression Test: Concrete automated test that will prove the fix works.
Step 4: Write Threat Model Artifacts
- Create/update
docs/THREAT-MODEL.mdcontaining:- Executive Summary & severity count table
- System Scope, Assets, Actors, Entry Points, Trust Boundaries, Mermaid DFD, Assumptions
- Prioritized Threat Register (
Critical->High->Medium->Low) - Prioritized Remediation Roadmap (
P0->P3) - Verification & Sign-Off section (ready for
threat-model-remediateandthreat-model-verify)
- If the project tracks machine-readable threat models (or on user request), also write
docs/threat-model.jsonconforming totemplates/threat-model.schema.json. - Present a concise summary of the top confirmed findings and ask/proceed to
threat-model-remediateif requested.