Prompt injection, explained.
A language model cannot reliably tell instructions from data. That single fact explains most of the risk.
What prompt injection is
A language model receives one stream of text. Your instructions, the user's question and any document you paste in all arrive in the same place, and the model decides what to do with all of it. Prompt injection is the act of hiding instructions inside content so that the model follows them as if they came from you.
The simple form is a user typing "ignore your previous instructions". The more serious form is indirect: the instructions sit in a web page, an email or a shared document that the assistant is later asked to summarise. The person asking never wrote the attack and may never notice it.
Why a chat box alone is low risk and tools are not
If the assistant can only produce text for a person to read, a successful injection usually means a wrong or misleading answer. That is a real problem for accuracy, but the damage stops at the screen.
The risk grows with capability. When an assistant can search internal documents, call an API, send a message or run code, injected text can try to make it do those things. The question to ask of every integration is simple: if the model were fully persuaded by a hostile document, what is the worst thing this tool could do?
Practical ways to reduce the risk
Give each tool the least privilege that still lets it work. A search tool that can only read a defined set of documents is far safer than one that can read everything and also write. Prefer read-only access by default and require a person to confirm any action that sends data out, changes records or spends money.
Keep untrusted content clearly separated from instructions in your prompts, and label it as data. This does not make injection impossible, but it makes accidental following of embedded instructions less likely. Limit what the assistant can output into other systems, for example by not rendering arbitrary links or images that could carry data out in a URL.
Log tool calls so you can see what the assistant did and why. When something odd happens, a record of the inputs and actions is what lets you investigate.
Do not rely on a single filter
Filters that look for phrases such as "ignore previous instructions" catch the obvious cases and miss rephrased ones. Treat them as one layer among several. Access control, confirmation steps, output restrictions and monitoring each reduce the impact when another layer fails.
It also helps to be honest with the people using the tool. Tell them that the assistant can be misled by content it reads, and that they should check important results against the source.
Where role-based access helps
Because a prompt cannot be trusted to enforce permissions, access rules belong outside the model. If a user is not allowed to see a document, the retrieval layer should never hand it to the model in the first place. Enforcing permissions in the application, rather than asking the model to behave, is the most dependable protection a self-hosted deployment can add.