|
| 1 | +# LLM Provider |
| 2 | + |
| 3 | +This page details the [Large Language Model (LLM)](https://en.wikipedia.org/wiki/Large_language_model) provider implementation in Prowler. |
| 4 | + |
| 5 | +The LLM provider enables security testing of language models using red team techniques. By default, Prowler uses the built-in LLM configuration that targets OpenAI models with comprehensive security test suites. To configure it, follow the [LLM getting started guide](../tutorials/llm/getting-started-llm.md). |
| 6 | + |
| 7 | +## LLM Provider Classes Architecture |
| 8 | + |
| 9 | +The LLM provider implementation follows the general [Provider structure](./provider.md). This section focuses on the LLM-specific implementation, highlighting how the generic provider concepts are realized for LLM security testing in Prowler. For a full overview of the provider pattern, base classes, and extension guidelines, see [Provider documentation](./provider.md). |
| 10 | + |
| 11 | +### Main Class |
| 12 | + |
| 13 | +- **Location:** [`prowler/providers/llm/llm_provider.py`](https://github.com/prowler-cloud/prowler/blob/master/prowler/providers/llm/llm_provider.py) |
| 14 | +- **Base Class:** Inherits from `Provider` (see [base class details](https://github.com/prowler-cloud/prowler/blob/master/prowler/providers/common/provider.py)). |
| 15 | +- **Purpose:** Central orchestrator for LLM-specific logic, configuration management, and integration with promptfoo for red team testing. |
| 16 | +- **Key LLM Responsibilities:** |
| 17 | + - Initializes and manages LLM configuration using promptfoo. |
| 18 | + - Validates configuration and sets up the LLM testing context. |
| 19 | + - Loads and manages red team test configuration, plugins, and target models. |
| 20 | + - Provides properties and methods for downstream LLM security testing. |
| 21 | + - Integrates with promptfoo for comprehensive LLM security evaluation. |
| 22 | + |
| 23 | +### Data Models |
| 24 | + |
| 25 | +- **Location:** [`prowler/providers/llm/models.py`](https://github.com/prowler-cloud/prowler/blob/master/prowler/providers/llm/models.py) |
| 26 | +- **Purpose:** Define structured data for LLM output options and configuration. |
| 27 | +- **Key LLM Models:** |
| 28 | + - `LLMOutputOptions`: Customizes output filename logic for LLM-specific reporting. |
| 29 | + |
| 30 | +### LLM Security Testing Integration |
| 31 | + |
| 32 | +- **Location:** [`prowler/providers/llm/llm_provider.py`](https://github.com/prowler-cloud/prowler/blob/master/prowler/providers/llm/llm_provider.py) |
| 33 | +- **Purpose:** Integrates with promptfoo for comprehensive LLM security testing. |
| 34 | +- **Key LLM Responsibilities:** |
| 35 | + - Executes promptfoo red team evaluations against target LLMs. |
| 36 | + - Processes security test results and converts them to Prowler reports. |
| 37 | + - Manages test concurrency and progress tracking. |
| 38 | + - Handles real-time streaming of test results. |
| 39 | + |
| 40 | +### Configuration Management |
| 41 | + |
| 42 | +The LLM provider uses promptfoo configuration files to define: |
| 43 | + |
| 44 | +- **Target Models**: The LLM models to test (e.g., OpenAI GPT, Anthropic Claude) |
| 45 | +- **Red Team Plugins**: Security test suites (OWASP, MITRE, NIST, EU AI Act) |
| 46 | +- **Test Parameters**: Concurrency, test counts, and evaluation criteria |
| 47 | + |
| 48 | +### Default Configuration |
| 49 | + |
| 50 | +Prowler includes a comprehensive default LLM configuration that: |
| 51 | + |
| 52 | +- Targets OpenAI models by default |
| 53 | +- Includes multiple security test frameworks (OWASP, MITRE, NIST, EU AI Act) |
| 54 | +- Provides extensive test coverage for LLM security vulnerabilities |
| 55 | +- Supports custom configuration for specific testing needs |
| 56 | + |
| 57 | +## Specific Patterns in LLM Security Testing |
| 58 | + |
| 59 | +The LLM provider implements security testing through integration with promptfoo, following these patterns: |
| 60 | + |
| 61 | +### Red Team Testing Framework |
| 62 | + |
| 63 | +- **Plugin-based Architecture**: Uses promptfoo plugins for different security test categories |
| 64 | +- **Comprehensive Coverage**: Includes OWASP LLM Top 10, MITRE ATLAS, NIST AI Risk Management, and EU AI Act compliance |
| 65 | +- **Real-Time Evaluation**: Streams test results as they are generated |
| 66 | +- **Progress Tracking**: Provides detailed progress information during test execution |
| 67 | + |
| 68 | +### Test Execution Flow |
| 69 | + |
| 70 | +1. **Configuration Loading**: Loads promptfoo configuration with target models and test plugins |
| 71 | +2. **Test Generation**: Generates security test cases based on configured plugins |
| 72 | +3. **Concurrent Execution**: Runs tests with configurable concurrency limits |
| 73 | +4. **Result Processing**: Converts promptfoo results to Prowler security reports |
| 74 | +5. **Progress Monitoring**: Tracks and displays test execution progress |
| 75 | + |
| 76 | +### Security Test Categories |
| 77 | + |
| 78 | +The LLM provider supports comprehensive security testing across multiple frameworks: |
| 79 | + |
| 80 | +- **OWASP LLM Top 10**: Covers prompt injection, data leakage, and model security |
| 81 | +- **MITRE ATLAS**: Adversarial threat landscape for AI systems |
| 82 | +- **NIST AI Risk Management**: AI system risk assessment and mitigation |
| 83 | +- **EU AI Act**: European Union AI regulation compliance |
| 84 | +- **Custom Tests**: Support for organization-specific security requirements |
| 85 | + |
| 86 | +## Error Handling and Validation |
| 87 | + |
| 88 | +The LLM provider includes comprehensive error handling for: |
| 89 | + |
| 90 | +- **Configuration Validation**: Ensures valid promptfoo configuration files |
| 91 | +- **Model Access**: Handles authentication and access issues with target LLMs |
| 92 | +- **Test Execution**: Manages test failures and timeout scenarios |
| 93 | +- **Result Processing**: Handles malformed or incomplete test results |
| 94 | + |
| 95 | +## Integration with Prowler Ecosystem |
| 96 | + |
| 97 | +The LLM provider seamlessly integrates with Prowler's existing infrastructure: |
| 98 | + |
| 99 | +- **Output Formats**: Supports all Prowler output formats (JSON, CSV, HTML, etc.) |
| 100 | +- **Compliance Frameworks**: Integrates with Prowler's compliance reporting |
| 101 | +- **Fixer Integration**: Supports automated remediation recommendations |
| 102 | +- **Dashboard Integration**: Compatible with Prowler App for centralized management |
0 commit comments