/appsec-skills:threat-modelfrom appsec-skills
Builds a threat model using the Doors, Windows & Holes method from AppSec Untangled. Walks through stories, entry points, threats/mitigations, and a testing plan with user review after each stage. Outputs Markdown and JSON, and can fill a Notion template.
Ships in appsec-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Answer the four questions for a system or a feature, in developer language: what are we working on, what can go wrong, what are we going to do about it, and did we do a good job. The aim is a useful model that a team reads and acts on in one meeting, not a complete one.
path:line.threat-model.json or a filled Notion template). Model only the delta,
and add to existing groups where the new door, window or hole fits../threat-model/.Ask the user only for what you can't derive: the goal, the users and roles, and anything about the deployment the material doesn't show. Ask once, in one message, then proceed with stated assumptions. A design's own "Assumptions" section is stated design, not your assumption.
A mistake in an early step (a missing story, a wrong group) spreads into every later one, so by default the skill stops for review after each stage:
| Stage | Steps | Ends with |
|---|---|---|
| 1 · Stories | Step 1 | Problem, stories, general scope and its two questions |
| 2 · Doors, windows and holes | Step 2 | Every scope question answered, the groups |
| 3 · Threats and mitigations | Step 3 | Threats, shared mitigations, ruled-out lines |
| 4 · Tests | Step 4 | The testing plan, and the outputs complete |
At the end of each stage:
threat-model.md with the sections
done, and threat-model.json with system.stage set to the stage just
finished and the later arrays empty. With a Notion page, fill that stage's
part of the page too (see references/notion.md).When the user asks for a change, apply it, then re-check the stages already
done that depend on it (a new story can add a door; a merged group moves its
threats) before you ask again. When the skill starts and the output directory
already holds a threat-model.json whose stage isn't complete, offer to
continue from the next stage.
One-shot, when the user asks for it ("one shot", "no review", "all at once"): run all four stages without stopping and write the outputs once.
path:line.
In design mode every claim the design doesn't state is marked
Assumption and listed under open questions.Read from ${CLAUDE_PLUGIN_ROOT}/wiki/docs/:
threat-modeling/index.md: the method, the grouping rule and the threat
format. Read it first.threat-modeling/doors.md, threat-modeling/windows.md,
threat-modeling/holes.md: where to look and what to record for each.
windows.md has the de-abstraction checklist per component type.threat-modeling/business-rules.md: the "what else must hold?" checks.threat-modeling/testing-plan.md: point-in-time and continuous tests.threats/business-logic/*.md (bucket 1) and threats/source-to-sink/*.md
(bucket 2): one page per threat. List the folders at run time; skip
index.md. Read When is it relevant to rule a page in or out, then
Mitigation and Test for each threat you keep.And ${CLAUDE_PLUGIN_ROOT}/skills/threat-model/references/questions.md: the
scope questions from the Notion template, each with the group, threats and
starting mitigation a yes adds. Steps 1 and 2 answer every one of them.
Don't read wiki/examples/ in design mode. In code mode, follow the
secure-code-review skill's rule: for a threat you are checking, read only
the one example file that matches the project's stack, when you reach it.
The problem and the stories come first: everything else is built from them.
sequenceDiagram with
autonumber, from the actor through every component to the data store,
with a Note for the log line a step writes where it matters. Name them
S1, S2… so later steps can cite "S3 · step 4". Five to eight is typical
for a system, one to three for a feature.
questions.md.If the material names something no story touches, add the missing story rather than listing it bare.
Walk the stories and answer every door, window and hole question in
questions.md, in order, as yes, no or not in scope, with a one-line note.
Under each section, list what it covers (the routes, buckets, queries).
doors.md). Record who is meant to use it, the input, and the
authentication.windows.md (what is it really, who else can reach it, write to it or read
from it, what credentials live in it or near it), then sort what you find:
ruledOut line. For a feature, include one only if the
feature changes it. Secrets get a window of their own only when no
trusted window holds them.holes.md. Tokens
the system issues and later checks (QR codes, unsubscribe links, reset
tokens) are threats at the door that receives them, not holes.index.md (same enforcement point, same
rule, and for holes the same sink through the same function). Each group
gets an id (D1, W1, H1), a name in business terms, its Members,
a one-line Grouped because, and the story steps it appears in. Split
any outlier into its own row and say why: it is usually where the bug is.
Order the groups doors, then windows, then holes, each in story order.A yes answer adds the group (or a member to an existing one) and the threats the question lists. A question whose threat already exists elsewhere ("the organizer role is checked at the Cognito window") points at that threat instead of adding a second one. Answer each question yes, no or not in scope (the material doesn't cover it), shown as ✅, ⛔ and ➖.
In code mode, confirm groups from the code: the same middleware on the router, the same repository or query helper, the same IAM policy. A member that doesn't use the shared control is an outlier.
For each group, starting from the threats step 2 added:
business-rules.md. For windows the caller is
often a cloud principal, a pipeline or a third party.holes.md when no page exists), trace it back to
every door its input enters through (sourceDoors), including through
queues and stored data, and pick the mitigation kind: no user input reaches
it, a safe function, or validation or sanitization, in that order of
preference.AuthN first. Every door that is not public by design needs an AuthN threat, even when the design already names the control: the threat is what makes the control testable. Write one AuthN threat per authentication mechanism (the bearer-token middleware, the webhook signature, the QR signature), linked to every door that relies on it, not one per door. Then the AuthZ threats, then the business rules. After that, write a threat only where the answer could be "yes, someone can".
One threat, several doors. Whenever the same attack is stopped by the
same control at several doors or windows (AuthN, an audit log, a rate limit),
write it once and link it to all of them (groups). In the Markdown, list
it under the most sensitive of them, and add "also at …".
Merge threats that are one attack. Once every group has its threats, and before the budget check, merge two or more threats into one when all of these hold:
The usual merges:
Merging changes how threats are counted, never what the model covers:
variants (the
Markdown's Covers line, the Notion row's Notes), so the title can stay
short. Keep each attacker in Who and each outcome in Impact.groups and sourceDoors, the
highest severity, and the worst status (worked out from all the merged
mitigations).Say in the stage summary which threats you merged ("4 into 2: AuthN, S3 bucket"), so the reviewer can ask to split one back out.
Every threat has: a title that is the What, Who, Impact, Category, the library threat (wiki page) it comes from, Status, Severity, and the mitigations that stop it.
Mitigations are their own list. Each says what must be true, adapted from
the wiki page's checklist and the starting mitigation in questions.md, with
its kind, status and evidence. In design mode a mitigation is
📝 Planned when the design states it, ❌ Missing when the design draws the
step without it or contradicts it, and ❓ Needs verification otherwise. When two threats are stopped by the same
control (one owner check on two routes), they share one mitigation; don't
write it twice.
For each group, list the pages ruled out in one line each ("CSRF: bearer token in a header, no cookies").
Budget: about 10 to 25 threats for a feature and 30 to 40 for a whole system, with doors and holes taking most of them. If you are over, you have not grouped enough: merge groups that share the control, write one threat for the same attack at several doors, merge threats that are one attack (above), merge threats on one group that share one mitigation, or move windows nothing trusts into the platform group. Never drop a high-severity threat to meet the budget.
Threat status: ✅ Mitigated only when a test of its mitigation has
passed (so never in design mode, where nothing has run). Otherwise take the
worst of its mitigations: any ❌ Missing makes the threat ❌ Missing, any
⚠️ Partial makes it ⚠️ Partially mitigated, and the rest is ❓ Needs
verification. In design mode, mark a mitigation ❌ only when the diagram shows
the dangerous step itself (a queue any role can send to, a render step with
no sanitizer), not merely because a sketch leaves a control out.
Severity, from who can do it and what they get:
In code mode, set the status from the code the way secure-code-review does:
✅ Mitigated, ⚠️ Partially mitigated, ❌ Missing, ❓ Needs verification. Look
for the control in middleware, the handler, the data layer and the platform
before marking it missing.
Every mitigation gets one test that would fail if the mitigation were
missing, from the threat page's Test section and testing-plan.md. Each
test has one type, Point-in-time (once, before release) or
Continuous (every change or on a schedule), and a kind (code review,
config review, dynamic test (Burp), pen test, unit, integration,
concurrency, SAST rule, policy-as-code, dependency scan, monitoring, other).
Pick the type that fits: continuous for controls in code and config that
change, point-in-time for things checked once.
Add a second test of the other type only when the mitigation stops a Critical threat, or a High threat whose control lives in application code that changes often (route handlers, middleware, query code): check it now, then keep it true. Write How (what to send or check, and what must happen to pass) and Where it runs. Risk-accepted threats need no test.
In iterative mode, write them at the end of every stage with what is done so far; in one-shot mode, once at the end.
<output>/threat-model.md, following
${CLAUDE_PLUGIN_ROOT}/skills/threat-model/templates/threat-model.md. The
template is a shortened dummy example: keep its structure, replace the
content, and write every group, threat, mitigation and test, not an
excerpt. Link each threat to the wiki page or heading it came from; for a
sink with no page, link the holes.md sink catalogue.<output>/threat-model.json, matching
${CLAUDE_PLUGIN_ROOT}/skills/threat-model/references/threat-model.schema.json.
It is what feature mode reads next time and what step 6 pushes to Notion.
Check it parses (node -e "JSON.parse(require('fs').readFileSync(process.argv[1]))" <file>)
and that every id it references exists.When the user gives a Notion page, or asks for Notion, follow
${CLAUDE_PLUGIN_ROOT}/skills/threat-model/references/notion.md. It needs the
Notion connector. Write to the page the user named, never to another one, and
in feature mode add rows instead of duplicating existing ones.
In iterative mode, after stages 1 to 3 reply with the stage summary and the review request (see above). After the last stage, or in one-shot mode, reply with: the counts (stories, doors, windows, holes, threats, mitigations, tests), the threats that are ❌ Missing or ⚠️ Partial with their severity, the open questions, and the output paths or Notion link.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub mohamed-osama-aboelkheir/appsec-untangled-resources --plugin appsec-skills6 skills in this plugin
/code-walkthroughExplain how a feature or a code location works as a numbered walkthrough: a Mermaid sequence diagram (UI → HTTP → app → route → auth → controller → service → store → database) and a matching VS Code CodeTour whose steps highlight the exact code, with real request/response and error examples. Starts from a route, a feature, or a code location such as a SAST/Semgrep finding's sink, and finds the routes that reach it. Use when asked to walk through, trace, diagram, explain or "code tour" a flow, route, feature or finding./secure-code-reviewThreat-model-first security code review of a pull request, commit or diff. Builds the story of the change, lists entry points and dangerous sinks, picks the relevant threats from the AppSec Untangled wiki, checks each mitigation against the code, and writes Markdown and HTML reports with evidence. Use when asked for a security review of a PR, commit, branch or diff./security-experimentBuild a short, runnable notebook that shows why a security control makes a sink safe (or why its absence doesn't): one classic payload goes through the application's real steps, first without the control, then with it, printing the value after every step with the dangerous part highlighted, until the payload disappears (or reaches the sink). Works for sanitisers, encoders, validators, allowlists, parameterised queries and path checks. Use when asked why a finding is a false positive, to prove or demonstrate a control, to show what a sanitiser removes, or to "experiment" with a payload against the code./semgrep-triageTriage Semgrep (or other SAST) findings: for each finding, trace the flagged value back to its sources, check the controls on the path against the AppSec Untangled wiki, and decide true or false positive, severity (impact × likelihood) and confidence. False positives get a decision on whether to disable or suppress the rule. Writes one Markdown report with source-to-sink diagrams, CodeTours and manual reproduction steps for every finding. Supports a learn mode where the user decides first. Use when asked to triage, review, validate or prioritise scanner findings, or to check whether a finding is exploitable or a false positive./source-to-sinkTrace how data flows between sources and dangerous sinks, like a SAST dataflow trace, and explain it as a diagram of code cards plus a VS Code CodeTour that highlights the value on every line. Backward mode starts from a sink (a file:line, or a Semgrep/SAST finding) and finds every source that reaches it and whether it is user input, and which users can send it. Forward mode starts from an input (a parameter, header, body field, or all inputs of a route) and finds every dangerous sink it reaches, or where it stops. Use when asked what reaches a sink, whether a finding's input is user-controlled, where an input goes, or for a source-to-sink / taint / dataflow trace.