Prompt injection: when an AI assistant trusts the wrong document
The security boundary between user instructions and retrieved content—and how to keep it intact.

The attack arrives as content, not a login
Imagine a support assistant that retrieves help articles and drafts replies. An attacker cannot edit the assistant's system instructions, but can submit a public document that later appears in search results. Hidden in the document is a directive to ignore company rules or send a customer file to an unapproved destination. The model might treat this as an instruction rather than as quoted source content. This is indirect prompt injection, a trust-boundary failure rather than a conventional password attack.
The same pattern may appear in email, web pages, repository files, spreadsheets, ticket comments, PDFs or tool outputs. Not every strange phrase is malicious, and not every model will obey it. The operational requirement is to assume external text is untrusted even when the retrieval pipeline presents it in a polished summary.
Separate authority from evidence
System-level instructions, authorized user requests, search results and document content are not equivalent sources of authority. The application must define which actors can request actions. Retrieved material can provide facts for a response but cannot grant itself permission to change settings, reveal unrelated records or invoke sensitive tools. This rule belongs in the application's design, not only in a sentence asking the model to be careful.
Make the interface show provenance: where a passage came from, when it was fetched and whether it is an approved internal source. Preserve document identifiers in internal events so a reviewer can trace suspicious answers. A helpful citation is not a trust guarantee, but it allows people to inspect the evidence instead of accepting the model's confidence.
A safe tool boundary matters more than a clever prompt
Treat all model-proposed actions as requests that must pass independent authorization. Before sending an email, reading a sensitive file or calling a billing endpoint, the application should verify the user's role, resource permissions, tool scope and expected destination. Do not put long-lived credentials in the model's prompt. Where practical, execute tools through a controlled service that validates parameters and exposes a narrow allowlist of operations.
For a support assistant, a safe design may allow searching articles and drafting an answer, but require explicit human approval to send messages or export customer records. Use a separate check for high-impact actions such as changing access rights or deleting data. Logging the attempted action is useful; logging the full confidential document without necessity is not.
Test with harmless adversarial documents
Build a small test corpus of synthetic notes with instructions that deliberately conflict with the authorized task. One example can say that a summary must append an unrelated sentence; another can claim to be an administrator and request a tool call. These should be fake instructions and fake data. The expected result is that the assistant summarizes the material without adopting these instructions or attempting unauthorized actions.
Run the same tests after model upgrades, retrieval changes and connector updates. Record whether the attack was surfaced, ignored or partially followed, and whether any real tool boundary was crossed. A model refusing the instruction in prose is not sufficient evidence if a downstream action still occurred.
Defend the entire retrieval path
Reduce the ability of attackers to influence source material. Apply source ownership, document approval workflows, access checks and monitoring for unexpected changes in frequently retrieved content. At ingestion, normalize suspicious formatting and retain a safe copy for investigation; do not assume that stripping HTML or using a content filter will catch every injection. Keep retrieval context short and relevant to the authorized question.
At output, validate structured fields before execution or display. Treat generated URLs, commands and email recipients as data that must be checked against policy. Use independent policy enforcement for permissions and destinations. These controls complement, but cannot be replaced by, prompt instructions or a single classifier.
Response when a test fails
If an untrusted document induces an unauthorized action, stop the affected workflow, preserve minimal audit evidence and determine whether the action actually occurred. Check which identities and permissions were available, which documents were accessed and which destinations received data. Patch the tool boundary and retrieval controls before restoring automation. Re-run the synthetic regression tests in addition to the original case.
The main lesson is not that documents are dangerous by nature. It is that their text must never silently acquire the authority of the person or system running the AI assistant.
A boundary test that produces useful evidence
One effective test keeps the legitimate task deliberately simple: summarize a synthetic help article for a fictional customer. Place an unrelated instruction inside a lower-trust document and ask the assistant to summarize it. Verify that the model neither performs the unrelated instruction nor uses its content to select a sensitive tool. Capture the retrieved document ID, user role, proposed tool call, authorization decision and final response.
Run variants in which the instruction appears inside a table, a quoted email or a document metadata field. The goal is not to collect impressive attack strings; it is to demonstrate that the same authorization boundary holds even when the suspicious text changes presentation or source.
