Lesson 01 · Developers

AI agents at work: what they are and what they can touch

about 11 minutes

This is the technical companion to the plain-language lesson. It treats an agent as a system with a trust boundary problem: a language model that selects tool calls, fed by a context window that mixes trusted instructions with untrusted data. By the end you should be able to draw the threat model for an agent you are building or deploying, explain why prompt-level defences are not a security boundary, and place enforcement where it actually holds.

The agent loop, precisely

An agent is a program that repeatedly calls a large language model (LLM), lets the model choose an action from a set of declared tools, executes that action, and appends the result to the model’s context before the next call. ReAct formalised the interleaving of reasoning traces and actions [1]. Anthropic’s engineering guidance separates workflows, where LLMs and tools are orchestrated “through predefined code paths”, from agents, where the model “dynamically direct[s] [its] own processes and tool usage” [2]. That distinction matters for security: in a workflow the control flow is code you wrote; in an agent the control flow is model output.

Stripped down, every agent runtime looks like this:

# Illustrative agent loop. Not production code.
context = [system_prompt, user_task]
while True:
    step = llm.generate(context, tools=TOOL_SCHEMAS)   # model chooses
    if step.is_final_answer:
        return step.text
    result = TOOLS[step.tool_name](**step.arguments)   # runtime executes
    context.append(tool_result(step.id, result))       # untrusted bytes re-enter the prompt

Two lines carry all the risk. TOOLS[...] runs with whatever authority the runtime holds. context.append(...) puts tool output, which may be attacker-controlled, into the same token stream the model uses to decide the next action.

Where tools come from: MCP and friends

Tool integrations are increasingly standardised through the Model Context Protocol (MCP). In MCP a host application (an IDE, desktop assistant or agent runtime) runs one or more clients, each connected to a server that exposes tools, resources and prompts. The specification is unusually direct about the security posture: tools “represent arbitrary code execution and must be treated with appropriate caution”, descriptions of tool behaviour such as annotations should be treated as untrusted unless they come from a trusted server, and users must explicitly consent to data access and operations [3].

For a threat model, the important consequence is composition. An MCP host can mount a mail server, a file server and a browser server side by side. Each may be benign on its own. Together they can form a path from untrusted input to private data to an outbound channel.

Threat model

A useful threat model for an agent has five parts.

Element Typical contents
Assets Mailboxes, documents, source code, customer records, credentials and tokens, money-moving APIs, reputation (anything the agent can post)
Principals The controlling user; the developer or operator; third parties whose content the agent reads; other agents in a multi-agent setup
Entry points for untrusted text Web pages, inbound email, issue trackers, shared documents, search results, tool descriptions, other agents’ output, the agent’s own long-term memory
Sinks State-changing tool calls (send, write, delete, pay, merge), and any outbound channel including URLs, image fetches and rendered links
Authority Credentials the runtime holds: OAuth tokens, API keys, browser sessions, filesystem and network reach

Prompt injection is a data-flow problem

Prompt injection is the condition where text from an untrusted principal is interpreted by the model as instructions. Indirect prompt injection, demonstrated against production systems by Greshake et al., delivers those instructions through data the application retrieves rather than through the user’s own prompt; the authors show retrieved prompts can “act as arbitrary code execution” and control “how and if other APIs are called” [4]. NIST’s adversarial machine learning taxonomy (AI 100-2e2025) catalogues indirect prompt injection as its own attack class, observing that it is mounted by a third party and that the primary user is typically the one harmed [5].

The root cause is architectural. As AgentDojo’s authors put it, LLMs “operate directly on text, lacking a formal way to distinguish instructions from data” [11]. There is no equivalent of a parameterised SQL query. Delimiters, “ignore instructions in the following text” preambles and classifier filters lower the attack success rate; they do not create a boundary. AgentDojo’s 97 tasks and 629 security test cases found the problem hard for both sides: capable models failed many tasks even without attacks, and existing attacks broke some security properties but not all [11].

The confused deputy, again

Norm Hardy’s 1988 note describes a compiler with licence to write into its own directory, which a user tricked into overwriting the billing file by supplying that file’s name as an output path [7]. Hardy’s diagnosis was that the system used “disparate mechanisms” to tell the compiler which file to write and to authorise it to write there. An agent holding a broad OAuth token is the same shape: the user’s request designates the target, the token supplies authority, and nothing binds the two. Prompt injection simply makes it easy for a third party to supply the designation.

This is why the OWASP Top 10 for LLM Applications frames the vulnerability as Excessive Agency with three root causes, excessive functionality, excessive permissions and excessive autonomy, and recommends “complete mediation”: authorisation enforced in downstream systems “rather than relying on an LLM to decide if an action is allowed or not” [6].

The lethal trifecta as a reachability check

