Kevin Mulholland38 downloadsWrite threat models in your notes and see them as C4-style structure, sequence and data-flow diagrams, with a STRIDE threat report.
Open the web editor → Try it in your browser first: the same language, diagrams and report, with examples to start from, and you can build a model by pointing and clicking. Nothing to install, and nothing leaves your browser. See The web app.
An Obsidian plugin for writing threat models in your notes. You describe a system in a threat code block: its people, systems, containers and data stores, the trust zones they run in, the data that flows between them, and the threats to each part. The plugin draws the model three ways, lets you change it by clicking its diagram, writes a report of it as a note when you ask, and checks it as you write.
It works on desktop and mobile, and it is completely local: diagrams are drawn by Obsidian's own Mermaid renderer, Pele, so it needs Obsidian 1.15 or later.
[!NOTE] 0.3.2: a Tools menu on each diagram (Edit, Report, and the web app's exports: .threat file or code block, share link, SVG, PNG and CSV), icon suggestions as you type, and a calmer bar with the zoom buttons floating over the diagram. See the release notes.
0.3.1: scenarios on every view (a scenario list before the view list), zoom buttons on the diagrams, nested zones rated as they really are, and the web app as a page to download with each release. See the release notes.
0.3.0: change a model by clicking its diagram, in Obsidian too: an Edit switch on each diagram opens the Threat model editor in the right sidebar, with undo; zones on the Structure view; a flow can go to a new element; Open in the web editor. See the release notes.
0.2.3: the web editor can now build and change a model by pointing and clicking, undo and redo, print the report or save it as PDF, export pictures and the threat register, and share a model as a link. In Obsidian, diagrams are drawn even when another plugin's code-block processing fails. See the release notes.
0.2.2: a web app; a skill for an AI such as Claude, to draft a threat model from a photo of a diagram or from your description; and two small fixes. See the release notes.
0.2.1: the settings missing from the settings page in 0.2.0 are back, and a
.threatfile's tab has the plugin's own icon,shield-half. See the release notes.0.2.0: default icons, marks for untrusted zones and sensitive data, and the old
.flowwords (io,function,database,boundary) are gone. See the release notes.0.1.0: first release. See the release notes.
Structure: a C4-style view, threats on the boxes and arrows, coloured by risk, inside their trust zones

Editing from the diagram: turn on Edit, click a box, and change it in the Threat model editor

A flow to a new element: the new element is added with its flow, ready to fill in

Data flow: trust zones, numbered flows and their data; unencrypted flows dashed, findings from the model underneath

Sequence: a scenario step by step, threats as notes, louder as the risk rises

A threat's footprint: click an ID to see everywhere it applies

The report: a summary for readers in a hurry, then the threat register, controls and an action plan

Risk matrix: likelihood against impact, before and after controls

Writing a model: syntax highlighting as you type

```threat
title = "Sign-in"
zone internet "Internet" { trust = "untrusted" }
zone dmz "DMZ" { trust = "restricted" }
person user "User" { zone = internet }
system app "Our app" {
container web "Web app" { technology = "React" zone = internet }
container api "API" { technology = "Node.js" zone = dmz }
store db "Accounts" { technology = "PostgreSQL" zone = dmz }
}
user -> web "Signs in"
web -> api "POST /login" {
protocol = "HTTPS"
data = ["Email #pii", "Password #secret"]
threat T01 "Password guessing against the login" #S { likelihood = 3 impact = 4 }
}
api -> db "Reads the account" { data = ["Password hash #secret"] }
```
The whole language is described in docs/language.md. In short:
person, external, system, container, component, store and queue. Containers and components can be nested inside a system, as in C4.zone = ….a -> b "label" { protocol, data, description }.threat T01 "title" #S { likelihood, impact, status, mitigation } (or a risk tag such as #high instead of likelihood and impact), written inside the flow, element or zone they are about, or at the top level for the whole model. on = [a -> b, c] puts one threat in several places. A CVSS 3.1 vector gives the score.#S #T #R #I #D #E are STRIDE categories (combine them as #STR or #IE), #critical #high #medium #low risks, #open #mitigated #accepted #transferred statuses, and #secret #pii #confidential mark sensitive data. The rest are yours.A list above each model switches between the three diagrams. The Tools menu at the end of that bar holds Edit (see Editing from the diagram), Report, and the ways to get the model out: Download as .threat file (from a note) or Copy as code block (from a .threat file), Copy a link to share, Open in the web editor, Download picture (SVG or PNG, of the diagram shown) and Download threat register (CSV). Downloads go through your computer's save dialog; Obsidian on a phone or tablet can't download, so use the link or the web editor there. In the web app, Report is a button and the rest are in its models menu. When the model has scenarios, a list before the diagram list shows one scenario at a time on every view, or All scenarios (where each diagram opens):
| View | What it shows |
|---|---|
| Structure | A C4-style diagram. A second list (Context, Container, Component) chooses how far inside each system to look. It offers only the levels that show something different: Container when a system has something inside it, Component when a container does. A model with nothing nested has no level list. Zones (trust boundaries) are drawn as dotted boxes within each level: the boxes at the top, and those inside each system or container, are grouped by the zone they are in, so a zone that a system's containers are split across is drawn inside the system too. The Zones switch hides them. The Threats switch (on unless you turn it off) adds the coloured STRIDE letters and threat IDs to boxes and arrows and colours them by their most serious open threat; threats inside a box that isn't opened at this level show on the box. Boxes can have icons (icon = "user", from the Lucide set Obsidian uses); elements without one get a default from their technology or kind (a person user, React globe, PostgreSQL database) unless you turn Default icons off in the settings. Arrows that aren't encrypted are dashed. Closed threats (mitigated, accepted or transferred) colour nothing, and their IDs are struck through. A key explains the colours. |
| Sequence | A scenario step by step (choose it from the scenario list; All scenarios shows every flow in order), with participants grouped by zone. Threats are notes: each STRIDE letter is shown in a box of its own colour (S blue, T orange, R purple, I yellow, D red, E brown), and the risk of an open threat gets louder as it rises (Low, Medium, High, CRITICAL, each in its risk colour), on a background tinted more strongly the higher the risk. A key sits under the diagram. |
| Data flow | The classic threat-modelling diagram: trust zones as boxes (a warning shield on an untrusted one), external entities, processes and data stores, numbered flows with their data (a padlock on sensitive data), STRIDE letters (in the same coloured boxes as the Sequence view) and threat IDs, coloured by risk. A key sits under the diagram. |
| Report (in the Tools menu) | Not a view: it saves the report as a new note and opens it in a new tab, ready to print or export to PDF with Obsidian's Export to PDF. The report opens with a summary for readers in a hurry (the open threats, the top three risks, and what needs action), then the scope and method, the threat register (open threats first, then by risk and score), the controls (what is done about threats, with their status and owner), an action plan grouped by owner, findings from the model (such as sensitive data on an unencrypted flow), a risk matrix of likelihood against impact before and after controls, the diagrams, the flows that cross a zone boundary and the sensitive data on them, the STRIDE categories not yet considered for each part, the elements and the flows. Where reports are saved is a setting. |
Above each diagram, at its right, are zoom buttons: zoom out, the zoom (click it to go back to the diagram as first drawn), zoom in, and Fit, which fits the whole diagram in the width and the height of the pane, handy for a long one. The zoom is kept as you switch views.
Under each diagram is its threat register: the threats that diagram shows, as in the report. The threat IDs on the diagram's boxes and arrows (such as T01, with its rating in brackets when it has one: T01 (4×5) for likelihood × impact, T04 (6.1) for a CVSS score) are the IDs in that register, most serious first, with an open threat's ID louder and in its risk colour as the risk rises, so you can see which threat a mark stands for. The Compact switch shortens the labels (no descriptions or data) and leaves the detail to the threat register, which helps on a busy diagram. A saved report writes each threat out once, in its threat register near the top; after that it names threats by their IDs, for example under a diagram that shows only some of them. Each of those IDs links to the threat's entry in the register, so hovering over it (with Obsidian's Page preview turned on) shows that threat. In Live Preview, hold Ctrl (Cmd on a Mac) while you hover; in Reading view a plain hover is enough. The threat IDs drawn on the report's diagrams are links too: click one to go to its register entry, or hover to see it. In a threat block, hovering over an ID on the diagram shows the threat, and clicking it shows the threat's footprint: every box, arrow and note it applies to stays, the rest of the diagram fades, and its row in the register comes into view. Click the ID again, or anywhere else on the diagram, to clear it.
A saved report also has properties (the model, date, version, status, review date, and counts such as open threats by risk, controls by status and overdue controls), so Obsidian's Bases or Dataview can list all your threat models and what state they are in.
If the model has mistakes, the block lists them with their line numbers instead. Warnings, such as a threat without an ID, are listed under the view.
You can change a model by clicking its diagram instead of typing. Each change is written into the model's text, changing only what you changed and keeping the rest as you wrote it, comments and all.
#, which browsers never send to a website: nothing is uploaded..threat files work the same, with Undo and Redo in the file's own bar too.The text of a threat model is coloured as you type: keywords, names, attributes, strings, comments and hashtags, with STRIDE letters, risks and sensitive-data tags in the same colours as the diagrams. The colours come from your theme's code colours.
threat blocks while you edit them.threat filethreat-source code blocks, which show a model's text without drawing it (handy for documentation)A file ending .threat opens as a threat model of its own. The pencil button at the top of the view switches to its text.
To edit .threat files outside Obsidian, in VS Code for example, a PlantUML extension gives some syntax highlighting once the .threat extension is associated with it (Change Language Mode → Configure File Association for '.threat'). It isn't the same language, so the colours are approximate.
The same models and diagrams in a web page, for trying the language without Obsidian, or for people who don't use it: https://27escape.github.io/threat-model-obsidian/. The diagrams fill the page, with the model's text beside them as you write (Code hides it, to give the diagrams the whole width), and the same views, threat register, findings and key as in Obsidian. Report shows the report in the page, to read, print or save as PDF (from the print dialog), or download as Markdown for Obsidian.
#, which browsers never send to a website: nothing is uploaded, and very large models make long links), Download picture of the diagram shown (SVG or PNG), and Download threat register as CSV for a spreadsheet or a ticket system. The full-screen button shows the diagrams alone.?) has the keyboard shortcuts and the whole language reference. Every menu and dialog closes with Esc, a click outside it, or its ✕..threat file (or the first model in a Markdown note), and Save a copy keeps your changes to an example..threat file to drop into your vault, and Copy as code block copies it as a threat code block to paste into a note.threat-modelling.html from the latest release, or, in a clone of this repository, open web/threat-modelling.html (the page as of the last release; see Building to build it from the source). Opened from your computer, the examples and diagrams work, but some browsers won't let the page save your own models.skills/threat-model/ is a skill (instructions for an AI such as Claude) for drafting a model from a photo of a whiteboard or diagram, or from you describing the system. It asks about what it can't read, plays the system back to you before writing, suggests threats with STRIDE per element, and marks the model as a draft with every suggested threat labelled for you to review. To use it with Claude, add it as a skill in Claude's settings, or copy the folder into a project's .claude/skills/ for Claude Code. Other AI tools can be given SKILL.md as instructions.
| Command | What it does |
|---|---|
| Insert an example threat model | Adds a small model where the cursor is |
| Open the threat report of this note as a new note | The same as Report in the diagram's menu, for the first model in the note |
| Open this threat model in the web editor | Opens the first model in the note (or the .threat file) in the web app, in your browser; nothing is uploaded |
| Setting | What it does |
|---|---|
| First view | The view a model opens with. A model can choose its own with default_view = "…". |
| First C4 level | The level the Structure view opens at. A model can choose its own with level = "…". A model with nothing that deep opens at its deepest level. |
| Show warnings | List warnings under each model. |
| Default icons | Give elements without an icon of their own a default one, from their technology (React globe, PostgreSQL database, Kafka list-ordered…) or their kind (a person user, an external system building-2); and in the Data flow view mark sensitive data with a padlock and untrusted zones with a warning shield. On by default; icon = "none" leaves the icon off one element. See Icons. |
| Save reports | Where Report saves a report: in a Reports folder beside the note with the model (the default), or in a folder you choose. The folder is made if it doesn't exist. A report never replaces an existing note: a new one gets a number ("… threat report 2"). |
| Report folder | The folder, when reports go in a folder. Start typing to choose from your folders. |
| Include the diagrams | Put the Structure, Data flow and Sequence diagrams in saved reports (on by default). Their colours are written into the diagrams, so they print the same in any theme. |
The diagrams take their colours from your theme, in light and dark mode: blues for the C4 structure, red, orange, yellow and green for critical, high, medium and low risk. To change them, set any of these variables in a CSS snippet:
.tm-block {
--tm-critical: var(--color-red);
--tm-high: var(--color-orange);
--tm-medium: var(--color-yellow);
--tm-low: var(--color-green);
--tm-boundary: var(--text-muted); /* zones and system boxes */
--tm-c4-person: rgba(var(--color-blue-rgb), 0.55);
--tm-c4-system: rgba(var(--color-blue-rgb), 0.42);
--tm-c4-container: rgba(var(--color-blue-rgb), 0.28);
--tm-c4-component: rgba(var(--color-blue-rgb), 0.14);
--tm-dfd-process: rgba(var(--color-blue-rgb), 0.16);
--tm-dfd-store: rgba(var(--color-red-rgb), 0.2);
}
src/styles.css lists them all. The sequence diagram's risk tints are written into the diagram, as Obsidian's diagrams can't take colours from a theme for those; they are see-through, so they work on light and dark backgrounds alike. The STRIDE letters are boxed letters (🆂 🆃 🆁 🅸 🅳 🅴) that the plugin colours once a diagram is drawn: .tm-sg-S to .tm-sg-E for the letters in diagrams, .tm-tid-low to .tm-tid-critical (and .tm-tid-closed) for threat IDs in diagrams, .tm-chip-S to .tm-chip-E for those in tables and keys.
Threat Modelling makes no network requests. It reads the text of the threat models it draws. It writes a file only when you ask: saving a report as a note (and making its Reports folder, if needed), editing a .threat file, or saving a change in the Threat model editor (and then only inside that model's code block). Open in the web editor opens your browser with the model in the link's # part, which browsers never send to a website.
Plain JavaScript with no dependencies and no bundler. Needs Node.js 22 or later.
node tools/build.mjs # dist/threat-model/{main.js,styles.css,manifest.json}; also copies the plugin, this README
# and docs/language.md into the sample vault
node --test test/*.test.mjs # unit tests
node tools/check.mjs # local-only rules, file sizes
npm install --no-save [email protected] [email protected] && node tools/build-web.mjs # the web app: dist/web/index.html, one page to open in a browser
npm install --no-save pele && node tools/render-check.mjs # draws every sample diagram with Pele (optional)
npm install --no-save pele playwright && node tools/dom-check.mjs # colours them twice in a browser: the second pass must change nothing (optional)
To try it, open the sample vault folder as a vault in Obsidian and turn on community plugins. Its Guide folder has this README and the language reference as notes. To use it in another vault, copy the three files from dist/threat-model/ into that vault's .obsidian/plugins/threat-model/ folder.
To try the web app from a clone without building anything, open web/threat-modelling.html in your browser: tools/release.sh rebuilds it for each release.
tools/setup-repo.sh sets up git and GitHub once; tools/release.sh X.Y.Z releases a version, with the web app page attached to the release and refreshed in web/.
MIT. The language grew out of Sony's DataFlow language. The Sony webapp example in the sample vault comes from that project and keeps its BSD 3-clause licence.