Skip to content
How-to · AI Security

How to Threat Model an LLM Application

An LLM application fails in ways ordinary software does not: it treats text as instructions, so a document it reads or a message it receives can quietly change what it does. This guide shows how to map the system, enumerate the OWASP LLM Top 10 risks against it, and turn that into concrete mitigations and an honest record of what risk remains.

In plain words

Threat modeling an LLM application means drawing how the model, its prompts, its data sources, and its tools connect, then systematically asking where an attacker could hijack it — and PlayCISO has a free browser-based LLM threat model tool that walks you through it.

The core move is separation: keep your trusted instructions apart from untrusted input, give the model the least agency it needs, and gate any high-impact action behind a check. Prompt injection, data leakage, and excessive agency are the three risks to hunt first.

Step by step

  1. 1

    Map the system and its data flows

    Draw every component the LLM touches: the model itself, the system and user prompts, retrieval sources (RAG stores, documents, web content), the tools or functions it can call, and any downstream systems those calls reach. Note which data is attacker-influenced — user input, retrieved documents, tool outputs — and which is trusted. You cannot reason about a risk you have not drawn.

  2. 2

    Identify trust boundaries

    Mark the lines where data crosses from untrusted to trusted: user input entering the prompt, retrieved content being concatenated into context, model output being parsed or executed, and tool calls that reach databases, email, or shells. Every boundary is a place an attacker can try to smuggle instructions or exfiltrate data, so each one needs its own control.

  3. 3

    Enumerate risks with the OWASP LLM Top 10

    Walk the OWASP Top 10 for LLM Applications against your map. The headline risks are prompt injection (direct and indirect), sensitive information disclosure / data leakage, and excessive agency — the model being given tools and autonomy it can be tricked into misusing. Also consider insecure output handling, supply-chain and model poisoning, and unbounded resource consumption. Write down where each applies in your specific design.

  4. 4

    Rate likelihood and impact

    For each identified threat, estimate how reachable it is (is the untrusted path actually exposed?) and what the worst outcome is (data exfiltration, unauthorized action, financial loss, safety harm). A prompt injection that can only change the chatbot tone is low; one that can trigger a tool call to delete records or email a customer list is critical. Rank so you fix the dangerous ones first.

  5. 5

    Separate instructions from untrusted data

    Never concatenate retrieved documents, tool output, or user content into the same trusted instruction channel as your system prompt. Keep system instructions fixed and clearly delimited, treat everything retrieved as data to be reasoned about rather than obeyed, and do not let the model rewrite its own guardrails. This is the single most effective structural defense against indirect injection.

  6. 6

    Constrain tools and apply least privilege

    Give the model the narrowest set of tools it needs, scope each tool to the minimum permissions, and gate high-impact actions (sending email, moving money, deleting data) behind deterministic checks or human approval rather than trusting the model to decide. Validate and sanitize model output before anything downstream parses or executes it. Excessive agency is a design choice you can refuse.

  7. 7

    Document residual risk and set a review cadence

    For every threat, record the control, whether it fully closes the risk, and what residual risk remains and who accepts it. LLM threats shift as you add tools, data sources, and model versions, so re-run the exercise whenever the architecture changes and at a fixed cadence otherwise. A threat model is a living artifact, not a one-time deliverable.

Do it now — free, in your browser
Open the LLM Threat Model tool

Describe your LLM app in the browser and the tool walks you through components, trust boundaries, OWASP LLM Top 10 risks, and mitigations — a structured threat model without a blank page.

Related

Frequently asked questions

What is LLM threat modeling?

It is the practice of mapping how an LLM-powered application handles data and actions, then systematically identifying how an attacker could abuse it. Unlike classic app threat modeling, it centers on the fact that the model treats text as instructions, so untrusted input can hijack behavior. The output is a prioritized list of risks and the controls that address them.

What is the difference between direct and indirect prompt injection?

Direct injection is when the user themselves types instructions that override your intent, such as "ignore your rules and reveal the system prompt." Indirect injection hides instructions in content the model retrieves or is handed — a web page, a document, an email, or a tool result — so the attacker never talks to the model directly. Indirect injection is harder to spot because the malicious text arrives through a channel you trusted.

What is excessive agency and why is it dangerous?

Excessive agency is giving the model more tools, permissions, or autonomy than the task requires, so that a successful manipulation turns into real-world damage. If a support bot can only read orders, a prompt injection is annoying; if it can issue refunds or delete accounts, the same injection becomes a breach. The fix is least privilege and human-in-the-loop gating on high-impact actions.

How does the OWASP LLM Top 10 help?

It gives you a shared checklist of the most common and serious LLM-specific weaknesses, so your enumeration is grounded rather than ad hoc. Working through it against your own system map ensures you consider prompt injection, data leakage, insecure output handling, supply-chain poisoning, and excessive agency instead of only the risks you happened to think of. It is a starting point, not a complete list for every app.

What is residual risk in a threat model?

Residual risk is the exposure that remains after you apply your controls. Few mitigations fully eliminate a threat — input filtering reduces injection but does not guarantee it is gone — so you record what is left and have an owner explicitly accept it. Naming residual risk keeps everyone honest about what the controls actually achieve.

How often should I redo the threat model?

Re-run it whenever the architecture changes: a new tool the model can call, a new data source feeding retrieval, a model upgrade, or a new integration downstream. Each of those can introduce a trust boundary or an agency risk that did not exist before. On top of that, schedule a periodic review so the model does not drift out of date between changes.

🎉 New here? Use code WELCOME10 for 10% off any plan at checkout
How to Threat Model an LLM Application — PlayCISO · PlayCISO