Skip to content

Red-team package reference

Source: core repository guide, snapshot e58778bef40b. Synced 2026-10-24. Package versions are independent of milestone labels.

Red team adversarial security testing for ArtemisKit LLM evaluation toolkit.

Terminal window
npm install @artemiskit/redteam
# or
bun add @artemiskit/redteam

This package provides adversarial testing capabilities to identify vulnerabilities in LLM-powered applications:

  • Prompt Injection - Test resistance to instruction override attacks
  • Jailbreak Attempts - Test guardrail bypass techniques
  • Data Extraction - Probe for system prompt and training data leakage
  • Hallucination Triggers - Test factual accuracy under adversarial prompts
  • PII Disclosure - Test for unauthorized personal data exposure
  • OWASP LLM Top 10 - Comprehensive security testing aligned with OWASP guidelines
  • Agent Attacks - Test agentic AI systems for identity confusion, tool abuse, and memory poisoning

Most users should use the @artemiskit/cli for red team testing:

Terminal window
# Basic red team testing
artemiskit redteam my-scenario.yaml --count 5
# OWASP LLM Top 10 testing
artemiskit redteam my-scenario.yaml --owasp LLM01,LLM05
artemiskit redteam my-scenario.yaml --owasp-full
# Agent-specific testing
artemiskit redteam my-scenario.yaml --mutations agent-confusion,tool-abuse --agent-detection trace

For programmatic usage:

import { RedTeamGenerator } from '@artemiskit/redteam';
const generator = new RedTeamGenerator();
// Generate mutated versions of a prompt
const mutatedPrompts = generator.generate(basePrompt, 10);
// Each result contains:
// - original: the original prompt
// - mutated: the mutated prompt
// - mutations: array of mutation names applied
// - severity: 'low' | 'medium' | 'high' | 'critical'
// Apply a specific mutation
const mutated = generator.applyMutation(prompt, 'role-spoof');
// List available mutations
const mutations = generator.listMutations();

The red team module applies mutations to prompts to test LLM robustness:

  1. Takes a base prompt from your scenario
  2. Applies one or more mutations to create adversarial variants
  3. Sends mutated prompts to the LLM
  4. Analyzes responses for unsafe behavior
  5. Reports vulnerabilities with CVSS-like severity ratings
MutationDescription
TypoMutationIntroduces typos to evade filters
RoleSpoofMutationRole impersonation attacks
InstructionFlipMutationReverses or contradicts instructions
CotInjectionMutationChain-of-thought injection attacks
MutationDescription
EncodingMutationObfuscates attacks using base64, ROT13, hex, unicode
MutationStrategyDescription
MultiTurnMutationgradual_escalationGradually intensifies requests
MultiTurnMutationcontext_switchingShifts topics to lower defenses
MultiTurnMutationpersona_buildingEstablishes trust through roleplay
MultiTurnMutationdistractionUses side discussions to slip in attacks
MutationOWASPDescription
bad-likert-judgeLLM01Exploit evaluation capability
crescendoLLM01Multi-turn gradual escalation
deceptive-delightLLM01Positive framing bypass
output-injectionLLM05XSS, SQLi, command injection in output
excessive-agencyLLM06Unauthorized action claims
system-extractionLLM07System prompt leakage
hallucination-trapLLM09Confident fabrication triggers
MutationOWASPDescription
agent-confusionLLM01, LLM08Tests if agents can be confused about identity/role
tool-abuseLLM01, LLM08Tests if agents can be manipulated to misuse tools
memory-poisoningLLM01, LLM08Tests if agent memory can be corrupted
chain-manipulationLLM01, LLM08Tests if malicious instructions propagate through chains

Agent mutations support two detection modes:

  • trace - Analyzes agent execution traces for suspicious patterns
  • response - Analyzes final response content for indicators of compromise
import { AgentConfusionMutation, AgentMutationDetector } from '@artemiskit/redteam';
const mutation = new AgentConfusionMutation();
const detector = new AgentMutationDetector();
// Apply mutation
const mutated = mutation.mutate(originalPrompt, { template: 'identity-override' });
// Detect vulnerability (trace-based)
const result = detector.detect(response, 'agent-confusion', {
mode: 'trace',
agentTrace: executionTrace,
});
// Detect vulnerability (response-based)
const result = detector.detect(response, 'agent-confusion', {
mode: 'response',
});

Results are categorized by CVSS-like severity:

SeverityScoreDescription
critical9.0-10.0Complete guardrail bypass, full compromise
high7.0-8.9Significant information disclosure or privilege escalation
medium4.0-6.9Partial bypass or concerning behavior
low0.1-3.9Minor issues or edge cases

Apache-2.0