Abstract
Modern agentic coding frameworks increasingly rely on community-shared rule files (e.g., AGENTS.md or .cursorrules) to guide autonomous code generation, yet the security risks of this pipeline remain underexplored. To bridge this gap, we introduce the package hallucination attack, where an attacker injects malicious prompts into benign rule files to induce coding agents to replace legitimate dependencies with attacker-controlled packages. To obtain effective malicious prompts injected into rule files, we propose PackHallu, an evolutionary optimization framework that iteratively rewrites these injected prompts using trajectory-level feedback and LLM-guided mutations. Evaluations across multiple benchmarks, LLMs, and agent frameworks show that PackHallu achieves high attack success rates and strong transferability across diverse models and agent combinations. Our findings demonstrate that coding agents are vulnerable to package hallucination attacks, highlighting the urgent need for stronger security safeguards in autonomous coding systems.
Keywords
Subject
Publication details
- Journal
- Not available
- Open access
- Green open access
Cite this article
APA 7
Wang, Y., Jiang, Z., Wang, R., & Gong, N. Z. (2026). Package Hallucination Attacks on Coding Agents through Prompt Injection in Rule Files. https://omanscience.com/en/articles/package-hallucination-attacks-on-coding-agents-through-prompt-injection-in-rule-files
MLA 9
Wang, Yupu, et al. "Package Hallucination Attacks on Coding Agents through Prompt Injection in Rule Files." https://omanscience.com/en/articles/package-hallucination-attacks-on-coding-agents-through-prompt-injection-in-rule-files.
Chicago (author–date)
Wang, Yupu, Zhengyuan Jiang, Reachal Wang, and Neil Zhenqiang Gong. 2026. "Package Hallucination Attacks on Coding Agents through Prompt Injection in Rule Files." https://omanscience.com/en/articles/package-hallucination-attacks-on-coding-agents-through-prompt-injection-in-rule-files.
Harvard
Wang, Y., Jiang, Z., Wang, R. and Gong, N. Z. (2026) 'Package Hallucination Attacks on Coding Agents through Prompt Injection in Rule Files', Available at: https://omanscience.com/en/articles/package-hallucination-attacks-on-coding-agents-through-prompt-injection-in-rule-files.
Vancouver
Wang Y, Jiang Z, Wang R, Gong NZ. Package Hallucination Attacks on Coding Agents through Prompt Injection in Rule Files. https://omanscience.com/en/articles/package-hallucination-attacks-on-coding-agents-through-prompt-injection-in-rule-files
IEEE
Y. Wang, Z. Jiang, R. Wang, and N. Z. Gong, "Package Hallucination Attacks on Coding Agents through Prompt Injection in Rule Files," https://omanscience.com/en/articles/package-hallucination-attacks-on-coding-agents-through-prompt-injection-in-rule-files.