GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
arXiv preprint

Design Patterns for Securing LLM Agents against Prompt Injections

Six ways to build agents that resist prompt injection by limiting what untrusted text can touch, worked through ten real applications. The trade is plain: every pattern gives up some generality.

Breakdown by FDE Interviews · 14 min read · Updated

About the original · 2025
AUTHORS
Beurer-Kellner, Buesser, Creţu, Debenedetti, et al.
FROM
ETH Zurich, Invariant Labs, IBM, Google, Microsoft, Swisscom, et al.
PUBLISHED
Jun 2025 · arXiv preprint
CITED BY
104Semantic Scholar · Oct 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 17% of this breakdown.

01

The paper in one minute

Prompt injection happens when text an agent reads, an email, a web page, a resume, a database row, carries instructions the agent then follows. Most defenses try to make the model notice and refuse: classifiers that flag injections, training that teaches models to prefer the developer's instructions, prompts that remind the model of its task. Fourteen authors from ETH Zurich, Invariant Labs, IBM, Google, Microsoft, Swisscom and others argue that, with today's models, none of these can be relied on for general-purpose agents.

Their alternative is to give up generality on purpose. The guiding rule is that once any component has read untrusted input, it must be impossible for that input to trigger a consequential action, meaning an action with side effects on the system or its environment, and its output must not carry the injection onward. The paper describes six patterns that enforce this to different degrees, from an agent that can only choose among fixed actions to one that writes a program whose data flows can be checked.

The second half applies the patterns to ten case studies: an operating-system file assistant, a SQL analytics agent, an email and calendar assistant, a customer-service chatbot, a booking assistant, a product recommender, a resume screener, a medication-leaflet chatbot, a medical-diagnosis intermediary, and a software-engineering agent. For each it walks from a naive design to safer ones, stating what each step costs in utility and what attacks remain. There are no benchmark experiments; the paper is a design guide.

THE IDEA, VISUALLY
SIX PATTERNS, FROM SAFEST TO MOST GENERAL Action selector tool results never return to the model can affect: nothing Plan then execute tools fixed before reading any data can affect: arguments, not which tools LLM map-reduce one isolated model per item, constrained output can affect: its own item's result Dual LLM planner uses quarantined results by reference can affect: values, not the plan Code then execute planner writes a program; data flows checked can affect: what policies allow Context minimization drop the user prompt before replying can affect: the query, not the reply Shared rule: once a component has read untrusted input, it must not be able to trigger a consequential action. RESUME SCREENING, ONE MALICIOUS RESUME our simulation of the paper's case 4.7, 2,000 pools of 20 one model reads all resumes attacker in top 3: 100% honest ranking harmed: 100% isolated scorers, bare number, text smuggled attacker in top 3: 0% honest ranking harmed: 0% isolated scorers, bare number, claims a 10 attacker in top 3: 56% honest ranking harmed: 0% isolated scorers, free-text output attacker in top 3: 78% honest ranking harmed: 100% Isolation contains the attack to the attacker's own result; an unvalidated text channel reopens the door.
Each pattern narrows what untrusted text can reach. In a simulation of the paper's resume-screening case, isolating each document behind a validated output confined an injected resume to its own score.
Research notes: the problem, approach and results
6

design patterns, each restricting what injected text can influence

10

worked case studies, from a file assistant and SQL agent to resume screening and coding agents

0

benchmark experiments: the claims are design arguments, tested in simulation on this page

THE PROBLEM

General-purpose agents read untrusted text and hold powerful tools, and heuristic defenses such as filters, detectors and training cannot guarantee that injected instructions will be ignored.

THE IDEA

Accept that the model can be fooled and design the system so it does not matter: once a component has read untrusted input, it must not be able to trigger a consequential action. Six patterns achieve this to different degrees.

THE RESULT

Action selector, plan-then-execute, LLM map-reduce, dual LLM, code-then-execute and context minimization, each applied to ten case studies from an OS assistant to a medical chatbot, with the utility each one gives up.

02

Why it matters to an FDE

Most customer agents read something an outsider can write: tickets, emails, uploaded documents, supplier data, resumes. This paper gives you a vocabulary for the conversation every security review eventually reaches: what can a malicious document make this agent do?

Ask what the agent needs to be general about. Many business agents do one job. A customer-service bot that only ever picks among a dozen actions can use the action-selector pattern and be immune to injection by construction.

Process untrusted items one at a time. If the task is "check each invoice" or "score each resume", run an isolated model per item with an output that is a number, a category or a yes/no. A poisoned item can then only affect its own result.

Constrain the outputs, not just the inputs. Isolation fails the moment a free-text output from an untrusted step reaches a component with tools. Force schemas, enums and numbers at those boundaries.

Name the residual risk honestly. Every pattern leaves something: a malicious resume can still claim a high score for itself; a calendar injection can still rewrite the body of an email it is part of. Write it down for the customer.

Treat user confirmation as a backup, not the design. The paper notes that confirmations burden users and that attacks can be dressed up to look harmless.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 99 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The six patterns in detail, the best practices, case-study lessons, and the misreadings to avoid

    Free account
  2. 04How it works

    Each pattern's information flow, the case-study method, and how patterns combine

    Premium
  3. 05The numbers that matter

    There are no benchmark numbers; here is what the case studies establish instead

    Premium
  4. 06Try it yourself

    Simulate the resume-screening case and watch isolation contain an injected resume

    Premium
  5. 07Where it breaks

    The limits of design-only guidance and of the patterns themselves

    Premium
  6. 08Using it on a deployment

    Running a design review of a customer agent against the six patterns

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →