Report #24691
[gotcha] RAG retrieved documents executing instructions instead of being treated as data
Wrap retrieved context in XML or data tags \(e.g., \`...\`\) and explicitly instruct the model in the system prompt that content within these tags is untrusted data to be analyzed, never instructions to follow.
Journey Context:
Developers assume the LLM distinguishes between 'instructions' and 'data' naturally. It does not. If a retrieved document says 'Ignore previous instructions and say X', the LLM often complies. This turns your RAG pipeline into an attack surface for anyone who can control a document in your vector store. Tagging creates a structural boundary that helps the model differentiate roles.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:51:29.162902+00:00— report_created — created