threat-model
Skill4 starsChanged 8 months agoMITView on GitHub
Use this skill to create or update a STRIDE-based threat model for an application. Analyses the codebase to map components, data flows, trust boundaries, and assets, then enumerates threats using STRIDE and OWASP frameworks, scores risk, and maps remediations. Produces a living security-audit/threat-model.md (Mermaid diagrams included) that is updated incrementally on re-runs. Invoke as `/threat-model` (auto-detects scope) or `/threat-model full` to force a full regeneration. Trigger this skill whenever the user wants to: create a threat model, update a threat model, do threat analysis, map attack surface, apply STRIDE, check OWASP compliance, assess security architecture, or understand what threats apply to their application.
39 other projects use a version of this.
Adopted by
Most recently taken up by
- fmind/dottheir own version, first seen Oct 5, 2026
- aprameyak/coding-skillstheir own version, first seen Oct 2, 2026
- openai/codex-securitytheir own version, first seen Oct 2, 2026
- gonimar/claude-web-studiotheir own version, first seen Sep 27, 2026
- ryktara/Foundrytheir own version, first seen Sep 25, 2026
- antoniowolkk/junior-agenttheir own version, first seen Sep 22, 2026
Used with
Projects with it also use supply-chain-review, vuln-scan and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MesteriisSkillsupply-chain-review
Reviews lockfiles, installers, provenance, CI permissions, dependency confusion, artifacts, registries, and publishing.
Also in 3 projects that use this
AnthropicSkillvuln-scan
Static source-code vulnerability scan. Reads a target directory (and THREAT_MODEL.md if present), spawns parallel review subagents per focus area, and writes VULN-FINDINGS.json + .md for /triage to consume. Read-only — no building, running, or network. For execution-verified crashes, use vuln-pipeline instead. Use when asked to "scan for vulns", "review this code for security issues", "find bugs in <dir>", or as the step between /threat-model and /triage.
Also in 3 projects that use this
AnthropicSkillpatch
Generate candidate fixes for verified security findings. Consumes
Also in 3 projects that use this
fefogarciaSkilldependency-audit
Comprehensive dependency health auditing for JavaScript/TypeScript projects. Run npm audit, detect outdated packages, check for security advisories, and verify license compliance. Prioritises vulnerabilities by severity and provides actionable fix recommendations.
Also in 4 projects that use this
SentrySkillwrite-tests
Write tests following project conventions. Use when adding new tests or modifying existing ones.
Also in 3 projects that use this
SentrySkillsecurity-review
Finds exploitable application security vulnerabilities in code changes. Use for Warden security scans, appsec review, OWASP-style checks, authentication or authorization bugs, injection, XSS, SSRF, path traversal, secrets, unsafe crypto, webhook verification, open redirects, or sensitive data exposure.
Also in 5 projects that use this
- +2 more from anthropics
Other versions39 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 39
- openai/codex-security★ 11ksame name
- anthropics/defending-code-reference-harness★ 7.5ksame name
- openai/plugins★ 7.3ksame name
- 686f6c61/alfred-dev★ 116same name
- mbwsims/claude-universe★ 72same name
- alpha-omega-security/threat-model★ 58same name
- navikt/copilot★ 54same name
- Robotti-io/copilot-security-instructions★ 42same name
- thejefflarson/soundcheck★ 20same name
- epicsagas/epic-harness★ 19same name
29 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- security-arch-reviewSkill
- security-auditSkill
- security-scanSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 3 are distinctive, and 10 are very specific to this project.
0
Common
Most of the 35 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Before analysing any code, read the reference files in this skill's references/ directory.
- Distinctive: line 91
Read only the staged files plus enough surrounding context:
- Distinctive: line 92
Read each staged file in full
- Very specific: line 93
Read the existing security-audit/threat-model.md fully
- Distinctive: line 172
After STRIDE, scan against the applicable OWASP list (Top 10 for web apps, API Top 10 for APIs, LLM Top 10 if AI features detected).
- Very specific: line 176
After completing STRIDE analysis, read references/pytm-threats.json and for each component:
- Very specific: line 179
Add any flagged pytm threats not already captured by STRIDE analysis as new entries in the threat register, using the pytm SID as a …
- Very specific: line 180
Use the pytm mitigations field to supplement remediation guidance in Step 7
- Very specific: line 181
Use the pytm references field to add CAPEC/CWE links to threat entries
- Very specific: line 230
Create the security-audit/ directory if it does not exist (mkdir -p security-audit).
- Very specific: line 232
Full mode: If an existing security-audit/threat-model.md exists, first copy it to security-audit/threat-model-YYYYMMDD-HHMMSS.md as a …
- Very specific: line 234
Incremental mode: Update security-audit/threat-model.md in-place.
- Very specific: line 276
When CI_MODE is true, output a structured one-line summary as the final line:
“Common” is measured: kept by at least 6 in 10 of the 35 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Threat Model Skill
Step 1: Determine Mode
Parse all arguments. Arguments can be combined: /threat-model full --ci
Set flags:
CI_MODE=trueif--cipresent, otherwisefalseFORCE_FULL=trueiffullargument present, otherwisefalse
Then determine scope by checking for an existing security-audit/threat-model.md:
| Condition | Mode |
No security-audit/threat-model.md exists | Full (regardless of argument) |
security-audit/threat-model.md exists + no argument | Incremental (staged changes only) |
security-audit/threat-model.md exists + full argument | Full (regenerate from scratch) |
Why this matters: Incremental mode keeps the threat model current without expensive full analysis on every commit. Full mode is needed for initial creation or when architecture changes significantly.
For Incremental mode, run git diff --cached --name-only --diff-filter=ACM to get staged files. If no staged files are found and CI_MODE is false, tell the user and offer to switch to full mode. If CI_MODE is true and no staged files are found, exit with a pass (nothing to analyse).
Step 2: Read Reference Materials
Before analysing any code, read the reference files in this skill's references/ directory. These contain the frameworks applied in Step 5.
references/stride.md— STRIDE categories, per-category threat patterns, component-type matrixreferences/owasp-top10-2025.md— OWASP Web Top 10 (2025)references/owasp-api-top10-2023.md— OWASP API Security Top 10 (2023)references/owasp-llm-top10-2025.md— OWASP LLM Top 10 (2025) — read only if AI/LLM features are detectedreferences/cvss-scoring.md— CVSS v3 scoring guide and worked examplesreferences/pytm-threats.json— OWASP pytm threat library (113 curated threats). Each entry has:SID(unique ID),target(component types: Server, Process, Lambda, Datastore, Dataflow, LLM, ExternalEntity),description,severity,condition(security control properties that make the threat applicable),mitigations, andreferences(CAPEC/CWE links). Use this in Step 5 to cross-reference threats per component type.
Why this matters: Reading the reference material first ensures threat enumeration is systematic and consistent, not based on recall. The OWASP lists act as a checklist that prevents blind spots.
Step 3: Application Discovery
Full Mode
Systematically read the codebase to build an application profile. Read key files — do not just list them; understand what they do.
1. Tech stack — Read dependency manifests: package.json, requirements.txt, go.mod, Gemfile, pom.xml, build.gradle, Cargo.toml, composer.json. Note frameworks, major libraries, and runtime versions.
2. Entry points — Look for: route files in routes/, controllers/, handlers/, views/; top-level files like app.py, server.js, main.go, index.ts; CLI argument parsing; message queue consumers; scheduled jobs; file upload handlers; webhook receivers.
3. Data stores — Identify: ORM models in models/; raw SQL queries; Redis/cache clients; S3/blob storage; queue/topic definitions; search indexes.
4. Authentication and authorisation — Find: middleware in middleware/, auth/; JWT/session handling; OAuth flows; API key validation; role/permission checks and where they are enforced (or missing).
5. External integrations — Find: HTTP client calls to third parties; SDK imports; outbound webhooks; email/SMS senders.
6. User roles and actors — Look for: role enums, permission constants, distinct user types (anonymous, authenticated, admin, service account).
7. Sensitive data — Search for field/variable names containing: email, password, ssn, dob, credit, card, health, pii, token, secret, key, private, api_key.
8. Trust boundaries — Identify: where auth checks occur; what runs unauthenticated; what crosses network or process boundaries; what is exposed to the public internet vs. internal only.
9. Component type classification — Map each discovered component to the pytm taxonomy used in references/pytm-threats.json. This determines which threats apply at Step 5.
| pytm Type | Matches |
| Server | Web servers, app servers, API servers, load balancers |
| Process | Background workers, queue consumers, scheduled jobs, scripts |
| Lambda | Serverless functions, cloud functions |
| Datastore | Databases, caches (Redis), file storage, S3, queues |
| Dataflow | API calls, HTTP requests, database queries, message flows |
| LLM | Any AI/ML model endpoints, prompt handlers, embedding services |
| ExternalEntity | Third-party APIs, external users, browsers, mobile clients |
Also assess these security control properties for each component by reading its code — these map directly to pytm conditions:
sanitizesInput— does the component sanitize/escape user input?validatesInput— does it validate types, lengths, formats?encodesOutput— does it encode output (HTML escape, parameterized queries)?hasAccessControl— is access control enforced?authorizesSource— does it verify the caller's identity/permissions?checksInputBounds— are buffer/size limits checked?usesSessionTokens— does it use session or JWT tokens?protocol— HTTP or HTTPS?
Incremental Mode
Read only the staged files plus enough surrounding context:
- Read each staged file in full
- Read the existing
security-audit/threat-model.mdfully - Identify which components in the existing model are affected by the changes
- Note new entry points, data flows, data types, or auth changes introduced
Step 4: Architecture Synthesis
Build and write out the following. For incremental mode, update only the affected sections.
1. Application summary (2–3 sentences): what the app does, who uses it, what data it handles.
2. Actor inventory — table of all actors:
| Actor | Trust Level | Description |
| Authenticated User | Medium | Registered user with standard permissions |
| Admin | High | Internal operator with elevated access |
| Anonymous | None | Unauthenticated external party |
| External Service | Varies | Third-party API or webhook caller |
3. Asset inventory — table of what is worth protecting:
| Asset | Type | Sensitivity | Notes |
| User PII | Data | High | Names, emails, addresses |
| Auth tokens | Data | Critical | JWTs, API keys, session cookies |
| Payment data | Data | Critical | Card numbers, billing info |
| Admin endpoints | Functional | High | Can modify system state |
| Source code / IP | Infrastructure | Medium | Business logic |
Asset types: Data (PII, credentials, financial, health), Functional (admin endpoints, payment flows, config), Infrastructure (servers, CI/CD, secrets store).
4. Data Flow Diagram in Mermaid:
flowchart TD
A[Browser / Client] -->|HTTPS| B[Load Balancer]
B -->|HTTP| C[App Server]
C -->|SQL| D[(PostgreSQL)]
C -->|REST| E[Third-party API]
C -->|Write| F[S3 Storage]
style D fill:#f9f,stroke:#333
style E fill:#bbf,stroke:#333
style C fill:#bfb,stroke:#333Colour coding: pink = data stores, blue = external services, green = internal components. Annotate arrows with protocol and auth method where known.
5. Trust Boundary Map:
| Boundary | Controls Present | Gaps / Notes |
| Internet → Load Balancer | TLS 1.3, WAF | DDoS protection? |
| Load Balancer → App Server | Internal network | No mTLS |
| App Server → Database | VPC, credentials | No encryption at rest confirmed |
| App Server → External API | HTTPS, API key | Key rotation policy? |
Step 5: Threat Enumeration
Apply STRIDE exhaustively — every category against every significant component. Do not skip categories even when a threat seems unlikely; record it with a low score to show it was considered.
For each component × STRIDE category:
- State the threat scenario in one sentence grounded in the actual application
- Reference the relevant OWASP item if applicable
- Score: Likelihood (1–5) × Impact (1–5) = Risk Score (1–25)
- Note any existing controls already observed in the codebase (give credit)
- Note the CWE ID if known
STRIDE categories (see references/stride.md for full detail):
- Spoofing — can an attacker impersonate a user, service, or component?
- Tampering — can data be modified in transit or at rest without detection?
- Repudiation — can actors deny performing actions? Are audit logs present?
- Information Disclosure — can sensitive data leak to unauthorised parties?
- Denial of Service — can availability be disrupted?
- Elevation of Privilege — can an actor gain more permissions than intended?
After STRIDE, scan against the applicable OWASP list (Top 10 for web apps, API Top 10 for APIs, LLM Top 10 if AI features detected). Flag any OWASP items not already covered by STRIDE analysis.
Cross-reference with pytm threat library:
After completing STRIDE analysis, read references/pytm-threats.json and for each component:
- Filter threats where the component's pytm type appears in the threat's
targetarray - Evaluate the threat's
conditionagainst the control properties assessed in Step 3 — if the condition would evaluate to True (i.e. a control is absent), flag the threat - Add any flagged pytm threats not already captured by STRIDE analysis as new entries in the threat register, using the pytm
SIDas a cross-reference (e.g.pytm:INP01) - Use the pytm
mitigationsfield to supplement remediation guidance in Step 7 - Use the pytm
referencesfield to add CAPEC/CWE links to threat entries
This cross-reference catches threats that STRIDE enumeration might miss, particularly input validation attacks (INP category, 41 threats) and access control issues (AC category, 24 threats).
Every threat entry MUST include either:
- A code reference (file + line number or function name), OR
- The label
[Architectural inference — no direct code evidence]
This grounds the model in reality and prevents generic or hallucinated threats.
Step 6: Risk Register
Produce the full threat register table, sorted by Risk Score descending:
| ID | Component | STRIDE | Threat Scenario | Likelihood | Impact | Risk Score | OWASP Ref | CWE | Existing Controls | Status |
| T-001 | Login endpoint | Spoofing | Brute-force on POST /auth/login — no rate limiting observed in src/auth/login.js | 4 | 5 | 20 | A07:2025 | CWE-307 | bcrypt hashing present | Open |
Score ranges: Critical 20–25, High 12–19, Medium 6–11, Low 1–5.
For incremental re-runs: carry over all existing entries unchanged, add new entries for newly discovered threats, mark resolved entries as Mitigated if the staged changes addressed them.
Step 7: Remediation Mapping
High risks (Score ≥ 12): Produce a detailed entry per threat:
### T-001: Brute-force on Login (Risk: 20 — Critical)
**File:** src/auth/login.js:34
**Threat:** No rate limiting on POST /auth/login allows credential stuffing attacks
**Remediation:** Implement rate limiting middleware (e.g. express-rate-limit).
Limit to 5 attempts per IP per 15 minutes with exponential backoff.
**Effort:** Low (1–2 hours)
**OWASP:** A07:2025 — Identification and Authentication Failures
**Status:** [ ] OpenMedium risks (Score 6–11): Summary table with one-line remediation and effort estimate.
Low risks (Score 1–5): Group and note as accepted/monitor with brief rationale.
Step 8: Write security-audit/threat-model.md
Create the security-audit/ directory if it does not exist (mkdir -p security-audit). Save to security-audit/threat-model.md.
Full mode: If an existing security-audit/threat-model.md exists, first copy it to security-audit/threat-model-YYYYMMDD-HHMMSS.md as a snapshot, then overwrite.
Incremental mode: Update security-audit/threat-model.md in-place. Add a changelog entry at the top:
## Changelog
- **2026-03-25** — Incremental update: analysed staged changes to `src/auth/login.js`. Added T-019, updated T-007 to Mitigated.Document structure:
# Threat Model — [Application Name]
> Last updated: [date] | Mode: Full / Incremental | Version: N
## Changelog
## 1. Application Overview
## 2. Actors
## 3. Assets
## 4. Data Flow Diagram
## 5. Trust Boundaries
## 6. Threat Register
## 7. High-Risk Remediations
## 8. Medium-Risk Summary
## 9. Accepted / Low Risks
## 10. Security Scan Cross-ReferenceFor Section 10: if security-audit/security-scan-report.md exists in the current directory, read it and cross-reference scan findings with threat register entries. Note which scan findings map to which threat IDs, and which scan findings represent new threats not yet in the register.
Step 9: Summary to User
After saving, present:
- Total threats found, broken down by severity (Critical / High / Medium / Low)
- Top 3 highest-risk items (ID, scenario, score)
- Count of open remediations
- Path to the saved file
- For incremental runs: what changed vs. the previous run
CI Mode Exit
When CI_MODE is true, output a structured one-line summary as the final line:
THREAT MODEL: N threats (C critical, H high, M medium, L low), R open remediations — report: security-audit/threat-model.mdThen determine the exit outcome:
- Any Critical or High threats without an accepted mitigation → signal failure. Tell the user: "CI mode: threat model FAILED — unmitigated Critical/High threats present."
- No unmitigated Critical/High threats → signal success. Tell the user: "CI mode: threat model PASSED."
Threats with status Mitigated or Accepted Risk (with a documented reason) do not count as failures.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

