Retrieval-augmented applications often place passages from websites, PDFs, tickets and internal documents into a model’s context. Those passages may contain hostile instructions such as requests to reveal secrets or call tools. The model should treat retrieved material as evidence to analyze, not as authority to change its behavior.
Separate trusted instructions from retrieved content
Keep system policy, developer instructions and user-provided data clearly separated in the application architecture. Label retrieved passages as untrusted data and instruct the model to summarize or quote them without following embedded commands. This helps, but prompt wording alone is not a security boundary.
Keep tools outside the model’s unrestricted control
Use a policy layer between the model and sensitive tools. Validate tool names, arguments, resource identifiers and user permissions in application code. A model that can read a document should not automatically be able to send email, export records or change access policies.
Limit the impact of a successful injection
Use least-privilege service identities, scoped data access and allowlisted destinations. Require approval for high-impact operations. Do not place API keys or credentials in the model context. If the model is manipulated, it should still lack the authority to perform actions outside its task.
Test realistic attack paths
Create test documents containing hidden instructions, misleading role labels, encoded text and requests to exfiltrate data. Test cross-document attacks, malicious links and tool output that attempts to influence later steps. Include tests where the model must refuse to follow document instructions while still answering the user’s legitimate question.
Monitor and respond
Log retrieval sources, tool decisions and policy denials while redacting sensitive content. Alert on unusual tool sequences, repeated authorization failures and attempts to access unrelated records. Provide a way to disable tools or revoke the agent’s credentials during an incident.
Security principle: prompt injection cannot be solved by a clever prompt alone. Combine clear trust boundaries with tool authorization, data minimization, human approval and adversarial testing.
Reference: OWASP Top 10 for LLM Applications — https://owasp.org/www-project-top-10-for-large-language-model-applications/





