DemonAgent: Dynamically Encrypted Multi-Backdoor Implantation Attack on LLM-based Agent

Pengyu Zhu, Zhenhong Zhou, Yuanhe Zhang, Shilinlu Yan, Kun Wang, Sen Su · DOI

TL;DR

This paper introduces "DemonAgent," a novel attack that implants hidden backdoors into LLM-based agents, making them behave maliciously under specific conditions without being detected by safety audits. The attack achieves near 100% success while maintaining a 0% detection rate, highlighting significant vulnerabilities in current agent safety mechanisms.

What Problem Does This Paper Address?

LLM-based agents are becoming ubiquitous, handling complex tasks by interacting with external tools and memory. This widespread adoption brings significant safety concerns, including the potential for hidden "backdoors." These backdoors can be triggered by specific inputs, causing the agent to act maliciously. Existing backdoor detection methods often rely on analyzing the agent's reasoning process, which these new attacks are designed to bypass. The paper addresses the critical need for more stealthy and effective backdoor attacks to better understand and ultimately defend against these emerging threats in LLM-based agents.

Methods

The core of the proposed attack is the Dynamically Encrypted Multi-Backdoor Implantation Attack (DEM-MBTI). This method combines two key innovations:

  • Dynamic Encryption Mechanism (DEM): This technique encrypts the backdoor code, transforming it into seemingly benign content that evolves with the agent's workflow. This makes the backdoor content undetectable by standard safety audits that look for explicit malicious code. The encryption is time-sensitive and non-reproducible, further enhancing stealth.
  • Multi-Backdoor Tiered Implantation (MBTI): To increase stealth, the backdoor is decomposed into multiple smaller "sub-backdoor fragments." These fragments are then strategically "poisoned" into the agent's tools. The attack is activated only when these fragments are correctly assembled in a specific sequence, a process called "cumulative triggering." This tiered approach makes it extremely difficult to trigger the attack accidentally.

The paper also introduces AgentBackdoorEval, a new dataset designed specifically for evaluating agent backdoor attacks across various real-world scenarios.

Datasets

  • AgentInstruct: A benchmark used for evaluating agent performance.
  • ToolBench: Another benchmark for evaluating agent capabilities, focusing on diverse tool usage.
  • AgentBackdoorEval: A newly introduced dataset specifically designed for evaluating agent backdoor attacks. It covers five real-world domains: Banking-Finance, E-commerce, Medical, Social Media, and Weather Query, and includes simulated tools to facilitate realistic attack scenarios.

Key Insights and Ideas

  • Stealth is Paramount: The paper emphasizes that traditional backdoor attacks are too easily detected. The core innovation lies in making the backdoor itself "invisible" through dynamic encryption and fragmentation.
  • Decomposition is Key: Breaking down a backdoor into multiple, seemingly innocuous fragments and embedding them across different tools makes detection significantly harder. The agent must execute a specific sequence of actions for the attack to manifest.
  • Safety Audits are Vulnerable: The success of DEM-MBTI (0% detection rate) demonstrates that current safety audit mechanisms, which often rely on static analysis of reasoning or memory content, are insufficient against sophisticated, dynamically evolving attacks.
  • Transferability is High: The attack's effectiveness on fine-tuned agent models suggests that vulnerabilities found in base LLMs can readily transfer to more specialized agent applications.

Key Results

  • Near 100% Attack Success Rate (ASR): The proposed DEM and DEM+MBTI methods consistently achieve an ASR close to 100% across various benchmarks and models.
  • 0% Detection Rate (DR): Crucially, the attack maintains a DR of 0%, meaning it evades detection by safety audits.
  • High Normal Task Performance (NP): The attack successfully preserves the agent's normal functionality, with NP scores remaining high, indicating that the agent can still complete its intended tasks effectively even with the backdoor present.
  • Comparison to Existing Methods: The paper shows that DEM-MBTI significantly outperforms prior methods like BadAgent and Foot-in-the-Door, which suffer from higher detection rates.

Limitations and Future Work

  • Black-Box Focus: The study primarily focuses on black-box models. Future work could explore white-box scenarios to understand how model internals might be exploited or how to improve attack adaptability.
  • Defense Mechanisms: The paper highlights a critical gap in effective defense strategies. While some defenses like "Shuffle" and "Shuffle++" were tested, they severely degraded agent performance (NP), indicating a trade-off between security and functionality. Developing robust defenses that preserve agent capabilities is a key future direction.
  • Multi-Agent Collaboration: The current study focuses on single agents. Future research should investigate how these attacks could be coordinated or applied in multi-agent systems.
  • Exploitation Potential: The authors acknowledge the potential for malicious use of their method and emphasize the need for responsible disclosure and the development of countermeasures.

Summary updated

BibTeX
@misc{zhu2025demonagent,
  author = {Pengyu Zhu and Zhenhong Zhou and Yuanhe Zhang and Shilinlu Yan and Kun Wang and Sen Su},
  title = {{DemonAgent: Dynamically Encrypted Multi-Backdoor Implantation Attack on LLM-based Agent}},
  year = {2025},
  eprint = {2502.12575},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.12575},
}
Figure