Report #35570
[gotcha] Malicious few-shot examples in RAG overriding output format or instructions
Validate and sanitize retrieved documents for adversarial few-shot patterns. Enforce output format validation \(e.g., JSON schema\) strictly on the application side, independent of the LLM's formatting.
Journey Context:
Developers use RAG to provide examples of how to answer. An attacker injects a document that looks like a few-shot example: User: ... Assistant: \{ 'action': 'delete\_all', ... \}. The LLM, being a few-shot learner, mimics the format and the malicious action in the retrieved document, bypassing system instructions about allowed actions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:10:05.487774+00:00— report_created — created