agentleFS
reddygopalkrishnareddygopalkrishna/developer-agent-skills/skills/threat-modeling/SKILL.md

threat-modeling

Skill8 starsChanged 9 days agoMITView on GitHub

Builds practical threat models - a data flow diagram with trust boundaries, STRIDE analysis per element, ranked threats, and mitigations turned into tracked work. Use when designing a new system or feature, reviewing a design doc or architecture for security, adding an external integration, auth flow, file upload, payment path or new data store, or when the user asks for a threat model or STRIDE analysis. Not for line-by-line code review (use security-audit).

45 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use iac-security, container-security and 7 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.
  • hardw00tSkill

    iac-security

    Infrastructure-as-Code security scanning router for Terraform, CloudFormation, Kubernetes manifests, Helm, ARM/Bicep. Orchestrates Checkov, tfsec, Terrascan, KICS, kubesec, kube-linter, Polaris, cfn-lint/cfn-nag, and OPA/Conftest. Use when auditing IaC for misconfigurations, scanning Terraform plans, validating K8s security policies, checking cloud infrastructure compliance, or authoring custom policy-as-code (Rego).

    Also in 4 projects that use this

  • vbrevikSkill

    container-security

    Scan container images, Dockerfiles, docker-compose files, and Kubernetes manifests for security misconfigurations and vulnerabilities. Uses Trivy for image/IaC scanning and Kubescape for K8s policy compliance. Falls back to regex-based Dockerfile and K8s YAML analysis when tools are unavailable. Produces STIG V-ID-tagged findings for /stig-compliance pipeline. Use when (1) reviewing Docker or K8s configuration changes, (2) scanning container images for OS-level CVEs, (3) validating K8s RBAC and NetworkPolicy configuration, (4) before deployment. Works air-gapped with pre-downloaded vulnerability database.

    Also in 4 projects that use this

  • wgpsecSkill

    prompt-injection

    AI/LLM 间接 Prompt 注入攻击。当目标 AI 系统会处理外部数据源(网页、文档、邮件、数据库、API 返回)时使用。覆盖间接注入、工具链劫持、RAG 投毒、数据外泄等技术。OWASP LLM Top 10 #1 漏洞类别

    Also in 4 projects that use this

  • allanninalSkill

    threat-hunting

    Hunt threats using Sigma detection rules and security analysis techniques. Use when investigating security incidents, creating detection rules, or analyzing suspicious activity.

    Also in 3 projects that use this

  • narlyseorgSkill

    secure-code-review

    Use when reviewing source code for security vulnerabilities, performing static analysis of a codebase, auditing code for injection flaws, authentication issues, cryptographic weaknesses, insecure deserialization, SSRF, path traversal, memory safety bugs, hardcoded secrets, or misconfigurations. Use when the user asks to find security bugs in code, assess code quality from a security perspective, or review pull requests for security implications. Use when performing dependency audits, secrets scanning, or configuration review of application source.

    Also in 3 projects that use this

  • jefflesterSkill

    api-security

    API security best practices and common vulnerability prevention. Enforces security checks for authentication, input validation, SQL injection, XSS, and OWASP Top 10 vulnerabilities. Use when building or modifying APIs.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 40 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before a security review, audit or launch.

    line 15
  2. Distinctive:

    After an incident, to find sibling threats.

    line 16
  3. Very specific:

    Not for: finding bugs in a specific diff (use security-audit and code-review-changes).

    line 18
  4. Distinctive:

    Scope it: Write down in 5-10 lines:

    line 22
  5. Distinctive:

    If you can't answer these from the code or docs, ask the user.

    line 27
  6. Distinctive:

    Keep it to the level where each arrow is a real network call or data movement.

    line 31
  7. Distinctive:

    Use a simple 3x3 unless the team already has a scale:

    line 88
  8. Distinctive:

    When a full model is overkill, answer in the PR description:

    line 109
  9. Distinctive:

    Run the STRIDE row for the new element only.

    line 113
  10. Distinctive:

    If any answer is "nothing handles it", either fix it in the PR or open a tracked item before merging.

    line 116
  11. Distinctive:

    After a security incident or a pentest finding in this area.

    line 123
  12. Distinctive:

    Every threat is specific, ranked, and has a response.

    line 140

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

