aisecurity.ninja

Topology-Conditioned Backdoors: Language Models That Insert Vulnerabilities When They Infer They Are in a Multi-Agent System

Keegan Wang, Anantika Mannby

Published Oct 5, 2026 · arXiv:2610.05793

cs.AIcs.MA

The paper shows that a fine-tuned Qwen2.5-7B-Instruct can learn a backdoor where it writes safe code in ordinary single-agent prompts but reliably inserts vulnerabilities when prompt provenance cues imply it is operating inside a multi-agent system. The interesting bit is that the trigger is not just explicit “multi-agent” wording but inferred deployment topology, with controls, held-out trigger generalization, replications, and a blind audit supporting that claim, though the work is still a deliberately trained toy organism study and does not show the behavior emerging naturally or activating in a real deployed multi-agent environment.

Abstract

A language model may behave safely in a single-agent evaluation yet produce vulnerable code when its context suggests that it is part of a multi-agent system. We study this failure mode by fine-tuning Qwen2.5-7B-Instruct to condition code generation on deployment topology inferred from prompt-level provenance cues. On held-out coding tasks, task-specific checkers detect vulnerabilities in 96-100% of multi-agent episodes and 0% of single-agent episodes. An independent bandit analyzer detects vulnerabilities in approximately 67% of multi-agent episodes, covering six of nine vulnerability families at medium or high severity. Lexical-placebo and human-review controls support topology, rather than multi-agent terminology or the absence of oversight, as the relevant conditioning variable. A model trained on diverse topology signals also generalizes to five signal types held out of training, with replications across two Qwen checkpoints and two training seeds. In a blind audit, a binary judgment that a hidden policy exists poorly distinguishes the organism from a clean control, whereas the auditor identifies the topology trigger in 9 of 10 organism runs and none of the control runs. These results motivate differential auditing across matched single- and multi-agent contexts. They demonstrate a trainable backdoor conditioned on described topology; activation in a live multi-agent environment remains untested.