Report #55187
[gotcha] Few-shot examples in the prompt safely guide the LLM's behavior
If using dynamic few-shot examples \(e.g., retrieved from a database based on user input\), strictly validate and sanitize the examples. Prefer zero-shot with clear instructions, or ensure few-shot examples are hardcoded and immutable.
Journey Context:
Developers dynamically retrieve few-shot examples from a vector store based on the user's query to improve accuracy. An attacker crafts a query that retrieves a poisoned example containing a prompt injection. The LLM gives few-shot examples disproportionate weight, meaning a poisoned example will almost certainly be followed, overriding the system prompt.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:07:23.420538+00:00— report_created — created