When source text contains instructions
An assistant reading a customer email may encounter instructions aimed at the model itself. The text might ask it to reveal order details, change its reply or omit something from a summary.
This is prompt injection: untrusted content attempts to redirect the assistant. The risk depends on the data and tools the assistant can access, so protection needs to extend beyond the wording of its prompt.
Direct and indirect injection
There are two broad forms, and product teams usually think about only the first.
Direct injection
A user types instructions into the feature itself, trying to override its intended behavior: make it ignore its rules, reveal its hidden instructions or produce content it should not. This matters, but the damage is usually limited to what that user could see anyway.
Indirect injection
The instructions arrive inside content the model processes on someone else's behalf: an email, a support ticket, an uploaded document, a web page the feature browses, a product review, a calendar invite. The person harmed is not the one who wrote the text. This is the form that turns an AI feature into a security problem, because the attacker never needs access to your product at all.
Why better prompting is not enough
The first instinct is to add a firm line to the system prompt telling the model to ignore instructions found in user content. It helps a little. It does not solve the problem.
A language model receives everything as one stream of text. Your instructions, the user's question and the email it is summarizing all arrive in the same form, and the model has no dependable way to know which parts carry authority. Researchers and attackers keep finding phrasings that slip past whatever rules the prompt sets. Treat any defense that relies only on the model behaving well as a speed bump, not a wall.
That is uncomfortable, but it leads to the right design principle: assume some injected instructions will get through, and make sure that when they do, very little can happen.
Where the real risk comes from
The impact of injection depends almost entirely on what the model can reach and what it can do.
- A model that only writes text for the same user can produce odd or embarrassing output. Annoying, rarely serious.
- A model with access to private data can be steered into revealing it, for example by including records in a reply or summarizing information the reader should not see.
- A model that can take actions through tools, such as sending emails, updating records, issuing refunds or calling external APIs, can be steered into doing things nobody approved.
- A model that can send data out, even indirectly by rendering links or images that point to an outside address, can leak information without anyone noticing.
The combination to watch is untrusted input plus private data plus a way to act or send data out. If a feature has all three, injection is a design concern from day one.
Defenses that work in layers
No single control is sufficient. Several modest ones together make a big difference.
Give the model the least it needs
Every tool and data source the model can reach is something an injected instruction can try to use. Scope credentials to the exact actions required, separate read access from write access, and avoid giving a summarizing feature the ability to send anything at all. Many injection risks disappear simply because the dangerous capability was never connected.
Keep instructions and data apart
Mark untrusted content clearly when you pass it to the model, and keep your own instructions outside it. Better still, structure the task so untrusted text is only ever processed, never obeyed: extract fields from it, classify it, summarize it into a fixed format. A model asked to return three specific fields has far less room to be redirected than one asked to "handle this email".
Check outputs before they matter
Validate what the model produces before anything acts on it. Enforce schemas, strip or block links and images pointing to unknown domains, check that a drafted reply does not contain data from records the conversation should not touch, and reject tool calls that do not match the expected pattern.
Put a person in front of risky actions
Anything that moves money, changes important records, deletes data or contacts customers should require explicit human approval, at least until you have strong evidence the feature behaves well. The approval screen should show exactly what will happen, not a friendly summary of it.
Log everything
Record the inputs, the model's tool calls and the outputs, with appropriate privacy controls. When something strange happens, you need to be able to see what text triggered it. Logs also show you attempts that failed, which is useful information in itself.
Common mistakes
A few patterns show up again and again in AI features that turn out to be easy to redirect:
- One broad tool instead of several narrow ones. A generic "call any internal API" tool is convenient to build and very hard to defend. Specific tools with fixed parameters are easier to check.
- Trusting content because it came from inside the company. Internal documents, wiki pages and tickets are written by many people and often contain pasted text from outside. Treat them as untrusted input too.
- Approval screens that hide the details. If the person approving sees "send reply to customer" instead of the full message and recipient, the approval step protects very little.
- No plan for incidents. Decide in advance how to switch off a tool or the whole feature quickly if something goes wrong, and who is allowed to do it.
How to test for it
Treat injection like any other failure mode and test for it deliberately.
- Add hostile content to your evaluation set: documents, emails and pages containing instructions aimed at the model, alongside normal inputs. The evaluation approach for LLM features works for security cases too.
- Test indirect paths, not only the chat box. Every source the model reads is an entry point.
- Check the consequences, not just the words. The question is not whether the model repeated the injected text, but whether any data left or any action ran.
- Retest after every change to prompts, tools, models or data sources, since each one shifts behavior.
- Review the design, not only the prompt: list every capability the feature has and ask what happens if an attacker controls the text it reads.
Features that answer from your own documents deserve the same scrutiny, because a poisoned document in the knowledge base becomes an injection source. If you are deciding how such a feature should get its knowledge, our article on RAG vs fine-tuning covers the trade-offs.
Review what the assistant can access
For each AI feature you run or plan, write three short lists: what untrusted text it reads, what private data it can see, and what actions it can take. Wherever all three lists are non-empty, remove a capability, add an approval step or add an output check before anything else. If you are planning a new AI feature and want this built in from the start, our AI development page explains how we approach it.


