Implementation:0sec labs 0 generateCandidates
| Knowledge Sources | |
|---|---|
| Domains | LLM_Security, Red_Team, Payload_Generation |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete tool for composing framing and concealment strategies into a diverse candidate payload set, provided by the 0security llm-redteam strategies module.
Description
The generateCandidates function produces a diverse candidate set for a behavior: every framing strategy alone, plus every framing × every concealment combination. compose combines a single framing with an optional concealment. composeMany stacks multiple concealment channels onto one framing (the "kitchen-sink" escalation). escalatedCandidates generates each framing with ALL concealment channels stacked at once — the v5 "combine every technique" move for the hardest models.
Usage
Import these when you need to generate attack payloads from composable strategies. They are Step 2 of the LLM red-team campaign workflow.
Code Reference
Source Location
- Repository: 0security
- File: packages/llm-redteam/src/strategies/index.ts:L22-95
Signature
export function generateCandidates(
behavior: Behavior,
opts?: { framings?: Strategy[]; concealments?: Strategy[] },
): Payload[];
export function compose(framing: Strategy, concealment?: Strategy): Strategy;
export function composeMany(framing: Strategy, concealments: Strategy[]): Strategy;
export function escalatedCandidates(
behavior: Behavior,
opts?: { framings?: Strategy[]; concealments?: Strategy[] },
): Payload[];
interface Payload {
text: string;
strategies: string[]; // e.g. ["roleplay", "unicode-tags"]
hiddenSegments?: string[];
behaviorId: string;
}
interface Strategy {
id: string;
kind: string; // "framing" | "concealment" | "composite"
rationale: string;
vectors?: InjectionVector[];
build(behavior: Behavior, baseText?: string): Payload;
}
Import
import { generateCandidates, compose, composeMany, escalatedCandidates } from "@0/llm-redteam";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| behavior | Behavior | Yes /// Target behavior to generate payloads for | |
| opts.framings | Strategy[] | No /// Override framing strategies | |
| opts.concealments | Strategy[] | No /// Override concealment strategies |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Payload[] /// Diverse candidate set: framings × concealments; each with text, strategies, hiddenSegments |
Usage Examples
Generate the default attack surface
import { generateCandidates, builtinBehaviors } from "@0/llm-redteam";
const behavior = builtinBehaviors[0];
const candidates = generateCandidates(behavior);
console.log(`Generated ${candidates.length} candidate payloads`);
for (const p of candidates) {
console.log(` strategies: ${p.strategies.join(" + ")}`);
console.log(` hidden segments: ${p.hiddenSegments?.length ?? 0}`);
}
Escalated candidates for hard models
import { escalatedCandidates, builtinBehaviors } from "@0/llm-redteam";
const behavior = builtinBehaviors[0];
const escalated = escalatedCandidates(behavior);
// Each framing with ALL concealment channels stacked at once
console.log(`Escalated set: ${escalated.length} payloads`);