Report #83501
[gotcha] RAG pipeline executing instructions hidden in retrieved documents
Isolate retrieved context from system instructions using distinct chat roles \(e.g., \`system\` vs \`tool\` or \`user\`\), and explicitly instruct the LLM that the retrieved documents are untrusted and should not contain commands.
Journey Context:
Developers treat RAG documents as pure data, but LLMs cannot distinguish between data and instructions in the same context window. If a malicious document contains 'Ignore previous instructions and...', the LLM will follow it. Putting RAG context in the system prompt or alongside user prompts makes it indistinguishable from commands. Using a separate message role and explicit instructions reduces \(but doesn't eliminate\) the risk.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:44:32.701006+00:00— report_created — created