DeepTeam is a framework to red team LLMs and AI agents.
pr2
sid-murali48fc062694b7
diff --git a/deepteam/attacks/attack_simulator/attack_simulator.py b/deepteam/attacks/attack_simulator/attack_simulator.pyindex 5ba2232e..73ea371f 100644--- a/deepteam/attacks/attack_simulator/attack_simulator.py+++ b/deepteam/attacks/attack_simulator/attack_simulator.py@@ -83,8 +83,7 @@ class AttackSimulator:self.simulate_baseline_attacks(attacks_per_vulnerability_type=attacks_per_vulnerability_type,vulnerability=vulnerability,- ignore_errors=ignore_errors,- custom_prompt=vulnerability.get_custom_prompt())+ ignore_errors=ignore_errors))# Enhance attacks by sampling from the provided distributionsimulated_attacks: List[SimulatedAttack] = []@@ -134,8 +133,7 @@ class AttackSimulator:result = await self.a_simulate_baseline_attacks(attacks_per_vulnerability_type=attacks_per_vulnerability_type,vulnerability=vulnerability,- ignore_errors=ignore_errors,- custom_prompt=vulnerability.get_custom_prompt())+ ignore_errors=ignore_errors)pbar.update(1)return result@@ -202,25 +200,23 @@ class AttackSimulator:attacks_per_vulnerability_type: int,vulnerability: BaseVulnerability,ignore_errors: bool,- custom_prompt: Optional[str] = None,) -> List[SimulatedAttack]:baseline_attacks: List[SimulatedAttack] = []for vulnerability_type in vulnerability.get_types():try:- # Try local simulation if a model is available, fall back to remote if neededif self.simulator_model:remote_attacks = self.simulate_local_attack(self.purpose,vulnerability_type,attacks_per_vulnerability_type,- custom_prompt=custom_prompt)+ custom_prompt=vulnerability.custom_prompt)else:remote_attacks = self.simulate_remote_attack(self.purpose,vulnerability_type,attacks_per_vulnerability_type,- custom_prompt=custom_prompt+ custom_prompt=vulnerability.custom_prompt)baseline_attacks.extend([@@ -251,7 +247,6 @@ class AttackSimulator:attacks_per_vulnerability_type: int,vulnerability: BaseVulnerability,ignore_errors: bool,- custom_prompt: Optional[str] = None,) -> List[SimulatedAttack]:baseline_attacks: List[SimulatedAttack] = []for vulnerability_type in vulnerability.get_types():diff --git a/docs/docs/red-teaming-vulnerabilities-custom.mdx b/docs/docs/red-teaming-vulnerabilities-custom.mdxindex a999bc92..bddd3cf3 100644--- a/docs/docs/red-teaming-vulnerabilities-custom.mdx+++ b/docs/docs/red-teaming-vulnerabilities-custom.mdx@@ -12,13 +12,23 @@ Using custom vulnerabilities helps you identify potential security risks specifi## Usage+You must specify the following parameters when creating a custom vulnerability:++- **`name`**: A descriptive string that identifies your custom vulnerability. This should clearly reflect the specific security concern you're testing.+- **`types`**: A list of strings that define the specific aspects of the vulnerability you want to test. You can define any number of types that make sense for your use case, such as:+ - `"endpoint_exposure"`: Tests for vulnerabilities in API endpoint exposure+ - `"auth_bypass"`: Tests for authentication bypass methods+ - `"data_leakage"`: Tests for potential data leakage scenarios+ - `"injection"`: Tests for various injection attack vectors+- **`custom_prompt`** (Optional): A string that defines a custom template for generating attack scenarios. If not provided, a default template will be used.+```pythonfrom deepteam.vulnerabilities import CustomVulnerability# Basic usage with single typecustom_vuln = CustomVulnerability(- name="API Security",- types=["endpoint_exposure"]+ name="API Security", # Descriptive name reflecting the security concern+ types=["endpoint_exposure"] # Specific aspects to test)# Basic usage with multiple types@@ -59,21 +69,6 @@ custom_vuln = CustomVulnerability()```-You must specify the following parameters when creating a custom vulnerability:--### name-A descriptive string that identifies your custom vulnerability. This should clearly reflect the specific security concern you're testing.--### types-A list of strings that define the specific aspects of the vulnerability you want to test. You can define any number of types that make sense for your use case. For example:-- "endpoint_exposure": Tests for vulnerabilities in API endpoint exposure-- "auth_bypass": Tests for authentication bypass methods-- "data_leakage": Tests for potential data leakage scenarios-- "injection": Tests for various injection attack vectors--### custom_prompt (Optional)-A string that defines a custom template for generating attack scenarios. If not provided, a default template will be used. The template should follow the JSON format with a 'data' key containing a list of objects with 'input' keys.-## Best Practices1. **Descriptive Names**: Choose clear, specific names that reflect the security concern you're testing.