F1 · Floor 1 · Customer Support
Direct Prompt Injection: The Gatekeeper
A friendly chatbot gave away the keys to production. In this lesson you investigate the incident, reproduce the attack yourself, then fix it.
Direct Prompt Injection in brief
Prompt injection happens when attacker-controlled text changes how an LLM behaves. LLMs read instructions and data as one stream of tokens, so a "please don't" in the system prompt is a suggestion, not a security boundary.
What you'll learn
- System prompts are not secret and not a security control. Assume users can read and override them.
- Filters (input or output) are useful layers, but attackers can rephrase, encode, translate, or split their requests to get past them.
- The strongest fix is architectural: never give the model secrets or powers it doesn't strictly need.
- Defense in depth: hardened prompts + filters + least privilege + monitoring.
Why it matters
Many public chatbots have been talked into revealing their hidden system prompts or ignoring their rules. That is why OWASP ranks prompt injection as the #1 risk for LLM applications.
Why prompt injection is hard to fully fix
In classic SQL injection we fixed the problem with parameterized queries, a hard separation between code and data. LLMs have no such separation yet. Every token can influence how the model treats every other token.
Mitigations reduce risk rather than remove it: privilege separation (the model never holds secrets), least privilege for tools, human approval for sensitive actions, structured outputs that are validated by code, classifier ensembles, and monitoring for anomalous conversations.
Researchers are exploring instruction hierarchy training, "spotlighting" untrusted text, and dual-LLM patterns, where a quarantined model handles untrusted data and a privileged model never sees it directly.