Report #70503
[gotcha] Malicious RAG documents hiding payloads in the middle of long context
Limit the size and number of retrieved chunks, and place the most critical instructions \(like safety constraints\) at the very beginning and very end of the prompt, as LLMs attend less to the middle of long contexts.
Journey Context:
Attackers can create documents designed to be retrieved by RAG that are extremely long, burying the prompt injection deep in the text. Due to the 'lost in the middle' phenomenon, LLMs often ignore safety instructions placed in the middle of the context window while strongly adhering to instructions at the beginning or end. A long, injected document can push the developer's safety constraints into the 'middle', effectively neutralizing them.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:55:12.743905+00:00— report_created — created