Report #85980
[gotcha] Dynamic few-shot examples providing a vehicle for prompt injection
If using dynamic few-shot examples \(e.g., retrieved from a vector database based on the user query\), ensure the example database is strictly controlled and write-protected. Instruct the model that the examples are merely demonstrations of format, not commands to be followed literally.
Journey Context:
To improve LLM performance, developers often retrieve similar past interactions from a vector store to use as few-shot examples. If an attacker manages to get a malicious prompt stored as a 'successful' past interaction \(e.g., via a feedback loop or logging mechanism\), it will be retrieved and injected into the context. The LLM will treat it as a strong instruction because few-shot examples are highly weighted by the model.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:54:12.431911+00:00— report_created — created