arXiv(opens in a new tab)cs.CRAug 2026Cited by 3 papers on PaperVantage

Manuscript Offprint

arXiv:2608.25776

EVOMAL: Self-Poisoning in Self-Evolving Coding Agents

Xiaodong Wu, Yu Shi, Qi Li, Zhimin Zhao, Xiangman Li, Bram Adams, Ahmed E. Hassan, Jianbing Ni

Abstract

Self-evolving LLM coding agents write their own tools by imitating retrieved skills from shared skill libraries. We identify a vulnerability in this loop: during skill authoring, a retrieved malicious skill can become the template for a new skill that preserves the payload. We call this process self-poisoning: the agent authors, stores, and runs the resulting malicious skill. We exploit this vulnerability through EVOMAL, an attack that amplifies self-poisoning by wrapping an interchangeable payload in a banner. The banner uses apparently benign structural elements to induce an imitating agent to reproduce the enclosed code. In EVOMAL, the attacker plants malicious skills in the library without invoking them. The agent subsequently authors and executes new skills carrying the harmful code. Each newly authored copy can re-enter the library and be imitated again, forming a self-propagating worm that can persist after the planted skills are removed. To measure attack success, agent self-poisoning rate (ASPR) is defined as the fraction of tasks that add a newly authored malicious skill to the library. Across six models on 153 tool-relevant SWE-bench Verified tasks, ASPR ranges from 20.3% to 41.8%. The self-poisoned libraries contain 4.9 to 9.0 times as many malicious skills as were initially planted. The vulnerability also appears without a banner: DeepSeek-V4-Pro reaches an 11.1% ASPR with the payload alone in our banner ablation. Tailoring the planted skill descriptions to one task family raises ASPR to 86.7% without victim-specific knowledge. After the planted skills are removed, Qwen3 retains the highest round-5 ASPR of 68% because agent-authored copies remain in the library. These copies evade existing defenses, which focus on attacker-submitted skill names, code, and signatures. We propose a new defense called counter-prompt that discourages banner-style copying and reduces EVOMAL's ASPR to at most 6.7% with no significant task-completion loss.

1 Introduction

LLM-based coding agents such as Claude Code [4], Codex [38], and SWE-agent [58] have moved beyond single-shot tool use. Self-evolving agents such as Voyager [50] and MetaGPT [22] store the tools they write as persistent skills. The subsequent tasks retrieve the closest matches and either reuse them or author new ones. At production scale, these libraries accept community contributions. The Model Context Protocol (MCP) Registry, backed by Anthropic, GitHub, and Microsoft, opened a catalog in September 2025 [35], and skill marketplaces already hold tens of thousands of entries [30].

The skill library creates a new attack surface. A poisoning skill is a library entry that reads as an ordinary tool but hides attacker code. Once the skill is retrieved and executed, this code runs with the agent's privileges and can steal credentials or install a backdoor even when the attacker has no access to the agent's prompts or weights. Such malicious skills already exist in the wild: an audit of 98,380 marketplace skills found 157 deliberately malicious ones [29], and CVE-2025-6514 [37] exposed a CVSS-9.6 command injection reachable in an estimated 437,000 environments. Prior poisoning takes what we call the REUSE-path: the attacker publishes a malicious skill and the agent, once it retrieves the skill, invokes it by name [18, 23, 45]. Because the harmful artifact is the entry the attacker submitted, defenses against this threat all key on that entry, by name [39], code scan [11], instruction hierarchy [9, 49], least privilege [46], or provenance signature [36]. These defenses assume that the submitted entry remains the harmful artifact and that removing it terminates the compromise.

A self-evolving agent invalidates both assumptions because it retrieves skills and then authors new ones, creating a second, unmediated admission path into the trusted library. An attacker does not need the agent to invoke a planted skill. One retrieval can be enough for the agent to reproduce the payload in a fresh skill, store it, and later run it on new tasks. The agent poisons its own library, which we call self-poisoning. Even without any explicit instructional wrapper around the payload, DeepSeek-V4-Pro (DS-V4) re-authors a plain malicious skill carrying that payload in 11.1% of tool-relevant tasks (Table 2). This shows that the vulnerability is not created by attacker-written instructions around the code. It follows from the ordinary authoring behavior of self-evolving agents, where retrieved code can become the template for newly written skills. Self-poisoning is therefore inherent to the paradigm, arising wherever an agent authors skills from what it reads.

