Report #48814
[gotcha] Large retrieved documents exhausting context window causing truncation of system prompt
Enforce strict size limits on retrieved documents and user inputs. Place critical system instructions at the end of the prompt \(near the user query\) rather than the beginning, as many LLM APIs truncate from the beginning or middle when context limits are exceeded, or use robust truncation logic.
Journey Context:
When using RAG, developers often concatenate \[System Prompt\] \+ \[Retrieved Docs\] \+ \[User Query\]. If an attacker can inject a massive document into the retrieval source, it can fill the context window. Depending on the LLM's truncation strategy, this can push the system prompt out of the context window entirely, stripping the LLM of its safety guidelines and operational constraints. Placing the system prompt at the end \(or using APIs that guarantee system prompt persistence\) mitigates this.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:25:07.106635+00:00— report_created — created