agentleFS
mindfortaimindfortai/security-skills/skills/threat-model/SKILL.md

threat-model

Skill16 starsChanged 5 months agoMITView on GitHub

Produces a professional red-team application security threat model as a standalone HTML report. Use when mapping architecture, data flows, trust boundaries, attack surface, and realistic abuse cases.

57 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use vuln-scan, patch 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.
  • AnthropicSkill

    vuln-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 5 projects that use this

  • AnthropicSkill

    patch

    Generate candidate fixes for verified security findings. Consumes

    Also in 4 projects that use this

  • mbwsimsSkill

    orbit

    Run for repo-wide or diff-wide readiness sweeps: "/orbit", "/orbit pr", "/orbit deep", "/orbit quick", "audit this project", "project-wide review", "is this PR ready overall", or "combined security, tests, codebase, evolution, and instruction review". Use this for broad multi-system assessment, not for a single-file review or a one-domain question.

    Also in 3 projects that use this

  • mbwsimsSkill

    test-plan

    This skill should be used when the user asks to "plan tests", "what should I test", "what tests do I need", "test plan for", "testing strategy for", "test matrix for", "what cases should I cover", "help me plan tests", mentions "/test-plan", or wants to understand what tests are needed before writing any test code.

    Also in 3 projects that use this

  • Sagargupta16Skill

    dependency-audit

    Audit project dependencies for security vulnerabilities, licensing issues, maintenance health, and optimization opportunities. Use it during regular security audits (monthly or quarterly); before a major release when you want to ensure the dependency tree is clean; when evaluating whether to adopt or replace a dependency; after a security advisory affects one of your dependencies; when your install times or bundle sizes have grown noticeably.

    Also in 4 projects that use this

  • patrickserranoSkill

    performance-audit

    Audit and improve SwiftUI runtime performance. Use for requests to diagnose slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, or layout thrash in SwiftUI apps.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

25 rules. 0 are common, 21 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 51 edited versions we read keep these.

  • 21

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when the user wants a full application-security threat model of a repository, delivered as a polished standalone HTML page.

    line 9
  2. Very specific:

    Use templates/threat-model-report.html from this skill as the visual and structural template when available.

    line 23
  3. Distinctive:

    No external JavaScript, fonts, images, trackers, or CDN assets.

    line 28
  4. Distinctive:

    No hidden dependencies on local build tooling.

    line 29
  5. Distinctive:

    Prefer system-specific threat scenarios over generic STRIDE filler.

    line 35
  6. Distinctive:

    Treat missing security boundaries, missing tests, and unclear ownership as reportable risks when they materially affect security.

    line 39
  7. Distinctive:

    Do not run dependency installation, migrations, destructive commands, production network calls, or broad scanners unless the user …

    line 64
  8. Distinctive:

    Create an internal working model with these elements:

    line 68
  9. Distinctive:

    If the system is too large to understand exhaustively in one pass, prioritize high-risk flows and explicitly list coverage limits.

    line 79
  10. Distinctive:

    Use repository-specific evidence to identify plausible abuse cases and threat scenarios.

    line 83
  11. Distinctive:

    Do not include step-by-step exploitation instructions or payloads.

    line 114
  12. Very specific:

    Use evidence to justify ratings.

    line 125
  13. Very specific:

    Use status values such as confirmed, likely, needs_validation, design_risk, accepted_control, or no_confirmed_findings.

    line 135
  14. Very specific:

    If no confirmed risks are found, still emit the header and one no_confirmed_findings informational row in the risk register.

    line 149
  15. Distinctive:

    Use tables for inventories and risk registers.

    line 172
  16. Distinctive:

    Do not hide uncertainty inside confident prose.

    line 180
  17. Distinctive:

    Use temporary stubs only to isolate unavailable external services, credentials, nondeterministic providers, or slow dependencies.

    line 182
  18. Distinctive:

    When subagents are available, ask an independent subagent to challenge high or critical threat scenarios for reachability, impact, …

    line 184
  19. Distinctive:

    Before finalizing the HTML:

    line 188
  20. Distinctive:

    Ensure the report is readable without external assets.

    line 191
  21. Distinctive:

    Ensure no placeholder text remains.

    line 192
  22. Distinctive:

    Ensure every high or critical risk has a recommended mitigation and validation plan.

    line 193
  23. Distinctive:

    Ensure the appendix lists commands run and files reviewed.

    line 194
  24. Distinctive:

    Ensure the report does not contain unsafe exploitation instructions.

    line 195
  25. Distinctive:

    If the user asks only for the artifact, keep the chat response brief and point to the generated HTML file.

    line 208

“Common” is measured: kept by at least 6 in 10 of the 51 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Threat Model

Use this skill when the user wants a full application-security threat model of a repository, delivered as a polished standalone HTML page.

This is not a checklist exercise. The agent must first understand how the system works, then model how it can fail under realistic adversarial pressure. The output should help engineers and security reviewers make decisions.

