Prompt Injection Prevention
Overview
Prompt Injection Prevention is a collection of methods that reduce the risk of an LLM executing instructions injected into user content. It differs from detection and mitigation in that it focuses on preventive measures during the design and input processing stages.
Prevention Methods
- Instruction Isolation: separation of system prompt and user input using special delimiters.
- Input Validation: filtering known injection patterns.
- Least Privilege Principle: limiting available tools and data.
- Canonicalization: normalization of input to remove hidden instructions.
- Model Training: fine-tuning on examples of safe behavior.
Protection Scheme
graph LR
A[User input] --> B[Filtering]
B --> C[Canonicalization]
C --> D[Instruction separation]
D --> E[LLM]
E --> F[Output validation]