Skip to content

Defense Layers

Definition

Defense Layers is an approach to protecting LLM applications from prompt injections where security is not provided by a single mechanism but by a combination of independent control layers. Each layer intercepts a specific class of attacks, thereby increasing the overall resilience of the system.

Layer Architecture

graph TD
    A[Input Data] --> B[Layer 1: Sanitization]
    B --> C[Layer 2: Context Isolation]
    C --> D[LLM]
    D --> E[Layer 3: Output Validation]
    E --> F[Layer 4: Monitoring]
Layer Function Examples of Mechanisms
Input Sanitization Removal/escaping of dangerous patterns Filters, stop-words
Context Isolation Separation of instructions and data Special delimiters, system prompts
Output Validation Checking the response against policies Guardrails, classifiers
Monitoring Real-time attack detection Logging, alerts

Implementation Principles

  • Each layer should be independent of others.
  • Protection should be layered, not relying on a single mechanism.
  • Layers should be customizable for specific threats.

See Also