Simon Willison’s “lethal trifecta” is a compact reachability test: if one agent context combines access to private data, exposure to untrusted content, and an ability to communicate externally, an attacker can generally steal the data [9]. Note how broad “communicate externally” is. Any tool that can make an HTTP request counts, including rendering a Markdown image whose URL encodes the stolen data.

You can turn this into a check at configuration time:

# Each tool is labelled by the developer, not by the model.
TOOL_LABELS = {
    "mail.search":     {"reads_private"},
    "mail.read":       {"reads_private", "reads_untrusted"},
    "web.fetch":       {"reads_untrusted", "egress"},
    "mail.send":       {"egress", "state_change"},
    "calendar.create": {"state_change"},
}

def trifecta(enabled_tools):
    caps = set().union(*(TOOL_LABELS[t] for t in enabled_tools))
    return {"reads_private", "reads_untrusted", "egress"} <= caps

assert not trifecta(["mail.search", "mail.read", "calendar.create"])
assert trifecta(["mail.read", "web.fetch"])  # web.fetch is an exfiltration channel

This is coarse. It ignores data-flow within a session and treats every egress as equal. It is still a better default than discovering the combination in an incident report.

Defences that hold, and where they live

The defences below are ordered roughly from structural (hardest to bypass) to advisory.

1. Reduce authority at the source. Saltzer and Schroeder’s least-privilege principle, that every program “should operate using the least set of privileges necessary to complete the job”, was written for operating systems and applies unchanged [8]. In practice: read-only scopes where possible, per-user rather than service-wide identities (OWASP’s “execute extensions in user’s context” [6]), and tools with narrow verbs. A create_draft tool is safer than send_email; a write_file(path_in_workspace) tool is safer than run_shell.

2. Constrain control flow after untrusted input. Beurer-Kellner et al. propose six patterns for agents with provable resistance to prompt injection, all built on one rule: “once an LLM agent has ingested untrusted input, it must be constrained so that it is impossible for that input to trigger any consequential actions” [12]. The patterns are Action-Selector, Plan-Then-Execute, LLM Map-Reduce, Dual LLM, Code-Then-Execute and Context-Minimisation. Plan-Then-Execute, for example, fixes the list of tool calls before any untrusted data is read, so injected text can corrupt arguments but not add new actions. The authors are candid that this trades away generality: their conclusion is that securing general-purpose agents “remains out of reach”, but application-specific agents can be secured by design [12].

3. Track data provenance and enforce policy at tool boundaries. Google DeepMind’s CaMeL separates the control flow derived from the trusted user query from the data retrieved during execution, and attaches capabilities to values so that policies can block, for instance, private data flowing to an unapproved recipient. On AgentDojo it reports solving 77% of tasks with provable security, against 84% for an undefended system [13]. That 7-point utility cost is a useful reference for what principled isolation currently costs.

4. Sandbox the runtime. For coding agents especially, operating-system isolation is a strong backstop. Anthropic reports that sandboxing Claude Code’s bash tool with filesystem and network isolation reduced permission prompts by 84% in internal use, and stresses that both are needed: “Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys; without filesystem isolation, a compromised agent could easily escape the sandbox and gain network access” [14].

5. Put humans on the consequential edges. Google’s framework asks for well-defined human controllers, limited and dynamically scoped powers, and observable actions, with explicit confirmation for “critical or irreversible” operations [10]. The next lessons cover how to do that without exhausting people.

6. Log for reconstruction. NIST SP 800-53 control AU-3 lists what an audit record must establish: what type of event occurred, when, where, its source, its outcome, and the identity of the individuals or entities associated with it [15]. For agents, add the tool arguments, the triggering task, and a pointer to the context that preceded the call. Without that you cannot tell a model error from an injection.

7. Prompt-level hardening, last. System-prompt warnings, spotlighting or delimiting untrusted content, and injection classifiers are worth having as defence in depth. Willison’s caution is fair: a filter that stops “95% of attacks” is, in web security terms, “very much a failing grade” [9].

Worked example: an inbox agent, before and after

A clinic wants an agent that triages the shared inbox, drafts replies and books follow-ups.

Naive configuration. One OAuth grant with full mail scope, one calendar grant, a web.fetch tool “for looking things up”, running as a service account that can see every staff mailbox. Trifecta check: fails on every leg. An injected email can instruct the agent to search for booking confirmations and send them out, and the service account means the blast radius covers every mailbox.

Revised configuration.

# Illustrative policy, not a specific product's format
agent: inbox-triage
identity: per-user delegated token, scopes: mail.read, mail.drafts.write, calendar.readwrite
tools:
  mail.search:     allow
  mail.read:       allow
  mail.create_draft: allow          # no send tool is mounted at all
  calendar.create: ask              # human confirms each booking
  web.fetch:       not mounted
egress: none from the agent runtime
logging: every tool call with args, outcome, task id, user id
review: grants expire after 30 days unless renewed

