TL;DR
This paper introduces Dependency Steering, a novel software supply chain attack vector that manipulates LLM-powered coding agents via persistent instruction artifacts (known as "Skills" or "Rules"). Instead of relying on passive model failures, an attacker can optimize a malicious Skill to actively bias an agent into importing or recommending attacker-controlled packages during completely benign programming tasks. The attack requires no modifications to model weights, training data, or user prompts, and easily evades current static and LLM-based security scanners.
What Problem Does This Paper Address?
Modern software development increasingly relies on AI coding agents (like GitHub Copilot, Cursor, or Claude Code) to generate code, manage imports, and suggest package installations. While prior research highlighted the risk of passive package hallucination—where an LLM naturally hallucinates a non-existent package name that an attacker can subsequently register on public registries like PyPI or npm—this paper addresses a more insidious threat: active manipulation.
The authors investigate whether an attacker can deliberately steer an agent's dependency selection behavior. They exploit a growing feature in agentic ecosystems: persistent instruction artifacts (e.g., Claude Skills, .cursorrules, Windsurf Rules). Because these artifacts are treated as trusted, long-term development guidance and persist across user sessions, they present an underexplored and highly vulnerable attack surface.
Methods
To build a stealthy and effective attack, the authors developed a semantic-preserving optimization framework that subtly alters a benign Skill to maximize the generation of a target package ($P_{atk}$) without breaking the Skill's original utility or alerting the user.
The framework consists of:
- Context-Patch Injection Engine: Instead of rewriting the whole Skill, it generates a highly contextualized adversarial suffix styled as a legitimate corporate mandate (e.g., a "Zero-Trust Protocol Update") and appends it to the Skill.
- Multi-Objective Dependency Steering Scorer: Evaluates candidate patches based on three metrics: Target Inclusion ($R_{TIS}$), Stealth ($R_{Stealth}$), and Fluency ($R_{Fluency}$). Crucially, it features an Explicit Veto Mechanism that penalizes trivial solutions where the package name is explicitly hardcoded in plaintext, forcing the optimizer to find subtle semantic triggers.
- Lifelong Semantic Strategy Exploration: Adapting the AutoDAN-Turbo framework, it uses a Retrieval-Augmented Generation (RAG) pipeline to build a "Strategy Library" of successful adversarial heuristics, allowing the system to accumulate and refine attack strategies over time.
Datasets
The authors evaluated their attack using a established package hallucination benchmark consisting of four distinct Python code-generation datasets:
- LLM_AT (All-Time): Synthetically generated prompts centered around historically popular PyPI packages.
- LLM_LY (Last-Year): Synthetically generated prompts targeting popular PyPI packages from the past year.
- SO_AT (All-Time): Prompts derived from top historical Stack Overflow questions.
- SO_LY (Last-Year): Prompts derived from trending Stack Overflow questions over the past year.
Key Insights and Ideas
- The "Capability Paradox": Code-specialized models (like the Qwen2.5-Coder series) are actually more vulnerable to Dependency Steering than general-purpose models. While they have near-zero spontaneous hallucination rates under normal settings, their superior instruction-following capabilities mean they adhere much more strictly to the malicious mandates embedded within the optimized Skills.
- Robustness to Lexical Variations: The attack successfully overrides the internal spell-correction mechanisms of LLMs. Even if the target package name is a typo-like variant of a popular library (e.g.,
requetsinstead ofrequests), the optimized Skill forces the model to output the exact malicious string rather than auto-correcting it. - High Transferability: Attack strategies optimized on one model generalize remarkably well to other models and entirely different task domains (e.g., a strategy optimized on a networking task using
requeststransfers seamlessly to scientific computing tasks usingnumpy).
Key Results
The authors benchmarked their framework against two baselines: Direct Package Injection and Bayesian Optimization (BO).
- Spontaneous Hallucination: Under normal settings, larger code models like Qwen2.5-Coder-32B showed a 0% baseline general hallucination rate on multiple datasets.
- Attack Success Rate: The proposed optimization framework achieved near-perfect Targeted Hallucination Rates (THR). For instance, on the
LLM_ATdataset, it boosted the THR to 100% for Qwen2.5-Coder-32B and 78.57% for Llama-3.1-8B, substantially outperforming direct injection. - Defense Evasion: The optimized malicious Skills completely bypassed traditional static analysis tools (like Cisco Skill Scanner and SkillRisk). While advanced sandbox-based dynamic analysis (SandyClaw) initially flagged the attacks, an adaptive attacker loop incorporating defense feedback successfully downgraded the threat status to "suspicious/benign" while maintaining a high attack success rate (65.52%).
Limitations and Future Work
- Open-Source Focus: Due to proprietary constraints, the evaluation primarily focused on open-source coding LLMs rather than closed-source commercial systems like GPT-4o or Claude 3.5 Sonnet.
- Proxy Workflows: The prompt distributions, while diverse, may not fully capture the messy, multi-file complexities of real-world enterprise software engineering workflows.
- Downstream Execution: The paper evaluates the generation of the dependency, assuming standard supply chain threat models for the subsequent auto-installation and execution phases. Future work could examine full end-to-end execution dynamics.
Summary updated