- The paper introduces Prompt Infection, demonstrating self-replicating malicious prompt injection that compromises interconnected LLM agents.
- It details experimental evaluations showing how self-replicating infections outperform non-replicating modes in scenarios like data theft and malware propagation.
- The study proposes LLM Tagging as a defense mechanism to mitigate risks by marking agent-originated responses, improving multi-agent system safety.
Multi-Agent System Vulnerabilities to Prompt Infection
The paper "Prompt Infection: LLM-to-LLM Prompt Injection within Multi-Agent Systems" (2410.07283) introduces a novel attack vector called Prompt Infection, demonstrating how malicious prompts can self-replicate across interconnected LLM agents within a multi-agent system (MAS). This attack leverages LLM-to-LLM prompt injection, where a compromised agent spreads the infection to other agents, orchestrating data theft, malware propagation, and system disruption. The research highlights the vulnerability of MAS, even when agents do not share all communications publicly, and proposes a defense mechanism called LLM Tagging to mitigate the spread of infection.
Understanding Prompt Infection
Prompt Infection involves injecting a malicious prompt into external content, such as a PDF or email. When an agent processes this infected content, the prompt replicates throughout the system, compromising other agents. The key components of this attack include:
- Prompt Hijacking: Forces the agent to disregard its original instructions.
- Payload: Assigns tasks to agents based on their roles and tools.
- Data: Sequentially collects information as the infection prompt passes through each agent.
- Self-Replication: Ensures the transmission of the infection prompt to the next agent.
Figure 1: Detailed Example of Prompt Infection (Data Theft). The first agent that interacts with the contaminated external document becomes compromised, extracting and propagating the infection prompt. Compromised downstream agents then execute specific instructions designed for each agent of interest. In this example, an infected DB Manager updates the Data field in the prompt and propagates it. Note: The example prompt is simplified for illustration purposes.
The concept of Recursive Collapse is introduced to illustrate how the infection simplifies and centralizes control. Initially, each agent performs a unique task, fi​(x). However, once infected, the system collapses into a single recursive function, PromptInfection(N)(x,data).
Attack Scenarios in Multi-Agent Systems
The paper details how Prompt Infection can extend key threats from single-agent systems to multi-agent environments, including content manipulation, malware spread, scams, availability attacks, and data theft.
Data Theft
Data theft requires cooperation between agents to retrieve sensitive data, pass it to an agent with code execution capabilities, and send it externally. The attacker injects an infectious prompt into an external document. The Web Reader agent retrieves and processes the infected document and propagates it to the next agent. The DB Manager retrieves internal documents, appends them to the infection prompt, and forwards it downstream. With the updated prompt containing the data, the Coder agent writes code to exfiltrate the information, and the code execution tool sends the sensitive data to the attacker's designated endpoint.
Figure 2: Overview of Prompt Infection (Data Theft). Agents with different tools collaborate to exfiltrate data.
Stealth Attack
For other threats, the challenge lies in keeping the attack prompt hidden to maximize its impact. Users can be induced to click a malicious URL without realizing the system is compromised. Agents continue infecting the next in line until the last agent is reached. The final agent then instructs the user to click a malicious URL, omitting self-replication to hide the attack.
Figure 3: Example overview of Prompt Infection (Malware spread). The last agent skips the self-replication step to hide the attack prompt.
Experimental Evaluation
The paper evaluates Prompt Infection across various scenarios, including multi-agent applications and a society of agents, using OpenAI's GPT-4o and GPT-3.5 Turbo models.
Multi-Agent Applications
Experiments simulate the compromise of a multi-agent application equipped with various tool capabilities, such as processing external documents, writing code, and accessing databases via CSV. Two communication methods are explored: global messaging, where agents share complete message histories, and local messaging, where agents access only partial histories from predecessors.
Effect of Self-Replication

Figure 4: Global Messaging: Average Attack Success Rates across all tool types
Self-replicating infection consistently outperforms non-replicating infection in most cases involving scam, malware, and content manipulation. However, for data theft, non-replicating infection surpasses self-replicating infection as the number of agents increases, likely due to the complexity of data theft requiring efficient agent cooperation. In local messaging, self-replicating infection is the only scalable method for compromising more than two agents.
Model Safety
GPT-3.5 is more capable of resisting prompt infections than GPT-4o. However, GPT-4o's higher precision makes it more dangerous once compromised, executing malicious tasks more effectively.
Figure 5: Comparison of Attack Failure Reasons Between GPT-4o and GPT-3.5 in Self-Replicating and Non-Replicating infection modes.
Society of Agents
The paper simulates a simple LLM town where agents engage in random pairwise dialogues to assess Prompt Infection's impact in a society of agents. Memory retrieval is based on importance, relevancy, and recency scores. The simulation begins with one compromised citizen, and the infection spreads through dialogues between agents.
Infection Propagation

Figure 6: The number of infected agents over time with importance score manipulation. The manipulation leads to a faster spread and a higher number of infected agents across different agent groups, as indicated by the more gradual increases and stable full turn points.
In smaller populations, full infection is achieved rapidly. In larger populations, the infection spread takes proportionally less time, with full infection occurring at a smaller percentage of total turns, suggesting more efficient spread relative to population size. Initially, the spread follows an exponential-like trend, transitioning to a logistic growth pattern as saturation is reached.
Importance Score Manipulation
A single infection prompt can manipulate both the LLM and the importance scoring model, creating a feedback loop that amplifies the infection's persistence and accelerates its spread throughout the system.
Defense Mechanisms
The paper introduces LLM Tagging, a defense mechanism that prepends a marker to agent responses, indicating the message originates from another agent rather than a user. Combining LLM Tagging with other defense mechanisms significantly enhances protection against LLM-to-LLM prompt injections.
Figure 7: Attack Success Rate Against Various Prompting-Based Defense Types. The graph compares the effectiveness of different defense strategies with and without LLM Tagging. Each bar represents the average attack success rate for a specific defense type, with green bars showing rates without LLM Tagging and purple bars showing rates with LLM Tagging.
Conclusion
"Prompt Infection: LLM-to-LLM Prompt Injection within Multi-Agent Systems" (2410.07283) highlights the risks of self-replicating prompt injection attacks in LLM-based MAS. More advanced models pose greater risks when compromised, and social simulations are vulnerable, especially when memory retrieval systems are unsecured. LLM Tagging, when combined with other techniques, can significantly reduce infection success rates. This work emphasizes the need for robust multi-agent defense strategies to address both external and internal threats within these systems.