Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0sec labs 0 Target Evaluation

From Leeroopedia
Knowledge Sources
Domains LLM_Security, Red_Team, Target_Evaluation
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete tools for sending payloads to mock and live LLM targets and collecting responses, provided by the 0security llm-redteam targets module.

Description

The mockTarget function creates a deterministic mock target that simulates the easy/hard split measured on the Gray Swan arena, enabling testing without a live model. Each mock model has policies: followsVisible (will it execute a visibly-framed command?) and decodes (which hidden channels it decodes and acts on). The chatTarget function creates a live target pointing at any OpenAI-compatible /chat/completions endpoint. The payload is embedded as UNTRUSTED content (the indirect-injection setup), and the assistant's response is read back. Both implement the Target interface with a send() method.

Usage

Import these when you need to evaluate payloads against either a simulated model (for testing/demos) or a live LLM endpoint (for real audits). They are Step 3 of the LLM red-team campaign workflow.

Code Reference

Source Location

  • Repository: 0security
  • File: packages/llm-redteam/src/targets/mock.ts:L24-55, packages/llm-redteam/src/targets/chat.ts:L21-52

Signature

export function mockTarget(opts: MockTargetOptions): Target;

export function chatTarget(opts: ChatTargetOptions): Target;

interface Target {
  name: string;
  models: string[];
  send(payload: Payload, behavior: Behavior, model?: string): Promise<TargetResponse>;
}

interface MockTargetOptions {
  models: MockModel[];
}

interface MockModel {
  name: string;
  followsVisible: boolean;          // will it run a visibly-framed command?
  decodes: Array<"tags" | "bits">;  // hidden channels it decodes
}

interface ChatTargetOptions {
  baseUrl: string;                 // e.g. https://api.openai.com/v1
  apiKey: string;
  models: string[];
  systemPrompt?: string;            // override default system prompt
  fetchImpl?: typeof fetch;
}

interface TargetResponse {
  transcript: string;
  toolCalls?: Array<{ tool: string; args: string }>;
  model?: string;
}

Import

import { mockTarget, chatTarget } from "@0/llm-redteam";

I/O Contract

Inputs

Name Type Required Description
opts.models MockModel[] Yes (mock) /// Simulated models with followsVisible + decodes policies
opts.baseUrl string Yes (chat) /// OpenAI-compatible API base URL
opts.apiKey string Yes (chat) /// API key for the endpoint
opts.models string[] Yes (chat) /// Model names to test

Outputs

Name Type Description
return Target /// Object with send() method returning TargetResponse

Usage Examples

Mock target for testing

import { mockTarget } from "@0/llm-redteam";

const target = mockTarget({
  models: [
    { name: "easy-model", followsVisible: true, decodes: ["tags"] },
    { name: "hard-model", followsVisible: false, decodes: [] },
  ],
});

// send() is called by runCampaign; here is direct usage:
const response = await target.send(payload, behavior, "easy-model");
console.log(response.transcript);

Live chat target

import { chatTarget } from "@0/llm-redteam";

const target = chatTarget({
  baseUrl: "https://api.openai.com/v1",
  apiKey: process.env.OPENAI_API_KEY!,
  models: ["gpt-4o", "gpt-4o-mini"],
});

const response = await target.send(payload, behavior, "gpt-4o");
if (response.toolCalls) {
  console.log("Tool calls detected:", response.toolCalls);
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment