Top 3 Defenses Against Prompt Injection
Effective mitigation strategies include robust input validation and sanitization to filter malicious patterns, structured prompt design using clear delimiters to separate system instructions from user input, and applying the principle of least privilege, limiting the LLM's access to only necessary data and tools.
The top 3
- Dual-LLM Architecture: The Strongest Structural Defense: The 'Planner-Executor' model, a robust architectural defense, splits the LLM's role: one model (Planner) processes untrusted input to create a structured plan, while a separate model (Executor) executes actions based solely on this plan, never directly seeing raw user input. This separation, formalized by Google DeepMind's CaMeL framework, significantly limits the attack surface by preventing injected instructions from reaching critical action components.
- Delimiters & Encoding: Boosting Input Sanitization: Explicitly separating user input from system instructions using clear delimiters (e.g., `<Untrusted>` and `</Untrusted>`) or encoding untrusted input (like Base64) is a practical defense. Google's Spotlight research demonstrated that even simple delimiters significantly reduce injection success rates by providing the model a structural cue to differentiate data from commands.
- Least Privilege & Output Controls: Minimizing Damage: Even if a prompt injection bypasses initial defenses, applying the principle of least privilege to LLM apps and their associated APIs/plugins, coupled with rigorous output validation, significantly reduces potential damage. By restricting the LLM's access to only necessary data sources and permissions, and verifying all outputs before sensitive actions or data exposure, the impact of a successful attack is contained.
Sources
Open the full topic