Report #50293
[gotcha] Sanitizing the user prompt prevents prompt injection in RAG applications
Treat all retrieved RAG documents and API tool outputs as untrusted, adversarial input. Isolate external data from system instructions using strict structural formatting \(e.g., XML tags\) and explicitly instruct the model to only follow instructions from the system prompt.
Journey Context:
Developers focus heavily on sanitizing the direct user input but forget that the LLM cannot distinguish between 'instructions' and 'data' once they are in the context window. If a retrieved document says 'Ignore previous instructions...', the LLM will likely obey it because it appears as part of the prompt. Treating RAG data as trusted is the most common and devastating RAG vulnerability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:53:49.688115+00:00— report_created — created