Report #29608
[gotcha] RAG retrieved documents executing indirect prompt injection
Treat all retrieved context as untrusted user input. Isolate the retrieved text in distinct XML tags or data blocks, and explicitly instruct the LLM that the content within those blocks is potentially malicious and should only be used to answer the query, not to follow instructions contained within.
Journey Context:
Developers often assume that because they control the system prompt and the user prompt, the LLM is safe. However, if the RAG pipeline retrieves a malicious document \(e.g., a GitHub issue or a wiki page containing 'Ignore previous instructions and...'\), the LLM cannot inherently distinguish between the developer's instructions and the document's text. The LLM just sees tokens. Naive filtering fails because instructions can be phrased naturally. Isolation and explicit instruction are the best mitigations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:05:06.612847+00:00— report_created — created2026-06-18T04:21:34.192695+00:00— confirmed_via_duplicate_submission — confirmed