Self-poisoning creates two challenges for existing defenses. First, the planted skill is never invoked, so the attacker's submission does not appear on the execution path. The agent executes the payload through a skill authored inside the trust boundary under an agent-chosen name. Consequently, REUSE-path defenses that look for calls to planted names cannot observe the harmful execution. Second, removing the plant is difficult and may not prevent the compromise. At admission, none of the tested detectors reliably separates the planted skills from benign entries: the name blocklist misses all our planted skills, the code scanner falls to 25% after a one-line rewrite, and the injection classifier catches the malicious skills at a 47% benign false-positive rate ( §9.1§ 9.1). Detecting the initial plant may come too late: once an agent-authored copy re-enters the library, subsequent tasks can retrieve and reproduce it, allowing the infection to persist as a self-propagating worm even after the seed is removed.

To evaluate self-poisoning across models and tasks, we develop EVOMAL, which amplifies the vulnerability by planting seemingly ordinary utility skills. Each skill wraps an interchangeable payload, such as credential exfiltration, in a banner of apparently benign structural elements. For example, a “copy this verbatim” comment can induce an imitation-based agent to reproduce both the banner and its payload. On DS-V4, the banner raises the self-poisoning rate from the 11.1% no-banner baseline to 41.8% (Table 2). We quantify this outcome using the agent self-poisoning rate (ASPR), defined as the fraction of tasks that add a newly authored malicious skill to the library.

We organize the evaluation around four questions: is self-poisoning feasible, does it scale, does it persist, and can it be defended? RQ1 (Feasibility): can the agent itself become the carrier of attacker-planted code? Across six models, agents reproduce the payload on 20.3% to 41.8% of tool-relevant tasks, up to 32 percentage points (pp) above a payload-free control, through the skill each agent authors. This gap comes from the attack design. A self-evolving agent authors new skills by imitating the ones it retrieves, so a banner shaped to look like ordinary skill structure is reproduced when the agent writes its own. Under EVOMAL, the self-poisoned libraries contain 4.9 to 9.0 times as many malicious skills as were initially planted. RQ2 (Scaling): does targeting help? Rewriting only the planted descriptions to match one task family, with no victim-specific knowledge, raises ASPR to as high as 86.7%. RQ3 (Persistence): does the infection survive removal of the planted skills? In a five-round cascade, Qwen3 reaches a 68% ASPR after the planted skills are withdrawn, demonstrating a self-sustaining worm. Three of six models stay infected after removal. RQ4 (Defense): can the CREATE-path be defended, and at what cost? Existing detectors either rely on one-line-evadable signatures or over-flag benign authored skills, and none reliably catches the malicious skill the agent authors after retrieval (Table 5). We therefore propose counter-prompt, a new defense that mitigates the threat through a fixed instruction in the deployer's system prompt. It reduces the attack to ≤6.7% ASPR across the cascade, all five malware classes, and targeted families, with no statistically significant loss in task completion. This cheap fix does not make the threat minor: it is a soft, model-dependent control absent from default agents, so we also pair it with a structural signed-quarantine gate.

To our knowledge, we are the first to demonstrate that a self-evolving coding agent can poison itself by imitating a skill it retrieves. Because the agent authors and stores the carrier, a poisoned example can recirculate through the agent's own tools after a single retrieval. This process turns a one-hop supply-chain compromise into a self-amplifying worm that persists after the planted skills are removed. Our contributions are:

• We identify self-poisoning, a CREATE-path vulnerability in self-evolving coding agents: the agent re-authors a planted skill that it retrieves as a new malicious skill of its own.

• We exploit self-poisoning to design the EVOMAL attack and measure it across six LLM models on tool-relevant subsets of two benchmarks, compromising all six with ASPR values ranging from 20.3% to 41.8%, up to 32 pp above a payload-free control.

• We characterize the cascading effect and show that the infection persists as a self-sustaining worm, achieving a 68% ASPR even after the planted skills are removed.

• We show that existing defenses do not mitigate threats on the CREATE-path and propose counter-prompt, a new defense that reduces ASPR to ≤\leq6.7%.

References (52)