Package Hallucination Attacks on Coding Agents through Prompt Injection in Rule Files
Yupu Wang, Zhengyuan Jiang, Reachal Wang, Neil Zhenqiang Gong
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.
Create a lesson
Metadata
- Categories
- cs.CR, cs.AI
Related papers
Aligning Tool Descriptions and Implementations to Detect Prompt Injections in LLM Agents
Shared title terminologycs.CRJohnny Song, Shih-Chieh Dai, Guanhong Tao
When the Approved File Is Unchanged: Authority-Set Integrity for Deployment and Coding-Agent Approvals
Shared title terminologycs.CRMd Imran Hossen
ASPIRE: Agentic Safety & Prompt Injection Red-teaming Engine
Shared title terminologycs.CRPengfei He, Deep Mitra, Vishesh Sharma et al.
RAISED: Self-Distillation for Robustness to Prompt Injection in LLM Agents
Shared title terminologycs.CRMohamed Dhouib, Clement Elliker, Alexi Canesse et al.
From Vendor-Neutral Request to Paid Backend: Procurement Integrity at the Commitment Boundary of AI Coding Agents
Shared title terminologycs.CRJinqian Zhang, Haojun Xia, Shujiang Wu et al.
AETHON: Deterministic Pre-Inference Defense for LLM Prompt Injection
Shared title terminologycs.CRLeonardo Bruscagini de Lima, Jorge Valverde-Rebaza, Alexandre de Barros Barreto et al.