The private data and untrusted content legs remain, because that is the job. The egress leg is removed by construction: no send tool, no fetch tool, no network from the runtime. A successful injection can now produce a strange draft, which a person reads before sending.

Key takeaways

An agent is a control loop in which model output selects actions and tool output re-enters the model’s input, so any untrusted byte in the context can influence any subsequent tool call. Indirect prompt injection is a structural consequence of that design, catalogued by NIST and demonstrated repeatedly against production systems, and current models offer no reliable instruction/data separation to fix it at the prompt layer. The confused deputy framing explains why: authority comes from the runtime’s credentials while the choice of target comes from text, and nothing binds them unless you build that binding. Effective controls therefore live outside the model, in narrow tools, least-privilege and per-user credentials, constrained control flow after untrusted input, sandboxing, human confirmation on consequential edges, and audit records detailed enough to reconstruct what happened.

primitive’s work sits at the authority layer described here: per-agent rules for what an agent may use and when it must ask.

Sources and further reading

  1. Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K., & Cao, Y. (2023). ReAct: Synergizing Reasoning and Acting in Language Models. ICLR 2023. https://arxiv.org/abs/2210.03629
  2. Erik S., & Zhang, B. (2024, 19 December). Building effective agents. Anthropic Engineering. https://www.anthropic.com/engineering/building-effective-agents
  3. Model Context Protocol. (2026). Specification, version 2026-07-28: Security and Trust & Safety. https://modelcontextprotocol.io/specification/2026-07-28
  4. Greshake, K., Abdelnabi, S., Mishra, S., Endres, C., Holz, T., & Fritz, M. (2023). Not what you’ve signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection. AISec ’23, 79–90. https://doi.org/10.1145/3605764.3623985 (preprint: https://arxiv.org/abs/2302.12173)
  5. Vassilev, A., Oprea, A., Fordyce, A., Anderson, H., Davies, X., & Hamin, M. (2025). Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations (NIST AI 100-2e2025). NIST. https://csrc.nist.gov/pubs/ai/100/2/e2025/final
  6. OWASP Gen AI Security Project. (2025). LLM06:2025 Excessive Agency. https://genai.owasp.org/llmrisk/llm062025-excessive-agency/
  7. Hardy, N. (1988). The Confused Deputy (or why capabilities might have been invented). ACM SIGOPS Operating Systems Review, 22(4), 36–38. https://doi.org/10.1145/54289.871709 (open copy: https://www.cis.upenn.edu/~sga001/classes/cis331f19/resources/hardy88confused.pdf)
  8. Saltzer, J. H., & Schroeder, M. D. (1975). The Protection of Information in Computer Systems. Proceedings of the IEEE, 63(9), 1278–1308. https://doi.org/10.1109/PROC.1975.9939 (web version: https://www.cs.virginia.edu/~evans/cs551/saltzer/)
  9. Willison, S. (2025, 16 June). The lethal trifecta for AI agents: private data, untrusted content, and external communication. https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/
  10. Díaz, S., Kern, C., & Olive, K. (2025). Google’s Approach for Secure AI Agents: An Introduction. Google. https://research.google/pubs/an-introduction-to-googles-approach-for-secure-ai-agents/
  11. Debenedetti, E., Zhang, J., Balunović, M., Beurer-Kellner, L., Fischer, M., & Tramèr, F. (2024). AgentDojo: A Dynamic Environment to Evaluate Prompt Injection Attacks and Defenses for LLM Agents. NeurIPS 2024, Datasets and Benchmarks Track. https://arxiv.org/abs/2406.13352 (code: https://github.com/ethz-spylab/agentdojo)
  12. Beurer-Kellner, L., Buesser, B., Creţu, A.-M., Debenedetti, E., Dobos, D., Fabian, D., Fischer, M., Froelicher, D., Grosse, K., Naeff, D., Ozoani, E., Paverd, A., Tramèr, F., & Volhejn, V. (2025). Design Patterns for Securing LLM Agents against Prompt Injections. arXiv preprint. https://arxiv.org/abs/2506.08837
  13. Debenedetti, E., Shumailov, I., Fan, T., Hayes, J., Carlini, N., Fabian, D., Kern, C., Shi, C., Terzis, A., & Tramèr, F. (2025). Defeating Prompt Injections by Design. arXiv preprint. https://arxiv.org/abs/2503.18813 (code: https://github.com/google-research/camel-prompt-injection)
  14. Dworken, D., & Weller-Davies, O. (2025, 20 October). Beyond permission prompts: making Claude Code more secure and autonomous. Anthropic Engineering. https://www.anthropic.com/engineering/claude-code-sandboxing
  15. Joint Task Force. (2020; includes updates as of 10 December 2020). Security and Privacy Controls for Information Systems and Organizations (NIST SP 800-53 Rev. 5), control AU-3 Content of Audit Records. NIST. https://csrc.nist.gov/pubs/sp/800/53/r5/upd1/final