This skill is written for Claude Code, Codex, Cursor, and similar coding agents. Tool names vary by environment; use the local equivalents for file search, file reading, command execution, and writing the final report.

Deliverable

Produce a standalone HTML report, preferably named:

appsec-threat-model.html

Use templates/threat-model-report.html from this skill as the visual and structural template when available. If the environment cannot directly read skill template files, recreate the same structure from the required report sections below.

The final report must be self-contained:

  • Inline CSS only.
  • No external JavaScript, fonts, images, trackers, or CDN assets.
  • No hidden dependencies on local build tooling.
  • Clean typography, clear hierarchy, readable tables, and printable layout.

Operating Principles

  • Understand before judging. Do not write the threat model until the architecture, trust boundaries, entry points, and sensitive data flows are grounded in repository evidence.
  • Prefer system-specific threat scenarios over generic STRIDE filler.
  • Model realistic attacker paths without providing weaponized exploit instructions, payload catalogs, persistence steps, credential theft workflows, or third-party attack guidance.
  • Tie every important claim to code, config, docs, tests, or explicit uncertainty.
  • Separate confirmed design facts from inferred behavior and unknowns.
  • Treat missing security boundaries, missing tests, and unclear ownership as reportable risks when they materially affect security.

Phase 1: Repository Comprehension

Build a codebase map before threat modeling.

Inspect, when present:

  • README, architecture docs, API docs, runbooks, deployment docs, ADRs, and diagrams.
  • Package manifests, lockfiles, workspace files, monorepo config, and build scripts.
  • Route definitions, controllers, handlers, RPC services, GraphQL resolvers, workers, CLIs, cron jobs, webhooks, and event consumers.
  • Auth, session, identity, tenant, role, permission, policy, and middleware code.
  • Database schema, migrations, ORM models, storage clients, queues, caches, search indexes, and external integrations.
  • Infrastructure-as-code, Dockerfiles, compose files, Kubernetes manifests, Terraform, CI/CD workflows, release scripts, and secrets/config examples.
  • Tests around authentication, authorization, validation, tenancy, and critical workflows.

Useful discovery commands when available:

rg --files
git status --short
find . -maxdepth 3 -type f
rg -n "auth|session|token|tenant|org|role|permission|policy|admin|webhook|secret|encrypt|decrypt|jwt|oauth|saml|csrf|cors|rate|limit"

Do not run dependency installation, migrations, destructive commands, production network calls, or broad scanners unless the user explicitly approves them or the repo workflow clearly permits them.

Phase 2: Build The System Model

Create an internal working model with these elements:

  • Product purpose: what the application exists to do.
  • System shape: frontend, backend, jobs, agents, data stores, third-party services, deployment boundaries, and operational surfaces.
  • Actors: anonymous users, authenticated users, admins, support users, service accounts, internal services, external providers, CI/CD actors, and attackers.
  • Sensitive assets: credentials, sessions, API keys, tokens, PII, payment data, customer data, tenant data, prompts, model outputs, audit logs, source code, infrastructure credentials, and administrative controls.
  • Entry points: routes, APIs, webhooks, file uploads, importers, parsers, URL fetchers, background workers, queues, CLIs, browser surfaces, extensions, model/tool interfaces, and admin panels.
  • Trust boundaries: browser to server, tenant to tenant, user to admin, app to third party, app to database, app to worker, worker to infrastructure, model output to tool execution, CI to deployment, and local config to runtime.
  • Data flows: how sensitive data enters, moves, transforms, leaves, and is logged or cached.
  • Security controls: authentication, authorization, validation, output encoding, CSRF, CORS, rate limits, audit logging, encryption, secret storage, sandboxing, network controls, and test coverage.

If the system is too large to understand exhaustively in one pass, prioritize high-risk flows and explicitly list coverage limits.

Phase 3: Red-Team AppSec Threat Modeling

Use repository-specific evidence to identify plausible abuse cases and threat scenarios.

Analyze at least these domains when applicable:

  • Authentication and account lifecycle: signup, login, logout, password reset, SSO, OAuth/SAML, magic links, invitation flows, account linking, API keys, service accounts, and token rotation.
  • Authorization and tenant isolation: object-level access, role checks, organization membership, admin boundaries, support access, sharing, exports, bulk operations, background jobs, and indirect object references.
  • Data exposure: logs, telemetry, traces, error messages, analytics, browser storage, caches, exports, generated files, object storage, client bundles, and support tools.
  • Unsafe input handling: SQL/NoSQL injection, shell invocation, template injection, path traversal, archive extraction, deserialization, XML/YAML parsing, SSRF, URL previewers, file uploads, and content processing.
  • Agentic or LLM surfaces: prompt injection, untrusted model output controlling tools, tool permission boundaries, browser automation, retrieval poisoning, memory poisoning, and cross-tenant context leakage.
  • Business logic abuse: workflow state changes, billing, quotas, trials, referrals, approvals, invitations, reset flows, marketplace/actions, and race conditions.
  • Supply chain and deployment: package scripts, CI permissions, release workflows, container hardening, dependency pinning, generated code, secrets in build logs, artifact provenance, and environment separation.
  • Resilience and abuse prevention: rate limits, timeout behavior, retry loops, idempotency, queue poisoning, expensive operations, storage exhaustion, and unauthenticated resource consumption.
  • Cryptography and secrets: password hashing, randomness, signing, encryption, key management, webhook signatures, JWT verification, config defaults, and local development secrets.

