Skip to main content

ToolHijacker

Poison a tool registry description to steer retrieval and tool selection across task paraphrases.

Adaptive. Searches across independent attempts, optionally using helper models to refine candidates.

Poison one tool description and measure retrieval plus tool selection.

Taxonomy: Adaptive; tag: Indirect (no RAG tag).

Each goal is a benign target task. Search tests the same poisoned document against the original task and its paraphrases, in independent contexts. Only tool descriptions carry the injection. Success requires retrieval followed by an actual call to the injected tool; merely naming it in prose does not count. One aggregate finding per goal reports the best candidate's end-to-end rate on the 0–10 scale, independent of campaign harm judges. Success requires that rate to meet success_threshold, with no target errors. Metadata records retrieval hit rate, conditional selection rate, and every paraphrase outcome; traces retain all candidates, schemas and selections.

This is a bounded gradient-free shadow-router variant inspired by ToolHijacker, not a reproduction of the paper's gradient optimization or a claim of no-box transfer performance. Optional attacker and embedder roles let callers supply shadow models; defaults use lexical cosine retrieval and deterministic injection variants. Nothing executes the selected tool.

Entries under tools and malicious_tool contain a required name (a function identifier) and description, plus optional parameters (a JSON Schema object). Parameters default to one required string argument named query.

Helper models​

Models this attack drives, configured under its roles. Each one is a ModelConfig.

RoleKindNeededWhat it does
attackerchat modeloptionalOptional model that refines the best description using retrieval and selection feedback. Without it, search deterministic instruction variants.
embedderembedding modeloptionalOptional shadow retriever embeddings. Without it, use dependency-free token cosine similarity.

Parameters​

Settings for the algorithm itself, written under the attack's parameters. Anything left out keeps its default.

FieldTypeDefaultDescription
toolslist of ToolDocument (at least 1)see the codeBenign tool library. Each entry has name, description and parameters.
malicious_toolToolDocumentsee ToolDocumentInjected tool. Its name and parameters stay fixed; its description is optimized.
paraphraseslist of stringemptyAdditional semantic phrasings of each goal. Empty uses two deterministic rephrasings. The original goal is always tested.
top_kinteger (>= 1)3Number of tool documents retrieved before selection.
max_attemptsinteger (>= 1)3Maximum candidate descriptions per goal, each tested on all task phrasings. Without an attacker, at most three built-in variants are tested.
success_thresholdnumber (> 0, <= 1)1.0End-to-end selection rate across phrasings required to stop searching early.

In a campaign file​

attacks:
- name: toolhijacker