To threat model an LLM application, draw a data-flow diagram that marks every trust boundary (including the one around the model itself), run STRIDE against each element, then layer the OWASP Top 10 for LLM Applications 2025 and MITRE ATLAS on top to catch the AI-specific attacks STRIDE was never designed for. The output is a ranked threat table with owners and mitigations, and it should live in your repo as code so CI fails when a new tool or data source shows up without a review.
Why Classic Threat Modeling Misses LLM Risks
Classic threat modeling assumes code and data are separate. An LLM erases that split: any text in the context window (user message, retrieved PDF, web page, tool result) can act as an instruction, and the model turns instructions into actions through its tools. Three consequences follow:
- The model is an untrusted component. Treat its output exactly like user input crossing a boundary, even when the model is "yours."
- Data stores become injection vectors. A vector store full of scraped or user-uploaded documents is an input channel, not just storage.
- Blast radius is set by tools, not prompts. You cannot make prompt injection impossible today, so the useful question is "what is the worst thing the agent can do when (not if) it is hijacked?"
For the defenses themselves, see our guide on how to prevent prompt injection attacks. This post covers the modeling process that tells you where they go.
Step 1: Draw the Data-Flow Diagram With Trust Boundaries
Our example is a customer support assistant. A chat API passes messages to an agent orchestrator, which retrieves chunks from a vector store built from help articles and past tickets, sends prompt, chunks and tool schemas to a hosted LLM, and executes tool calls against an MCP server exposing search_orders, create_ticket and issue_refund.
Here is the DFD in Mermaid. You can paste it into Diagram Studio to render and edit it.
flowchart LR
subgraph Internet
U[Customer]
end
subgraph AppVPC[App VPC]
API[Chat API]
ORCH[Agent orchestrator]
VS[(Vector store)]
LOG[(Conversation logs)]
end
subgraph Vendor[Model provider]
LLM[Hosted LLM]
end
subgraph ToolZone[MCP tool server]
T1[search_orders]
T2[create_ticket]
T3[issue_refund]
end
ING[Doc ingestion job] --> VS
U -->|message| API --> ORCH
ORCH -->|query| VS -->|chunks| ORCH
ORCH -->|prompt + chunks + tool schemas| LLM
LLM -->|text or tool call| ORCH
ORCH --> T1 & T2 & T3
ORCH --> LOG
ORCH -->|answer| API -->|rendered HTML| U
Mark each trust boundary explicitly:
- Internet to Chat API: classic web boundary.
- Orchestrator to model provider: your data leaves your control; the response coming back is untrusted.
- Ingestion to vector store: anyone who can write a help article or a ticket can write into the model's context later.
- Orchestrator to tool server: the point where text becomes side effects.
- Answer to browser: model output is rendered, so output handling matters.
Draw the LLM as an external entity even if you self-host the weights; from a trust perspective it behaves like one.
Step 2: Apply STRIDE Per Element
STRIDE per element is the classic approach popularized by Microsoft's SDL (the STRIDE categories are documented with its Threat Modeling Tool): processes are checked against all six categories, while data stores and data flows are mainly checked for tampering, information disclosure and denial of service.
| STRIDE category | Generic question | LLM-specific form in our app |
|---|---|---|
| Spoofing | Can someone pretend to be another principal? | Retrieved text claims to be "the system" or "the admin"; agent calls tools with a shared service identity instead of the user's |
| Tampering | Can data be modified in transit or at rest? | Poisoned documents in the vector store; MCP tool definitions changed after approval |
| Repudiation | Can an actor deny an action? | No record of which prompt, chunk and tool call led to a refund |
| Information disclosure | Can data leak to the wrong party? | System prompt extraction; cross-tenant chunks retrieved; PII sent to the model vendor; exfiltration through a tool's URL parameter |
| Denial of service | Can the system be made unavailable or too expensive? | Token flooding, recursive tool loops, a single user burning the monthly model budget |
| Elevation of privilege | Can someone gain capabilities they should not have? | Injected instruction makes the agent call issue_refund, which the customer could never call directly |
STRIDE gives you systematic coverage of the architecture. What it handles poorly is attacks that do not map cleanly to a single element, such as indirect prompt injection that enters through the vector store and exits through a tool. That is what the next two layers fill.
Step 3: Layer the OWASP Top 10 for LLM Applications (2025)
The current edition is the 2025 list, published by the OWASP GenAI Security Project.
| ID | Risk | Where it lands in the example DFD |
|---|---|---|
| LLM01:2025 | Prompt Injection | Direct via chat; indirect via vector store chunks and tool results |
| LLM02:2025 | Sensitive Information Disclosure | Order data and PII in context, conversation logs, model vendor |
| LLM03:2025 | Supply Chain | Model provider, embedding model, MCP server package, framework dependencies |
| LLM04:2025 | Data and Model Poisoning | Ingestion job writing to the vector store; any fine-tuning data |
| LLM05:2025 | Improper Output Handling | Answer rendered as HTML; tool arguments built from model output |
| LLM06:2025 | Excessive Agency | issue_refund reachable from an unauthenticated chat turn |
| LLM07:2025 | System Prompt Leakage | Business rules and any secrets someone put in the system prompt |
| LLM08:2025 | Vector and Embedding Weaknesses | Missing tenant filters on retrieval, embedding inversion |
| LLM09:2025 | Misinformation | Wrong refund policy stated confidently to a customer |
| LLM10:2025 | Unbounded Consumption | No per-user token or tool-call budget |
Score LLM06 Excessive Agency as three separate items (excessive functionality, permissions and autonomy) because the mitigations differ. And treat LLM07 as a design smell: if leaking the system prompt is an incident, authorization logic is living in the prompt.
For agent-heavy systems, OWASP also published the Top 10 for Agentic Applications for 2026 in December 2025 (entries prefixed ASI, starting with ASI01 Agent Goal Hijack and ASI02 Tool Misuse and Exploitation). Use it as a second checklist when your agent plans multi-step work, holds memory, or talks to other agents.
Step 4: Map Attack Paths With MITRE ATLAS
OWASP tells you what can go wrong; MITRE ATLAS catalogs how adversaries do it, ATT&CK-style, which makes it ideal for attack paths and red-team scenarios. The IDs below are from the ATLAS data release 2026.10 in the official atlas-data repository.
| ATLAS ID | Technique | Relevance to the example |
|---|---|---|
| AML.T0051.000 / .001 | LLM Prompt Injection: Direct / Indirect | Chat input; poisoned help articles and ticket text |
| AML.T0070 | RAG Poisoning | Ingestion job accepts content from ticket bodies |
| AML.T0053 | AI Agent Tool Invocation | Hijacked agent calls issue_refund |
| AML.T0086 | Exfiltration via AI Agent Tool Invocation | Data encoded into create_ticket fields sent to an attacker-visible system |
| AML.T0110 | AI Agent Tool Poisoning | Malicious instructions in an MCP tool description |
| AML.T0080 | AI Agent Context Poisoning | Persisted memory or conversation summaries carrying injected instructions |
| AML.T0054 | LLM Jailbreak | Bypassing the model's safety training to produce disallowed output |
| AML.T0034 | Cost Harvesting | Abusing your model API spend |
A typical path in our app: T0070 (attacker's ticket text gets ingested) leads to T0051.001 (it is retrieved into a later conversation) leads to T0053 (agent calls issue_refund) or T0086 (agent leaks another customer's order into a ticket field). Written out, the cheapest break point is obvious: the tool boundary, not the prompt.
ATLAS also ships mitigations with IDs. The ones that matter most here are AML.M0028 Enforce Access Controls for AI Agent Tools, AML.M0029 Human In-the-Loop for AI Agent Actions, and AML.M0030 Restrict AI Agent Tool Invocation on Untrusted Data.
Step 5: Model Agent and Tool-Use Threats Explicitly
Excessive agency
For every tool, record what it can do, whose identity it runs as, and whether a human approves it. A tool running as a shared service account turns every user into that account the moment injection succeeds; prefer the end user's own scoped authorization so the agent can never exceed what the user could do.
MCP tool poisoning and rug pulls
MCP servers advertise tool names, descriptions and input schemas that are fed to the model. Invariant Labs documented tool poisoning attacks where hidden instructions in a tool description, text the user typically never sees, steer the model into reading files or exfiltrating data. A related problem is a server that changes its tool definitions after you approved it. Model every MCP server as a separate external entity whose tool metadata is an input flow into the model. The MCP security best practices page covers confused-deputy and token-passthrough issues you should check for the authorization side. If you build your own servers, our MCP server tutorial is a good place to bake these controls in from the start.
Untrusted-turn tainting
The most effective control I have seen: once untrusted content enters the context, mark the turn as tainted and block or require approval for side-effecting tools for the rest of that turn. This is ATLAS AML.M0030, and it holds even when the model is fully fooled.
Worked Example: The Threat Table
| ID | Element / flow | Threat | STRIDE | OWASP / ATLAS | Risk | Mitigation | Status |
|---|---|---|---|---|---|---|---|
| TM-1 | Chat to orchestrator | User instructs agent to ignore policy and refund | E | LLM01, LLM06 / T0051.000, T0053 | High | issue_refund requires a human approval step; refund limits enforced in the tool, not the prompt |
Done |
| TM-2 | Ingestion to vector store | Attacker ticket text poisons future answers | T | LLM04, LLM08 / T0070 | High | Only ingest agent-reviewed ticket resolutions; store source and author metadata; filter at retrieval by tenant | In progress |
| TM-3 | Vector store to orchestrator | Retrieved chunk contains instructions | T, E | LLM01 / T0051.001 | High | Taint turn on retrieval; side-effecting tools blocked on tainted turns without approval | Done |
| TM-4 | Orchestrator to create_ticket |
Data exfiltration via tool arguments | I | LLM02 / T0086 | Medium | Schema-validate args; strip URLs and markdown images from fields; per-user rate limit | Open |
| TM-5 | MCP server to model | Poisoned or changed tool description | T | LLM03 / T0110 | Medium | Pin server version; hash tool definitions and alert on change; review descriptions in PRs | Open |
| TM-7 | Orchestrator to browser | Model output renders script or tracking image | T, I | LLM05 / T0077 | Medium | Render as text or sanitized markdown; block remote images | Done |
| TM-8 | Whole agent loop | Recursive tool calls burn budget | D | LLM10 / T0034 | Medium | Max steps per turn, per-user token budget, alert on spend anomalies | Open |
Rank by impact first and assume LLM01 always succeeds when estimating it; that one assumption sorts most tables correctly.
Keep the Threat Model Alive in CI
A threat model in a wiki goes stale within a sprint. Two open-source options make it code:
- OWASP pytm: a Python framework where you declare elements, boundaries and data flows, and it generates a DFD, a sequence diagram and findings from a rules database. Version 1.4.1 (November 2026) requires Python 3.11+ and includes
LLMandAgentelement types. - OWASP Threat Dragon: a desktop and web diagramming tool (v2.6.2 as of this writing) supporting STRIDE, LINDDUN, CIA, CIA-DIE and PLOT4ai, with models stored in GitHub, GitLab, Bitbucket or local files. Better when non-developers edit the model; weaker for automated gating.
Here is the example system in pytm. I ran this against pytm 1.4.1:
#!/usr/bin/env python3
from pytm import (TM, Finding, Actor, Agent, Boundary, Classification, Data,
Dataflow, Datastore, ExternalEntity, LLM, Server)
tm = TM("Support assistant (RAG + tools)")
tm.description = "Customer chat assistant with RAG and a ticketing tool"
tm.isOrdered = True
internet = Boundary("Internet")
app_zone = Boundary("App VPC")
vendor = Boundary("Model provider")
user = Actor("Customer")
user.inBoundary = internet
api = Server("Chat API")
api.inBoundary = app_zone
agent = Agent("Agent orchestrator")
agent.inBoundary = app_zone
agent.usesExternalTools = True
llm = LLM("Hosted LLM")
llm.inBoundary = vendor
llm.hasRAG = True
llm.hasAgentCapabilities = True
llm.hasAccessToSensitiveSystems = True
llm.processesPersonalData = True
llm.overrides = [
Finding(threat_id="LLM02",
response="Mitigated by TM-3: tainted turns cannot call side-effecting tools"),
]
vectors = Datastore("Vector store")
vectors.inBoundary = app_zone
tickets = ExternalEntity("Ticketing API (MCP server)")
tickets.inBoundary = internet
question = Data("Customer question", classification=Classification.SENSITIVE, isPII=True)
Dataflow(user, api, "Chat message", protocol="HTTPS", data=question)
Dataflow(api, agent, "Message + session")
Dataflow(agent, vectors, "Similarity query")
Dataflow(vectors, agent, "Retrieved chunks")
Dataflow(agent, llm, "Prompt + chunks + tool schemas", protocol="HTTPS")
Dataflow(llm, agent, "Completion / tool call")
Dataflow(agent, tickets, "create_ticket()", protocol="HTTPS")
Dataflow(agent, api, "Answer")
Dataflow(api, user, "Rendered answer", protocol="HTTPS")
tm.process()
Run python tm.py --json tm.json to get findings, or python tm.py --dfd | dot -Tpng -o dfd.png for the diagram (needs Graphviz). pytm has no built-in "fail the build" mode, so add a small gate that fails on high-severity findings without a recorded response:
# tm_gate.py: usage: python tm_gate.py tm.json [THREAT_ID_PREFIX ...]
import json
import sys
report, prefixes = sys.argv[1], tuple(sys.argv[2:]) or ("",)
findings = json.load(open(report))["findings"]
open_high = [
f for f in findings
if f["threat_id"].startswith(prefixes)
and f["severity"] in ("High", "Very High")
and not f.get("response")
]
for f in open_high:
print(f'{f["threat_id"]:6} {f["severity"]:9} {f["target"]}: {f["description"]}')
print(f"{len(open_high)} unresolved high-severity findings")
sys.exit(1 if open_high else 0)
On the model above, python tm_gate.py tm.json LLM reports six open LLM findings (direct prompt injection, excessive agency, untrusted tool launch configuration and three others) and exits 1, while the overridden LLM02 finding is suppressed. Without the prefix filter the same model produces 39 open high-severity findings, most of them generic web threats; start by gating on the LLM prefix and widen as you triage. One gotcha: pytm's LLM01 to LLM09 are its own rule IDs, not OWASP Top 10 IDs. pytm's LLM02 is indirect prompt injection, which OWASP files under LLM01. Keep the OWASP mapping in your own table.
Run it whenever the model or agent code changes:
name: threat-model
on:
pull_request:
paths:
- "threatmodel/**"
- "src/agent/**"
- "mcp/**"
jobs:
pytm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: pip install pytm==1.4.1
- run: python threatmodel/tm.py --json tm.json
- run: python threatmodel/tm_gate.py tm.json LLM
The path triggers matter most: adding a tool or MCP server should force someone to touch tm.py. Add a CODEOWNERS entry so security review is requested on those paths.
When to re-run the human part
Automation catches drift, not new threats. Hold a short human review for any new side-effecting tool, new retrieval source, model provider switch, agent memory, or agent-to-agent calls.
Frequently Asked Questions
What is the best framework for threat modeling LLM applications?
No single framework covers everything. STRIDE per element covers the architecture, the OWASP Top 10 for LLM Applications 2025 is the AI-specific checklist, and MITRE ATLAS supplies adversary techniques for attack paths. Use all three in that order.
Are there automated threat modeling tools for AI and LLM applications?
Yes, but treat their output as a first draft. OWASP pytm generates findings from code, including LLM and agent rules, and Threat Dragon offers collaborative diagramming. We compared commercial options in our list of AI threat modeling tools. None of them knows your tool permissions better than the team that built the system.
How is threat modeling a RAG app different from a plain chatbot?
The vector store becomes an input channel: anyone who can influence ingested content can place instructions in front of the model later. You also need per-tenant authorization at retrieval time, because similarity search ignores access control unless you add filters.
Should the LLM be inside or outside the trust boundary?
Outside, always. Even a self-hosted model can be steered by untrusted text, so validate its output like user input before it reaches a renderer, a query or a tool. Putting it inside the boundary is how model output ends up in SQL or shell commands.
How often should an LLM threat model be updated?
Whenever a new tool, data source, model or agent capability ships, enforced with path-based CI triggers as shown above. A quarterly review is reasonable for stable systems.
Conclusion
Threat modeling an LLM application is regular threat modeling plus one uncomfortable assumption: the model will eventually follow an attacker's instructions. Draw the DFD with the model outside your trust boundary, run STRIDE per element, map the result to OWASP LLM Top 10 2025 and ATLAS, and spend most of your mitigation budget at the tool boundary, where authorization, approval and tainting actually hold. Then put the model in the repo with a CI gate so the next tool someone adds cannot skip the conversation.