Works with the AI Agents you already use

    Threat Modeling — STRIDE, Data Flow Diagrams, Abuse Cases

    by Cristhian Zanforlin Lousa

    1

    Design-time threat modeling: DFD with trust boundaries, STRIDE per element, every threat mapped to a control and a test.

    Free

    Security scanned
    Threat Modeling — STRIDE, Data Flow Diagrams, Abuse Cases

    Threat Modeling — STRIDE, Data Flow Diagrams, Abuse Cases

    Example session with this skill installed

    Threat model this feature before we build it.

    Feature: shareable invoice links

    • A signed-in user (invoice owner) clicks "Share" on an invoice and gets a link like https://app.example.com/i/<token>.
    • Anyone with the link can view the invoice PDF and pay it via Stripe Checkout, without an account.
    • Links expire after 30 days; the owner can revoke a link at any time.
    • Stack: Node.js API, Postgres (invoices, share_links), PDFs in a private S3 bucket, Stripe Checkout + a checkout.session.completed webhook that marks the invoice paid.
    • Invoices contain the client's name, billing address, email, line items and amounts.
    • PM is Dana; she decides on accepted risks.
    • Read your context and instructions
    • Compiled the threat modeling

    Summary. One feature, three trust boundaries, eleven threats. The two highest risks are guessable or leaked share tokens (any invoice readable by strangers) and a spoofed Stripe webhook (invoices marked paid without payment). Ten threats get a control and a test; one, a client forwarding a valid link, is proposed as an accepted risk pending Dana's sign-off. Model dated 2026-10-08.


    1. What are we working on?

    Assets

    • Invoice data: client PII (name, billing address, email), line items, amounts.
    • Share tokens: possession of one grants read and pay access.
    • Payment state: the "paid" flag on an invoice (money-movement adjacent).
    • Availability of the public invoice page.

    Scope. In scope: create/revoke link, view via link, pay via link, Stripe webhook. Out of scope this pass: the owner's login/session (covered by the existing auth model), Stripe's own infrastructure.

    Data Flow Diagram

                  ┌──────────────── TB1: internet edge ────────────────┐
     [E1 Owner] ──F1 create/revoke──▶                                   │
     [E2 Link holder] ──F2 GET /i/<token>, POST pay──▶ (P1 API service) │
                  └─────────────────────────────────────────────────────┘
                              │ F6 SQL                 │ F3 presign GET
                              ▼                        ▼   ── TB3: cloud storage ──
                      ═DS1 Postgres═            ═DS2 S3 PDFs═ (private)
                                                       │
                   ── TB2: third party ──              │
     (P1) ──F4 create Checkout session──▶ [E3 Stripe]  │
     (P1) ◀──F5 webhook checkout.session.completed── [E3 Stripe]
    
    IDElementType
    E1Invoice owner (authenticated)External entity
    E2Link holder (anonymous)External entity
    E3StripeExternal entity
    P1API serviceProcess
    DS1Postgres: invoices, share_linksData store
    DS2S3 bucket: invoice PDFsData store
    F1–F6Flows shown aboveData flow

    Boundary crossings: F1, F2 (TB1); F4, F5 (TB2); F3 plus the presigned URL handed to E2 (TB3).

    2. What can go wrong? (STRIDE per element)

    #Element / flowSTRIDEThreat scenario
    T1E2 → F2SAttacker guesses or enumerates tokens and reads other people's invoices.
    T2F1 → P1EOwner in org A creates or revokes a link for an invoice in org B by changing the invoice ID (IDOR).
    T3F2IToken leaks through access logs, analytics or the Referer header sent to third-party scripts on the invoice page.
    T4P1IRevoked or expired link still serves the PDF, or a presigned S3 URL stays valid long after revocation.
    T5DS2IBucket or object ACL made public; PDF keys are predictable (invoices/<id>.pdf).
    T6F2 (pay)THolder edits the pay request to change the amount or currency.
    T7F5 → P1S, TForged or replayed webhook marks an invoice paid without payment.
    T8E1, P1ROwner denies sharing a link, or there is no record of who viewed or paid.
    T9P1, DS2DFlooding /i/<token> drives PDF rendering and S3 egress costs.
    T10F6 → DS1TToken value used in an unparameterized lookup query (injection).
    T11E2I (LINDDUN: disclosure)Client forwards a valid link; a third party sees the client's PII.

    Abuse cases

    • As an opportunistic scraper, I want to iterate /i/<token> so that I can harvest invoices with names and addresses (T1, T9).
    • As a customer, I want to pay less than I owe by editing the checkout request (T6).
    • As an attacker who knows the webhook URL, I want to POST a fake checkout.session.completed so that my invoice shows as paid (T7).
    • As a former client with an old link, I want to keep reading invoices after the relationship ended (T4).

    Attacker personas: anonymous scraper (high likelihood, low skill), dishonest customer, former client, a user of another tenant.

    3. What are we going to do about it?

    Risk = likelihood × impact (L/M/H).

    #RiskResponseControlTest
    T1H×HMitigate256-bit token from a CSPRNG; store only sha256(token); per-IP rate limit on 404s from /i/*Unit: token length/charset; DB row holds no plaintext token. Integration: N+1 misses from one IP return 429
    T7M×HMitigateVerify Stripe-Signature with the endpoint secret and timestamp tolerance; process each event ID onceIntegration: unsigned payload → 400 and invoice stays unpaid; replayed event ID → no second state change
    T2M×HMitigateObject-level authz: load invoice by id AND org_id = caller.org_idIntegration: user A shares B's invoice → 404, no share_links row
    T6M×HMitigateAmount and currency read server-side from the invoice; request carries only the tokenIntegration: POST with amount=1 → Checkout session amount equals invoice total
    T3M×MMitigateReferrer-Policy: no-referrer on /i/*; no third-party scripts on that page; redact /i/<token> in access logsUnit: log redactor masks token. Integration: response header asserted
    T4M×MMitigateCheck revoked_at and expires_at on every request; presigned URLs expire in ≤ 60 sIntegration: revoke then GET → 410; presigned URL TTL asserted
    T5L×HMitigateBlock Public Access on the bucket; random object keys; access only via presigned URLIaC policy check in CI; unsigned GET on an object → 403
    T9M×MMitigateCache rendered PDF per invoice version; rate limit per IP and per tokenIntegration: request burst returns 429 after the configured limit
    T8L×MMitigateAppend-only audit log for link created, revoked, viewed, paid (actor or token hash, time, IP)Integration: create link → one audit row with actor ID
    T10L×HMitigateParameterized queries onlyIntegration: token with SQL metacharacters → 404, no error leak
    T11M×MAccept (proposed)Bearer-link model is the product design; mitigated in part by expiry and revokeAccepter: Dana (PM). Pending sign-off, not yet accepted

    4. Did we do a good job?

    • Coverage: E1–E3 checked for S/R; P1 for all six; DS1/DS2 for T/I/D; F1–F6 for T/I/D. Every boundary crossing has at least one threat with a response.
    • Highest risks got the strongest controls: T1 and T7 each have a preventive control and a negative test.
    • Re-model when: links are sent by email from our system (new third party), partial payments are added, or invoices gain attachments.
    • Follow-through: this model is not done until the tests above exist in the codebase. Today they are planned, not written.

    Next steps

    1. Open work items for T1, T7, T2 and T6 first (highest risk), each with its test as the definition of done.
    2. Get Dana's decision on T11 and record it with her name and date.
    3. Hand the controls to implementation (developing-features), then confirm at PR time that they shipped (reviewing-code).

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Most security bugs are design flaws: a trust boundary nobody drew, an authorization check that only exists on the client, a webhook nobody verifies. Code review rarely catches them. This skill makes your agent find them while the design is still cheap to change.

    It follows Adam Shostack's Four Question Framework:

    1. What are we working on? List the assets, build a Data Flow Diagram (external entities, processes, data stores, data flows) and mark every trust boundary. Scope it to one feature or service.
    2. What can go wrong? Apply STRIDE per element (only the categories that apply to each element type) and add abuse cases and attacker personas.
    3. What are we going to do about it? Every threat gets a response (mitigate, eliminate, transfer, accept). Every mitigation names a concrete control and a test that would fail if the control regressed. Accepted risks name who accepted them.
    4. Did we do a good job? Check coverage, date the model, and redo it when a new data flow, boundary, third party, auth path or category of PII appears.

    Reference files:

    • stride.md: the six categories, the property each violates, example threats and mitigations, and the STRIDE-per-element table.
    • dfd-and-scope.md: DFD element types, where to draw trust boundaries, how to scope, and a worked password-reset example.
    • methodologies-and-risk.md: when to use PASTA, Attack Trees, LINDDUN (privacy), VAST or OCTAVE; likelihood × impact ranking, and the problems with DREAD and CVSS for design-time threats.

    It triggers on requests like "threat model this", "run STRIDE", "what could go wrong with this feature", "map the attack surface" or "draw a data flow diagram". A learnings/ folder stores project-specific assets, personas and accepted risks, and those notes override the defaults.

    What sets it apart: a threat list counts as unfinished until each item maps to a control and a test.

    Free and MIT-licensed, part of the claude-skills-czl collection.

    Source on GitHub: this skill · full repository

    A design-time analysis returned in the conversation; it does not scan or change code. Its quality depends on the architecture details you provide, and accepted risks remain your decision.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 9 days ago

    • Free with an Agensi account

    Permissions

    Read Files

    File Scopes

    learnings/**

    - Reads files: yes. It reads its own `learnings/` folder first, plus any design docs or code you point it to. - Edits files: it does not change your code. Its only write is an optional new note in its own `learnings/` folder (`learnings/YYYY-MM-DD-slug.md`), and only when it finds a reusable asset, persona, accepted risk or recurring threat pattern. - Shell commands: none required. - Network access: none. - Git / GitHub: none. It does not commit, push or open issues. The threat model is returned in the conversation.

    Listed9 days ago

    What's inside

    Frequently Asked Questions

    Yes. It is a standard SKILL.md folder with plain Markdown references, so any agent that loads SKILL.md skills can use it. It was built and tested mostly on Claude Code.

    No. It produces a threat model in the conversation: assets, a DFD, a STRIDE table, and threat → control → test mappings. The only file it may write is a short note in its own `learnings/` folder.

    Ask for a threat model, a STRIDE pass, an attack-surface map, abuse cases, trust boundaries, or "what could go wrong with this feature?". In Claude Code you can also invoke it by name.

    A code review checks code that already exists. This skill runs before the code is written and looks for design flaws, such as missing boundaries and unverified assumptions. Pair it with `security-review` to cover the implementation.

    Unzip it into `~/.claude/skills/` (all projects) or into your project's `.claude/skills/` (that project only), so the path is `.../skills/threat-modeling/SKILL.md`.

    New in Security

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.

    Free