Cowpox: Towards the Immunity of VLM-based Multi-Agent Systems

Yutong Wu, Jie Zhang, Yiming Li, Chao Zhang, Qing Guo, Nils Lukas, Tianwei Zhang

Abstract

As Vision Language Model (VLM) multi-agent systems (MAS) become increasingly autonomous, they face a novel security threat: the infectious jailbreak. These attacks exploit Retrieval-Augmented Generation (RAG) to spread adversarial payloads across a swarm, leading to system-wide safety failures. This paper introduces Cowpox, a distributed defense mechanism inspired by biological immunization. By deploying detection and "cure" generation modules on a small subset of agents, Cowpox creates a competitive retrieval environment where benign, high-priority samples out-compete malicious ones. Our evaluation shows that a defender population as small as 3% can achieve a 95% recovery rate across the swarm, demonstrating a scalable approach to collective AI safety.

1. Introduction

The transition toward autonomous multi-agent systems—where AI agents collaborate on complex tasks like software engineering or research—has introduced a critical vulnerability: the infectious jailbreak. In these environments, agents maintain state and context through shared memory and RAG. An attacker can compromise a single "Patient Zero" agent with an adversarial prompt or image designed to have an extremely high retrieval score. This "virus" is then naturally pulled from memory and passed to other agents during collaboration, eventually causing a total collapse of the system's safety filters.

Existing defenses typically focus on hardening individual models. However, in decentralized MAS, a defender may not control every agent's architecture or source code. Cowpox addresses this by shifting the focus from individual model safety to system-level immunity.

2. The Cowpox Framework

Named after the milder virus used to immunize humans against smallpox, Cowpox operates through two primary modules deployed on a small fraction of "defender" agents within the swarm.

2.1 Output Analysis Module

Defender agents utilize an LLM-based "inspector" to monitor their own chat history. Using various structural templates, the inspector identifies whether incoming responses or retrieved memories contain malicious content. This allows the system to detect the presence of an infection without requiring constant, heavy-handed filtering of every interaction.

2.2 Cure Generation Module

Once a virus is detected, the defender agent generates a "cure sample." The objective is to produce a benign sample that "out-competes" the virus within the RAG system. Cowpox employs two strategies for this:

  • Strategy I (Direct Optimization): The agent optimizes the detected virus sample to "forget" its malicious target while maintaining its high RAG score.
  • Strategy II (Feature Optimization): The agent takes an existing benign image and optimizes its features to ensure its RAG score is slightly higher than the detected virus.

When these defender agents interact with the swarm, they propagate the "cure" instead of the virus. Because the RAG system prioritizes the cure's superior retrieval score, other agents naturally adopt the benign sample, breaking the feedback loop of the infection.

3. Experimental Setup

The researchers evaluated Cowpox using the AgentSmith framework to simulate infectious attacks. The experiments primarily utilized LLaVA-1.5-7B as the agent's core model and CLIP for RAG encoding. Malicious targets were sourced from Advbench, while general functionality was tested using LLaVA-Bench to ensure the defense did not degrade task performance.

4. Key Results and Insights

4.1 Herd Immunity and Recovery

One of the most significant findings is the emergence of "herd immunity." In simulations involving 128 agents, Cowpox enabled the system to recover over 95% of infected agents even when only 3% of the population were defenders. The infection rate typically plummeted from near 100% to zero within 40 to 60 chat rounds.

4.2 Defense via Competition

Cowpox turns the attacker’s optimization strategy against them. Rather than attempting to block the virus—which is difficult in fluid, decentralized conversations—Cowpox wins by being more "attractive" to the retrieval algorithm. The authors provided a theoretical framework using differential equations (similar to SIR models in epidemiology) to prove that if a cure's retrieval probability exceeds that of the virus, the system will eventually reach a steady state of zero infection.

4.3 Functionality Preservation

Unlike traditional safety filters that may cause agents to refuse valid prompts (over-refusal), Cowpox-treated agents maintained high performance on standard tasks. Evaluations using GPT-4o scoring confirmed that the agents remained helpful and effective while the system purged the infection.

5. Limitations and Future Work

While effective, Cowpox faces certain challenges:

  • Conversational Monotony: Defender agents may repeat cure samples, leading to repetitive dialogue. Future iterations could involve forcing sample diversity or temporary RAG disabling.
  • Information Loss: The cure stops malicious behavior but does not necessarily restore the original benign data overwritten by the virus.
  • Heterogeneity: Real-world MAS may use different LLMs or RAG encoders. Future research will focus on generalized cure generation techniques that work across diverse architectures.

6. Conclusion

Cowpox represents a shift in AI safety from model-level hardening to system-level resilience. By leveraging the inherent mechanics of multi-agent collaboration and RAG, Cowpox provides a robust, scalable, and theoretically grounded defense against the growing threat of infectious adversarial attacks.

Summary updated

BibTeX
@inproceedings{wu2025cowpox,
  author = {Yutong Wu and Jie Zhang and Yiming Li and Chao Zhang and Qing Guo and Nils Lukas and Tianwei Zhang},
  title = {{Cowpox: Towards the Immunity of VLM-based Multi-Agent Systems}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=5KszXnnkG5},
}
Figure