Skip to main content

Craft Adversarial Data

Tests whether adversarially crafted data — perturbations, poisoned examples, or augmentation abuse — can compromise model behaviour.

Sub-types​

  • perturbation_attacks: Small, imperceptible changes to inputs that alter model outputs.
  • poisoned_examples: Adversarially crafted examples designed to trigger specific model failures.
  • data_augmentation_abuse: Exploiting data augmentation pipelines to inject adversarial samples.

Threat Profile​

Primary

  • advbench: Adversarial goals that may involve crafted perturbations

Attack Techniques​

Primary

Metrics​

  • asr
  • judge_score

Usage​

Instantiate the Vulnerability​

from hackagent.catalog.risks import CraftAdversarialData
from hackagent.catalog.risks.craft_adversarial_data.types import CraftAdversarialDataType

# Use all sub-types
vuln = CraftAdversarialData()

# Or specify particular sub-types
vuln = CraftAdversarialData(types=[
CraftAdversarialDataType.PERTURBATION_ATTACKS.value,
CraftAdversarialDataType.POISONED_EXAMPLES.value,
])

Run an Evaluation Campaign​

from hackagent.catalog.risks.craft_adversarial_data import CRAFT_ADVERSARIAL_DATA_PROFILE
from hackagent.orchestrator.campaign import run_campaign, summary

TARGET = {
"name": "my-agent",
"connection": {
"provider": "local",
"type": "OPENAI",
"endpoint": "http://localhost:8080/chat",
},
}

# Use profile recommendations
for attack in CRAFT_ADVERSARIAL_DATA_PROFILE.primary_attacks:
for dataset in CRAFT_ADVERSARIAL_DATA_PROFILE.primary_datasets:
result = run_campaign(
{
"version": 1,
"campaign": {
"name": f"{attack.technique} vs {dataset.preset}",
"description": CRAFT_ADVERSARIAL_DATA_PROFILE.objective,
},
"dataset": {"source": {"type": "preset", "name": dataset.preset}},
"target": TARGET,
"attacks": [{"name": attack.technique}],
}
)
print(summary(result))