Threat Scenario Standard

Each meaningful threat scenario should include:

  • Scenario title.
  • Affected component or flow.
  • Attacker starting position.
  • Preconditions.
  • Trust boundary crossed.
  • Attack narrative at a safe, non-weaponized level.
  • Impact.
  • Existing controls observed in the repo.
  • Gaps or weak assumptions.
  • Recommended mitigations.
  • Validation approach.
  • Residual risk after mitigation.

Do not include step-by-step exploitation instructions or payloads. The purpose is to help defenders fix design and implementation risk.

Risk Rating

Rate risks using likelihood, impact, and confidence:

  • Likelihood: Low, Medium, High.
  • Impact: Low, Medium, High, Critical.
  • Confidence: Low, Medium, High.
  • Priority: P0, P1, P2, P3.

Use evidence to justify ratings. Keep confidence low when code paths, deployment controls, or production assumptions are unclear.

Findings CSV

The report's risk register and any chat summary of risks must use this exact CSV header:

id,severity,confidence,status,category,title,location,asset_or_flow,actor,issue,impact,evidence,fix,test,scope_notes

Use status values such as confirmed, likely, needs_validation, design_risk, accepted_control, or no_confirmed_findings. Use category values such as authorization, authentication, data-exposure, injection, ssrf, file-access, llm-agent, business-logic, supply-chain, resilience, crypto, or tests.

For threat scenarios, use:

  • location: primary code, config, report section, or component reference.
  • asset_or_flow: sensitive asset, trust boundary, or data flow.
  • actor: realistic attacker starting position.
  • issue: threat scenario and failed security property.
  • impact: likely customer, tenant, data, operational, or business consequence.
  • evidence: repo facts, inferred architecture, or explicit missing evidence.
  • fix: recommended mitigation.
  • test: validation plan or regression test.
  • scope_notes: priority, likelihood, residual risk, or coverage limit.

If no confirmed risks are found, still emit the header and one no_confirmed_findings informational row in the risk register.

Required HTML Report Structure

The report must include:

  1. Title block with repo name, date, reviewer/agent, scope, and commit or branch when available.
  2. Executive summary.
  3. Scope and methodology.
  4. System overview.
  5. Architecture inventory.
  6. Trust boundaries.
  7. Sensitive assets.
  8. Entry points and attack surface.
  9. Data-flow summary.
  10. Threat scenarios.
  11. Risk register as a CSV-formatted table using the standard findings header.
  12. Security controls observed.
  13. Gaps and recommended roadmap.
  14. Validation plan.
  15. Review coverage and limitations.
  16. Appendix with key files reviewed and commands run.

Use tables for inventories and risk registers. Use compact visual blocks for severity and priority. Use code path references for evidence.

Evidence Rules

  • Link or reference concrete files and functions using repo-relative paths.
  • For claims based on config or tests, name the relevant file.
  • For inferred architecture, mark it as inferred.
  • For unknown production behavior, mark it as unknown and explain what evidence would resolve it.
  • Do not hide uncertainty inside confident prose.
  • Where locally testable, run focused smoke tests, existing tests, static checks, or local harnesses to validate high-priority risks before placing them in the risk register.
  • Use temporary stubs only to isolate unavailable external services, credentials, nondeterministic providers, or slow dependencies. Do not stub the trust boundary, policy, approval gate, tenant filter, or parser behavior being modeled.
  • Clean up scratch files, temporary fixtures, mock servers, local config changes, generated harnesses, and ad hoc scripts before finalizing the report unless the user asked for durable tests.
  • When subagents are available, ask an independent subagent to challenge high or critical threat scenarios for reachability, impact, confidence, and whether observed controls already mitigate them.

Output Quality Bar

Before finalizing the HTML:

  • Open or inspect the file enough to verify it is valid HTML with one <!doctype html>, one <html>, and balanced major sections.
  • Ensure the report is readable without external assets.
  • Ensure no placeholder text remains.
  • Ensure every high or critical risk has a recommended mitigation and validation plan.
  • Ensure the appendix lists commands run and files reviewed.
  • Ensure the report does not contain unsafe exploitation instructions.

Agent Workflow

  1. Confirm scope if the user has not provided one and the repo is ambiguous.
  2. Discover the repo structure and Git state.
  3. Build the system model from code, docs, config, and tests.
  4. Identify trust boundaries, assets, entry points, and data flows.
  5. Threat model high-risk flows deeply.
  6. Draft the report using the HTML template.
  7. Validate the HTML artifact for completeness and readability.
  8. Report the output path and summarize the top risks in chat.

If the user asks only for the artifact, keep the chat response brief and point to the generated HTML file.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.