Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 1 of 6 · Concept · 20 min · revision 3

Threat Modeling an LLM Application

List the assets, data flows and trust boundaries of a RAG assistant, ask the OWASP Top 10 for LLM Applications questions at each boundary, and keep the result as a threat register with a control, a test and a residual risk for every threat.

Contentsand lesson path

What you will learn

  • Map an LLM application's assets, trust boundaries and threats using the OWASP Top 10 for LLM Applications.

01. Why it matters

In the earlier skills you built a help-centre assistant for Lumen, the made-up project-management app: it retrieves passages, asks a model to answer from them and cites its sources. It works. Now ask a different question: what could someone make it do that you never intended?

An LLM application is an ordinary web application with one unusual component. Everything you know about authentication, input validation and secrets still applies. What is new is that the model turns text into behaviour, and it reads text from many places with very different owners: your system prompt, the customer's message, help articles your staff wrote, community answers anyone can post, documents from the customer's own workspace. All of it ends up in one context window, and the model has no reliable way to tell which parts are instructions and which are data.

A threat model is how you find the consequences of that before an attacker does. It answers four plain questions: what are we building, what can go wrong, what are we doing about it, and did we do enough? This lesson gives you a method for the first three with the OWASP Top 10 for LLM Applications as a prompt list; the rest of the skill builds and tests the controls.

02. Assets, data flows and trust boundaries

Start with what you are protecting. For the Lumen assistant the assets are:

  • Customer data: workspace documents, names and email addresses, anything a customer types into the chat.
  • Secrets: the model provider's API key, the credentials behind each tool, signing keys for sessions.
  • The integrity of answers: customers act on what the assistant says, so a planted false answer is damage even if nothing leaks.
  • The authority of tools: the assistant can email a conversation transcript; mail sent from Lumen's domain carries Lumen's reputation.
  • Money and capacity: every request costs tokens, and the budget and rate limits are finite.

Next, list the data flows: every place where data moves from one component to another. Then mark each trust boundary, a point where data passes between parts with different owners or different levels of trust. Boundaries matter because that is where checks belong: whatever crosses one must be authenticated, authorised, validated or encoded on the receiving side.

Data flows of the Lumen assistant (B1 to B6 are trust boundaries)
flow                                       carries                         crosses
1. browser -> Lumen API                     question, session cookie        B1
2. help articles, community answers,        text, source, access labels     B2
   workspace documents -> index
3. index -> prompt                          top passages for this user      B3
4. Lumen API -> model provider              system prompt, passages,        B4
                                            question, tool definitions
5. model reply -> browser, tools, logs      answer text, tool calls         B5
6. package index, model hub -> build        libraries, SDKs, model files    B6

Two boundaries are easy to miss. B2 is where untrusted text becomes "our" data: once a community answer is in the index, it looks exactly like a staff article to every later stage. B3 is the strangest: passages, the system prompt and the user's question are concatenated into one sequence of tokens. Inside that sequence nothing enforces the boundary, because the model weighs all of it together. You cannot put a check inside the model, so you enforce B3 around it: control what goes in (only passages this user may read, with secrets removed), what the model is allowed to do (narrow tools) and what happens to what comes out (validation, encoding, moderation).

That is the central idea of this skill. Treat the model as a component that an attacker can partly steer whenever they control any text it reads, and design so that steering it achieves little.

03. Asking the OWASP questions at each boundary

The OWASP Top 10 for LLM Applications (2026 edition, published in October 2026) names the risk categories that practitioners see most often. The 2026 edition renumbered the 2025 list, so the ids in older articles differ: for example, LLM05 was Improper Output Handling in 2025 and is LLM10 now. System Prompt Leakage (LLM07 in 2025) has no entry of its own; it sits inside the broader LLM08 Hidden Context Exposure, which also covers developer instructions, retrieved policy text and tool schemas. Use it as a list of questions to ask at each boundary, not as a checklist to tick off. For the Lumen assistant:

  1. LLM01 Prompt Injection (B1, B3): text that changes what the model does. Direct when the user types it, indirect when it hides in content the model reads, such as a community answer that tells the assistant to email the chat somewhere.
  2. LLM02 Sensitive Information Disclosure (B3, B4, B5): personal data, secrets or another customer's documents in an answer, in the request sent to the provider or in the logs.
  3. LLM03 Excessive Agency (B5): tools with more functions, permissions or autonomy than the task needs.
  4. LLM04 Supply Chain (B6): a compromised package, SDK, model file or adapter that you pulled in.
  5. LLM05 Data and Model Poisoning (B2): manipulated training, fine-tuning or embedding data. For a RAG app the usual route is the corpus: spam answers that plant false facts or hidden instructions.
  6. LLM06 Unbounded Consumption (B1): unlimited requests or tokens, which run up cost, degrade service or let someone copy the model's behaviour.
  7. LLM07 Misinformation (B5): confident answers the sources do not support, and users who rely on them. The grounding and citations skill covers the controls.
  8. LLM08 Hidden Context Exposure (B1): assume that the system prompt, developer instructions and tool schemas can be extracted or inferred. The real risk is what you put in them, such as credentials or rules that you rely on instead of real access control.
  9. LLM09 Vector and Embedding Weaknesses (B2, B3): missing access control in the vector store, cross-tenant leaks, poisoned or inverted embeddings.
  10. LLM10 Improper Output Handling (B5): model output passed to a browser, a database or a shell without validation or encoding.

The list does not replace ordinary application security. Session handling, CSRF and dependency updates still matter, and a threat that fits none of the ten is still a threat.