A threat model answers four questions (Adam Shostack's framework): What are we working on? What can go wrong? What are we going to do about it? Did we do a good job? The output is not a document for its own sake. It is a short list of specific threats, each with a mitigation that someone owns.

When to use

  • A new service, feature or integration is being designed, or a design doc is up for review.
  • A change crosses a trust boundary: new public endpoint, third-party API, webhook, file upload, new tenant or role, new data store with sensitive data.
  • Before a security review, audit or launch.
  • After an incident, to find sibling threats.

Not for: finding bugs in a specific diff (use security-audit and code-review-changes). Not a compliance checklist.

Workflow

  1. Scope it. Write down in 5-10 lines:
    • What is being built and the boundary of this model (one feature, one service, the whole system).
    • Assets: what an attacker wants or what must not break (customer data, credentials, money movement, admin access, availability).
    • Actors: legitimate users and roles, admins, other services, third parties, and attackers (anonymous internet user, malicious tenant, compromised dependency, insider).
    • Assumptions: what you are trusting (cloud provider, identity provider, network controls). Wrong assumptions are a common root cause, so list them. If you can't answer these from the code or docs, ask the user. Do not invent the architecture.
  2. Draw a data flow diagram (DFD) in Mermaid. Use only four element types plus boundaries:
    • External entity (users, third-party systems), process (your code), data store (DBs, queues, buckets, caches), data flow (arrows, labeled with what moves and over what protocol).
    • Trust boundaries as subgraphs: internet vs your edge, your services vs data tier, tenant vs tenant, your system vs third parties. Keep it to the level where each arrow is a real network call or data movement. 5-15 elements is typical for a feature.
  3. Apply STRIDE per element. For each element, ask the STRIDE questions that apply to its type (table below). Spend most time on flows that cross a trust boundary. Read references/stride-questions.md for the question bank.
  4. Write each threat specifically: who does what, to which element, with what result. "An authenticated user of tenant A changes the tenantId in GET /invoices/{id} and reads tenant B's invoices" is a threat. "Hackers could access data" is not.
  5. Check existing controls. For each threat, look in the code and config for what already mitigates it (authz middleware, TLS, signed URLs, rate limits). Note gaps honestly.
  6. Rank each threat (see Ranking). Don't spend time ordering low-risk items.
  7. Decide a response for each: mitigate, eliminate (remove the feature or data), transfer (to a provider, with a contract), or accept (with a named owner who agrees). Prefer eliminating data you don't need.
  8. Record and track. Save the model next to the design (for example docs/threat-models/<feature>.md): scope, DFD, threat table, decisions. Turn each mitigation into a work item. Ask the user before creating tickets in an external tracker.
  9. Verify. Where practical, back mitigations with tests (an authz test that tenant A gets 404 for tenant B's object, a test that oversized uploads are rejected).

DFD example

flowchart LR
  user([Browser user])
  stripe([Payment provider])
  subgraph edge [Trust boundary: public edge]
    api[API service]
  end
  subgraph internal [Trust boundary: private network]
    worker[Billing worker]
    db[(Postgres: invoices)]
    q[(Queue: billing-events)]
  end
  user -- "HTTPS: login, GET/POST invoices" --> api
  api -- "SQL over TLS" --> db
  api -- "publish invoice.created" --> q
  q -- "consume" --> worker
  worker -- "HTTPS: create charge" --> stripe
  stripe -- "HTTPS webhook: charge.succeeded" --> api

The webhook from the payment provider into the public API is a boundary crossing worth the most attention (spoofed webhooks, replay).

STRIDE

ThreatProperty violatedExampleTypical mitigations
SpoofingAuthenticationForged webhook; stolen session cookie; service impersonationStrong authN, MFA, signed webhooks, mTLS or workload identity
TamperingIntegrityModified request params, message on queue altered, unsigned artifactServer-side validation, signatures/HMAC, TLS, DB constraints, immutable logs
RepudiationNon-repudiationUser denies issuing a refund; no record of admin actionAudit log with actor, action, target, time; tamper-resistant storage
Information disclosureConfidentialityIDOR, verbose errors, secrets in logs, public bucketObject-level authz, least privilege, encryption, redaction, private by default
Denial of serviceAvailabilityUnbounded uploads, expensive queries, retry stormsRate limits, quotas, timeouts, size limits, pagination, autoscaling limits
Elevation of privilegeAuthorizationUser calls admin endpoint; container escape; mass assignmentDeny by default, server-side role checks, allowlisted fields, sandboxing

Which STRIDE categories apply to which element

ElementSTRIDE
External entityyesyes
Processyesyesyesyesyesyes
Data storeyesif it holds logsyesyes
Data flowyesyesyes

This is the classic STRIDE-per-element mapping. Use it to avoid both skipping categories and asking nonsensical ones.

Ranking

Use a simple 3x3 unless the team already has a scale:

Impact lowImpact mediumImpact high
Likelihood highMediumHighCritical
Likelihood mediumLowMediumHigh
Likelihood lowLowLowMedium
  • Likelihood: how reachable is it (anonymous internet vs authenticated insider), how much skill is needed, is it already exploited in the wild for this pattern.
  • Impact: data exposed (whose, how much), money, safety, regulatory, blast radius across tenants.
  • Critical and High need a mitigation before launch or an explicit, owned acceptance.

Threat table template

IDElement / flowSTRIDEThreatExisting controlsLIRiskResponseMitigation / work itemOwner
T1Webhook: provider to APIS, TAttacker posts forged charge.succeeded, invoice marked paidNoneHHCriticalMitigateVerify provider signature and timestamp; reject replays older than 5 min; idempotency on event ID
T2API: GET /invoices/{id}I, EUser of tenant A reads tenant B invoice by IDAuth requiredMHHighMitigateScope every query by tenant from the session, not the request; add cross-tenant test

Lightweight version (single PR or small feature)

When a full model is overkill, answer in the PR description:

  1. What does this change expose or accept that it didn't before (new input, endpoint, permission, data)?
  2. Which trust boundary does it cross?
  3. Run the STRIDE row for the new element only.
  4. List the 1-3 most likely threats and what in the diff handles each.

If any answer is "nothing handles it", either fix it in the PR or open a tracked item before merging.

When to revisit

  • A new trust boundary, data store, external integration or role is added.
  • Authentication or authorization logic changes.
  • Sensitive data types are added (payments, health, government IDs, credentials).
  • After a security incident or a pentest finding in this area.
  • At least once a year for critical systems.

Anti-patterns

  • Generic threats: "SQL injection", "DDoS" with no element and no scenario. Tie each threat to an element and a concrete attacker action.
  • Boiling the ocean: modeling the whole company in one sitting. Scope to the change; models can be linked.
  • Architecture diagram instead of a DFD: boxes for every class or pod. Show data movement and boundaries only.
  • Threats without owners: a table that nobody tracks. Every Critical/High needs a work item and an owner.
  • Ignoring non-internet attackers: malicious tenants, compromised dependencies, CI systems and insiders are frequent real attackers.
  • One-time exercise: a model that is never updated drifts from reality within months.
  • Mitigation by assumption: "the network is private" or "the frontend validates it" are not controls.

Done when

  • Scope, assets, actors and assumptions are written down.
  • A DFD exists with trust boundaries, and every boundary-crossing flow has been through STRIDE.
  • Every threat is specific, ranked, and has a response; every Critical/High has a mitigation or an owned acceptance.
  • Mitigations exist as tracked work items (created with the user's OK) and the model is saved next to the design.

References

  • references/stride-questions.md — read during step 3 for the question bank per STRIDE category and element type.

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.