agentleFS
MaheshAwasareMaheshAwasare/claude-skills-pro/skills/threat-modeling-stride/SKILL.md

threat-modeling-stride

Skill1 starsChanged 7 months agoMITView on GitHub

Threat-model a system using STRIDE — Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege. Walks through data flow diagrams, trust boundaries, and per-component threat enumeration with mitigations. Use before adding auth/payments/PII handling, after a near-miss, or as part of a secure SDLC.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before significant external exposure (public API, mobile app, third-party integration).

    line 14
  2. Distinctive:

    After a near-miss / minor incident, before the next variant happens.

    line 15
  3. Distinctive:

    Don't over-engineer the diagram.

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

STRIDE Threat Modeling

STRIDE is the most-used threat modeling methodology. It scales from a 30-minute napkin model to a multi-day deep dive. This skill is the engineering-grade walkthrough that produces an actionable risk register.

When to use

  • Designing new auth, payments, or PII-handling flows.
  • Architecture review for a new service.
  • Before significant external exposure (public API, mobile app, third-party integration).
  • After a near-miss / minor incident, before the next variant happens.
  • Annual security review (lighter pass).

When NOT to use

  • Internal tooling with low blast radius (still useful, but proportional effort).
  • Pure compliance-driven model with no engineering follow-through — wasted artifact.

STRIDE in one table

LetterThreatProperty violated
SpoofingPretending to be someone elseAuthentication
TamperingModifying data/code maliciouslyIntegrity
RepudiationDenying having done somethingNon-repudiation
Information DisclosureLeaking dataConfidentiality
Denial of ServiceMaking system unusableAvailability
Elevation of PrivilegeGaining unauthorized capabilitiesAuthorization

For each component / flow / trust boundary, ask: how could each of these go wrong?

The workflow

1. Draw the data flow diagram (DFD)

Identify:

  • External entities (users, third-party services).
  • Processes (your services, functions).
  • Data stores (DBs, S3, queues).
  • Data flows (arrows between).
  • Trust boundaries (where trust changes — internet ↔ VPC, app ↔ DB).

Don't over-engineer the diagram. A whiteboard photo is fine. The point is to make implicit interactions explicit.

                Internet (untrusted)
                       |
                       v
                   [Cloudflare]
                       |  --- Trust boundary ---
                       v
                   [API gateway]
                       |
                       v
              [auth-service] -----> [Postgres (auth)]
                       |
                       v
              [payment-service] --> [Postgres (payments)]
                       |
                       +-> [Razorpay API] (third-party, external trust)
                       |
                       +-> [Brevo API]

2. Per component, walk STRIDE

For each process, data store, and data flow, ask the 6 STRIDE questions. Not every threat applies to every element — fine.

Example: payment-service process

STRIDEThreatMitigation in placeResidual
SAttacker calls payment-service directly bypassing API gatewayService has no public IP; mTLS between gateway and serviceLow
TAttacker tampers payment-amount in transitTLS 1.2+; signed JWT contains user_id, server reads amount from DB by plan_id (not request body)Low
RUser claims they didn't authorize a chargeAudit log captures user_id, ip, ua, timestamp on every charge intentMedium — needs alert on unusual patterns
ILogs leak card dataPII filter strips card-shaped patterns; only token IDs loggedLow
DAttacker floods endpoint to exhaust Razorpay rate limitRate limit per user (10/min); per IP fallbackLow
ECustomer escalates to admin via crafted role claimRole assignment server-side only; JWT roles re-verified per requestLow

Example: Postgres (payments) data store

STRIDEThreatMitigationResidual
SApp connects with wrong credentialsPer-service DB user; password from secret managerLow
TDirect DB modification by SRE outside of auditRBAC: only on-call has prod access; access JIT-granted; all queries loggedMedium
RDB admin makes change, denies itAll admin queries logged with pg_audit; logs to immutable storageLow
IBackup leaks PANWe don't store PAN; backups encrypted in any caseLow
DSingle DB → outageMulti-AZ replica; tested failoverLow
EApp role can grant itself superuserRole separation: app_user cannot GRANTLow

3. Score and prioritize

DREAD is a scoring framework but mostly deprecated. Practical: likelihood × impact on a 1–3 scale = priority.

