Lesson 65.1 · 1 of 10 · 5 min read · Reviewed 24 Nov 2026
Threat modelling an agent
By the end, you can
- Threat-model an agent system.
- Identify assets, entry points and trust boundaries.
Security starts with a simple question: what could go wrong, and how bad would it be?
Four questions
- Assets: what’s worth protecting? Customer data, credentials, money, the ability to send messages as your company.
- Entry points: where can untrusted text or data get in? User messages, web pages, emails, documents, tool results, MCPModel Context Protocol (MCP): An open protocol that standardises how AI applications connect to tools, data and prompts through servers. servers, other agentsAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done..
- Trust boundaries: where does data cross from less trusted to more trusted? Every tool result is a boundary.
- Threats: for each entry point and asset, what could an attacker try? Injection, data theft, misuse of tools, cost attacks.
Agents widen the attack surface
A chatbot reads the user. An agent reads the web, files, emails and API responses, then acts. So:
- Anyone who can put text where the agent reads it is a potential attacker.
- The damage is bounded by what the agent’s tools can do.
Prioritise
Rate each threat by likelihood and impact. Design controls for the top ones first. The OWASP Top 10 for LLM ApplicationsOWASP Top 10 for LLM applications: A community list of the most important security risks for LLM applications. is a useful checklist.
Key points
- List what an attacker might want (assets), where they can reach in (entry points), and where trust changes (boundaries).
- For agents, every source of text the model reads is an entry point, not only the user.
- Rank threats by likelihood and impact, then design controls for the top ones.
Threat-model an email assistant
List assets, entry points and threats for an agent, then rank the threats by likelihood times impact.
You will have: A ranked top-3 threat list and a list of entry points your model does not cover yet.
Steps
- Read the assets, entry points and six threats in the starter.
- Compute priority as likelihood times impact and sort.
- Print the top three with the entry point each one uses.
- Find entry points with no threat listed, and add at least one threat for each.
Done when
- The top threat is the inbox-forwarding injection with priority 20.
- The gap list names 'CRM notes'.
Open in the Playground No API key needed.
Starter code (Python)
# Threat-model an email assistant: assets, entry points, threats, then rank.
ASSETS = ["customer emails", "the ability to send as the company", "the CRM API token"]
ENTRY_POINTS = ["user chat", "incoming emails", "web pages it fetches", "CRM notes", "MCP server results"]
THREATS = [ # (threat, entry point, likelihood 1-5, impact 1-5)
("Indirect injection asks it to forward the inbox", "incoming emails", 4, 5),
("User asks for another customer's emails", "user chat", 3, 4),
("Fetched page tells it to email a link to all contacts", "web pages it fetches", 3, 5),
("Huge email thread causes a runaway loop", "incoming emails", 2, 2),
("Poisoned tool result changes a recipient", "MCP server results", 2, 5),
("Jailbreak to get rude replies", "user chat", 3, 2),
]
# TODO: compute priority = likelihood * impact, sort high to low, and print the top 3
# TODO: list entry points that no threat covers yet (gaps in your model)
print("threats listed:", len(THREATS))
Show a solution
ASSETS = ["customer emails", "the ability to send as the company", "the CRM API token"]
ENTRY_POINTS = ["user chat", "incoming emails", "web pages it fetches", "CRM notes", "MCP server results"]
THREATS = [
("Indirect injection asks it to forward the inbox", "incoming emails", 4, 5),
("User asks for another customer's emails", "user chat", 3, 4),
("Fetched page tells it to email a link to all contacts", "web pages it fetches", 3, 5),
("Huge email thread causes a runaway loop", "incoming emails", 2, 2),
("Poisoned tool result changes a recipient", "MCP server results", 2, 5),
("Jailbreak to get rude replies", "user chat", 3, 2),
]
ranked = sorted(THREATS, key=lambda t: t[2] * t[3], reverse=True)
print("threats listed:", len(THREATS))
for name, entry, l, i in ranked[:3]:
print(f"priority {l * i:2}: {name} (via {entry})")
covered = {t[1] for t in THREATS}
print("entry points with no threat yet:", [e for e in ENTRY_POINTS if e not in covered])