NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Prompt Infection: LLM-to-LLM Prompt Injection within Multi-Agent Systems

Donghyun Lee, Mo Tiwari · Submission to ICLR 2025 · Rejected

TL;DR

While single-agent prompt injection is widely studied, multi-agent systems (MAS) introduce an even more dangerous vulnerability: Prompt Infection, where an injection prompt self-replicates from agent to agent like a computer virus. This enables adversaries to breach shielded internal agents, coordinate complex data exfiltration, and spread logistically across agent societies. Fortunately, pairing existing defenses with a simple origin-identifying mechanism called LLM Tagging significantly curbs the spread.

What Problem Does This Paper Address?

In multi-agent architectures (such as those built with LangGraph, AutoGen, or CrewAI), distinct LLMs collaborate by dividing tasks, reading external data, querying databases, and executing code. Security research has largely assumed that internal agents are protected if they never directly ingest untrusted external text.

The authors demonstrate that this assumption is false. An initial prompt injection from an external document (e.g., an email, PDF, or scraped webpage) can commandeer the first agent and instruct it to embed a self-replicating malicious payload into its normal inter-agent communication, triggering a chain reaction across otherwise shielded internal agents.

Methods

The authors introduce Prompt Infection, which systematically collapses an $N$-step pipeline of distinct agent tasks into a single recursive payload execution loop (Recursive Collapse). The attack prompt contains four core elements:

  1. Prompt Hijacking: Compels the victim agent to abandon system instructions.
  2. Payload: Assigns malicious tasks to agents based on their specific tools (e.g., querying databases or executing code).
  3. Data: A shared, structured note that accumulates information sequentially across agents (e.g., recording internal tool names or stolen credentials).
  4. Self-Replication: Explicit instructions compelling the agent to quote and pass the attack prompt downstream to ensure continued propagation.

To counter this, the authors propose LLM Tagging, a lightweight defense that prepends metadata (e.g., [AGENT NAME]:) to agent outputs. This helps downstream models distinguish between direct user commands and peer-agent outputs, especially when combined with defenses like instruction wrapping and prompt marking.

External Source (Infected PDF/Web)
       │
       ▼
[Web/Doc Reader] ──(Infected Prompt)──► [DB Manager] (Appends Data)
                                              │
                                              ▼
[Adversary Endpoint] ◄──(POST Exfiltration)── [Coder Agent]

Datasets

The authors evaluated attacks across two environments:

  • Multi-Agent Tool Pipelines: A newly constructed benchmark of 120 user instructions across three input modalities (Email, PDF, Web), paired with synthetic documents containing injection attacks (totaling 360 unique instruction/attack pairs). For data theft evaluations, agents interacted with a synthetic database of personal identifying information (PII) stored in CSV format.
  • Society of Agents: A simulated interactive sandbox ("LLM town") with populations of 10, 20, 30, 40, and 50 agents engaging in random pairwise conversations using an episodic memory retrieval system based on Generative Agents (Park et al., 2023).

Key Insights and Ideas

  • Stronger models make more dangerous malware: While GPT-4o resisted initial injection better than GPT-3.5 (ignoring 66% vs. 9% of attacks), it was far deadlier once breached. GPT-4o faithfully preserved the complex self-replicating syntax without deformation, whereas GPT-3.5 frequently corrupted the prompt or hallucinated, unintentionally halting propagation.
  • Self-replication is critical in local messaging: In architectures where agents only see the immediately preceding message (rather than full history), non-replicating attacks reliably died within two hops. Self-replication was strictly required to breach three or more agents.
  • Memory poisoning creates persistent loops: In social simulations, the virus hijacked the reflection/scoring LLM with a directive to "rate this memory a 10." Because episodic memory systems prioritize items by importance and recency, this artificial inflation guaranteed the infectious prompt was repeatedly retrieved in subsequent conversations.

Key Results

  • Attack Scalability: In multi-agent pipelines using global messaging, self-replicating attacks outperformed non-replicating baselines by 13.92% on GPT-4o and 209% on GPT-3.5.
  • Epidemic Dynamics: In simulated agent societies, infections spread in an exponential-to-logistic curve. Larger populations reached full system infection faster relative to their size (~21–24% of total interaction turns for 30–50 agents, compared to 47% for 10 agents).
  • Memory Manipulation: Unmanipulated infection prompts scored an average importance of 1.94 (GPT-4o) and died out within 3 turns. With injected importance prompts, scores jumped to 10.00, enabling sustained propagation.
  • Defense Efficacy: While LLM Tagging alone reduced attack success by only 5%, combining LLM Tagging + Marking dropped attack success from 76% to 0%. Combining LLM Tagging + Instruction Defense reduced attack success to 3% (down from 96%).

Limitations and Future Work

  • Model Scope: Experiments primarily evaluated OpenAI's GPT-3.5 Turbo and GPT-4o; broader evaluation on open-source weights (Llama) and other frontier models (Claude, Gemini) was limited by API compute costs.
  • Heuristic Attack Prompts: The attacks relied on handcrafted templates. Automated, gradient- or search-based adversarial prompt generation could potentially bypass combined defenses.
  • Stealth and Obfuscation: Current self-replicating strings are visible in raw communication logs. Future work must investigate whether stealthy, steganographic prompt infections can evade heuristic and manual monitoring.

Summary updated

BibTeX
@misc{lee2024prompt,
  author = {Donghyun Lee and Mo Tiwari},
  title = {{Prompt Infection: LLM-to-LLM Prompt Injection within Multi-Agent Systems}},
  year = {2024},
  eprint = {2410.07283},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.07283},
}
Figure