Risk = max(STRIDE-class likelihood × impact)

Track in a register:

IDThreatLikelihoodImpactMitigation ownerStatus
TM-001Race condition allows double-refundMediumHigh@paymentsIn progress
TM-002Webhook replay attackLowMedium@platformMitigated (idempotency)
TM-003Privilege escalation via role bugLowHigh@securityMitigated (server-side check)

4. Mitigate or accept

For each finding, three outcomes:

  • Mitigate — engineering ticket, deadline, owner.
  • Accept — risk is below threshold; documented with rationale.
  • Transfer — insurance / contract / customer responsibility.

"We'll think about it later" is not an outcome. Accept or mitigate, document the choice.

5. Re-model on change

Threat model isn't a one-time artifact. Re-do when:

  • New trust boundary (new third-party integration, new exposure).
  • New data category (now handling PII / PHI / PAN).
  • Architecture change (new service, new data store).
  • Major incident.

Common threats by component

API endpoints (the most common attack surface)

ThreatMitigation
IDOR (insecure direct object reference)Authorization check on every resource access; never trust path params alone
Mass assignmentSchema validation; allowlist fields, not denylist
Rate-limit bypassPer-user + per-IP rate limits
Injection (SQL, NoSQL, command, LDAP)Parameterized queries; input validation; never string-concat into queries
SSRF (server-side request forgery)Restrict outbound; deny private IPs; validate URLs
XXE (XML external entity)Disable DTD processing; prefer JSON
Replay attacksNonces / idempotency keys / timestamp + signature
Excessive data exposureDon't SELECT *; explicit field allowlist per endpoint

Authentication

ThreatMitigation
Credential stuffingRate limit; CAPTCHA after N failures; breach corpus checks
Password spraySame as above; alert on distributed attempts
Session hijackingHttpOnly + Secure + SameSite cookies; rotate on auth events
Token theft (XSS)CSP; HttpOnly cookies; short-lived access + refresh tokens
Token reuse after logoutServer-side session revocation; short JWT lifetimes

Webhooks

ThreatMitigation
Forged webhookHMAC signature verification with correct secret + raw body
Replay attackIdempotency keys / event ID tracking
Webhook DoSQueue + worker; webhook handler returns 200 fast

Payments / billing

ThreatMitigation
Price tamperingServer-side price lookup; ignore client-supplied amounts
Refund-then-chargeback fraudVelocity checks; manual review for first refunds
Bypassing payment by manipulating order stateState machine in DB; transitions enforced
Double-fulfillment on retryIdempotent webhook handler

File uploads

ThreatMitigation
Malicious file (executable, zip-bomb)Content-type allowlist; size limits; AV scan
Path traversalGenerated filenames, never user-controlled
Storage abuse / cost attackPer-user quota; cost alerts
XSS via SVG uploadSVG sanitization or store as image only
Content disclosure via guessable URLSigned URLs with expiration; or auth check on download

Anti-patterns

  • Threat model that's a generic list copy-pasted — useless. Must be specific to your DFD.
  • No mitigations or owners — produces an artifact, not a change.
  • Modeled at design, never updated — drifts; new threats unaddressed.
  • Scoped only to features being shipped — misses systemic threats (logging, monitoring).
  • No re-model after major change — surprises in production.
  • DREAD scores treated as precise — they're rough heuristics. Ranges, not points.
  • Skipping repudiation threats — almost everyone does. Audit log is the answer.
  • No external red team / pen test — your threat model is what you can imagine. External eyes find what you missed.
  • Not threat-modeling third-party integrations — your threat surface includes your sub-processors.
  • Treating compliance audit as substitute for threat modeling — audit checks controls; threat modeling identifies what controls you need.

Verify it worked

  • DFD exists for the system; trust boundaries marked.
  • STRIDE walked for each process, data store, and external entity.
  • Threat register populated with > 0 findings (no system has zero threats).
  • Each finding has likelihood × impact scoring.
  • Each finding has mitigation, owner, and status.
  • High-priority threats are mitigated or formally accepted.
  • Threat model linked from architecture doc / ADR.
  • Re-model triggers documented (when to update).
  • Mitigations are real — code/config changes, not aspirational notes.
  • At least one finding led to an actual code change.
  • An external pen test or red team has validated key controls (annually).

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.