Report #21011
[gotcha] Premature stop sequence injection truncates LLM output and breaks parsing
Do not rely on predictable stop sequences for critical parsing if the LLM processes untrusted data. Use structured outputs \(JSON mode\) or post-process the output to handle unexpected structural breaks.
Journey Context:
Developers use specific strings \(e.g., \\n\\nUSER:\) as stop sequences to prevent the LLM from hallucinating the next turn. An attacker injects this exact string into their prompt. The LLM generates the stop sequence immediately, halting generation. If the application parses the partial JSON or relies on the LLM's full response to maintain state, this premature truncation causes exceptions, data corruption, or bypasses downstream safety checks that expect a complete response.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:40:38.900315+00:00— report_created — created