04. A threat register you can check

For each boundary, write down the threats you found and, for each threat, the control that addresses it and the test that proves the control works. Keeping the register as data next to the code has a practical benefit: a short script can check it, and CI can fail when a new boundary has no threats or a threat has no test.

Python · threat_register.py
"""The Lumen assistant's threat register, kept as data so a script can check it."""
from typing import NamedTuple

BOUNDARIES = {
    "B1": "browser to API: messages from signed-in users",
    "B2": "community answers and synced docs to the index",
    "B3": "retrieved passages into the prompt",
    "B4": "app to the model provider",
    "B5": "model output to the browser, tools and logs",
    "B6": "third-party packages and models into the build",
}


class Threat(NamedTuple):
    id: str
    boundary: str
    owasp: str
    threat: str
    control: str
    test: str  # the test that proves the control works; "" = not written yet


THREATS = [
    Threat("T1", "B3", "LLM01", "planted answer tells the assistant to email the chat",
           "data blocks, recipient fixed to the user, confirmation", "planted_docs"),
    Threat("T2", "B1", "LLM08", "user extracts the system prompt",
           "no secrets in the prompt, output check for its marker", "direct_attacks"),
    Threat("T3", "B3", "LLM09", "search returns another workspace's chunks",
           "filter on the verified identity before ranking", "cross_user"),
    Threat("T4", "B4", "LLM02", "pasted API keys reach the provider and logs",
           "redact before the prompt and the log", "redaction"),
    Threat("T5", "B5", "LLM10", "answer rendered as HTML runs a script",
           "escape, or sanitise with an allow-list", "xss_payloads"),
    Threat("T6", "B2", "LLM05", "spam answers seed false facts in the index",
           "index reviewed community answers only", "ingest_sources"),
    Threat("T7", "B1", "LLM06", "a script sends thousands of long questions",
           "per-user rate limit, token caps, spend alerts", ""),
    Threat("T8", "B5", "LLM07", "confident answer the passages do not support",
           "citations checked against passages", "groundedness"),
    Threat("T9", "B5", "LLM03", "the email tool can write to any address",
           "tool takes no recipient argument", "tool_arguments"),
    Threat("T10", "B6", "LLM04", "a compromised dependency or model file",
           "pinned versions with hashes, trusted sources", "lockfile_check"),
]

if __name__ == "__main__":
    for key, name in BOUNDARIES.items():
        ids = [f"{t.id}/{t.owasp}" for t in THREATS if t.boundary == key]
        print(f"{key} {name:48} {' '.join(ids) or 'NO THREATS LISTED'}")
    covered = {t.owasp for t in THREATS}
    print("OWASP entries covered:", len(covered), "of 10")
    print("threats without a test:", [t.id for t in THREATS if not t.test])
Terminal
python threat_register.py
Expected output
B1 browser to API: messages from signed-in users    T2/LLM08 T7/LLM06
B2 community answers and synced docs to the index   T6/LLM05
B3 retrieved passages into the prompt               T1/LLM01 T3/LLM09
B4 app to the model provider                        T4/LLM02
B5 model output to the browser, tools and logs      T5/LLM10 T8/LLM07 T9/LLM03
B6 third-party packages and models into the build   T10/LLM04
OWASP entries covered: 10 of 10
threats without a test: ['T7']

Read the register critically. Every OWASP entry appears, yet T7 has no test, so its control is a hope rather than a fact. Some threats have one control and others three; the depth should follow the impact. And some threats cannot be closed. The lab in this skill shows that a well-crafted planted document can still steer the model after every prompt-level defence, so T1's honest status is "reduced, not removed".

That leftover is the residual risk, and it belongs in the register too: what can still happen, how bad it would be and who accepted it. For T1 it might read: "An injected passage may still change the wording of an answer. Accepted, because the assistant has no tool that acts outside the user's own account and every answer carries citations." A residual risk that nobody has written down has been accepted by accident.

Revisit the model whenever its inputs change: a new tool, a new data source, a new group of users, a new model or provider. The test column then becomes your adversarial test set, which you rerun on every change.

05. Check your understanding

Practice check · 3 questions

Mapping threats

Choose the best answer for each question.

Q1. A competitor's script sends thousands of maximum-length questions to your public assistant every hour. In the register this is T7, filed under LLM06 Unbounded Consumption. What does the output of threat_register.py tell you about T7?
Q2. Your system prompt contains the database password so that the model can write connection strings. What should the threat model say?
Q3. Which change should send you back to the threat model before release?
Practice only: not graded, not saved, not evidence.

06. Apply it

Write the one-page threat model for your own RAG assistant, the first part of this skill's practice project:

  1. List its data flows in the format above, and mark every trust boundary they cross.
  2. List the assets, including the ones that are not data: answer integrity, tool authority, budget.
  3. For each boundary, ask the ten OWASP questions and record at least one threat, with its OWASP id, the control you have or plan and the name of the test that will prove it.
  4. Add a residual-risk line for each threat you cannot close, with who accepted it.
  5. Keep the register as data in the repository and adapt the coverage check, so that a threat without a test is visible in every review.

07. Review prompt

Without looking back:

  1. Name five assets of a RAG assistant, including two that are not data.
  2. What is a trust boundary, and why can you not enforce the boundary between retrieved passages and instructions inside the prompt?
  3. Pick four entries of the OWASP LLM 2026 list and say where each shows up in your own assistant.
  4. What is residual risk, and why should it be written down with a name next to it?

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check