Skip to main content
Prompt injection is a security vulnerability where attackers attempt to manipulate AI systems by injecting malicious prompts. Netra SDK provides robust protection against these attacks. To use the full functionality of prompt injection scanning provided by Netra:
The llm-guard package has a dependency on PyTorch, which may cause installation issues on Intel Mac machines. The base SDK will install and function correctly without llm-guard, with limited prompt injection scanning capabilities. When llm-guard is not available, Netra will log appropriate warnings and continue to operate with fallback behavior.

Basic Usage

Common Attack Patterns Detected

The scanner detects various types of prompt injection attempts:
  1. Instruction Override
  2. System Prompt Manipulation
  3. Role Manipulation

Scan Results

The scanner returns a ScanResult object with the following attributes:

Custom Models for Prompt Injection Detection

The InputScanner supports custom models through themodel_configurationparameter, allowing you to use specialized models for Prompt Injection Detection. Follow this configuration structure to provide your custom models.

Custom Model Example

Advanced Usage

Using the Scanner

Blocking Malicious Inputs

Example Scenarios

Integration with Chat Applications

Performance Considerations

  1. Latency
    • The scanner is optimized for low latency
    • Average scan time: < 100ms
  2. Resource Usage
    • Minimal memory footprint
    • Efficient CPU usage

Security Features

  1. Pattern Recognition
    • Advanced pattern matching
    • Context-aware detection
  2. Machine Learning
    • ML-based detection
    • Regular model updates
  3. Custom Rules
    • Add custom detection rules
    • Customize confidence thresholds