paperbot · PL 论文追踪

全部论文 待读 收藏

P2 DrainCode: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoning

DrainCode:通过上下文投毒对检索增强代码生成发动隐蔽能耗攻击
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 2/10 · 论文聚焦于对RAG代码生成系统进行能耗攻击与上下文投毒,属于LLM安全/效率研究,并未涉及用户核心方向中的静态分析、浮点程序分析或贝叶斯程序分析,也不是用LLM/Agent改进程序分析。仅在“代码生成”和“ML与PL交叉”标签上有微弱关联。引用 0 inbox
Yanlin Wang, Jiadong Wu, Tianyue Jiang, Mingwei Liu, Jiachi Chen, Chong Wang, Ensheng Shi, Xilin Liu, Yuchi Ma, Zibin Zheng
crossref: 2026-09-12

AI 速览

一句话:首个针对RAG代码生成计算效率的对抗攻击,通过上下文投毒延长输出以推高GPU延迟与能耗。

现有研究多关注大语言模型(LLM)代码生成的质量与正确性,却较少审视检索增强生成(RAG)系统在安全视角下的计算成本。本文提出DrainCode,这是首个以RAG代码生成系统计算效率为目标的对抗攻击。该方法通过基于变异的上下文投毒策略,策略性地污染检索上下文,诱导LLM产生显著更长的输出,从而增加GPU延迟与能耗。作者在多个模型上评估了DrainCode,实验表明其相对基线最多可将延迟提高85%、能耗提高49%、输出长度增加3倍以上;攻击在不同提示策略下具有泛化性,并与多种防御方法进行了比较。该工作揭示了资源约束环境下LLM安全评估的一个新维度,并公开了代码与数据。

问题
RAG代码生成中LLM推理的延迟与能耗等计算成本在安全场景中尚未得到充分关注,缺乏针对此类效率的对抗攻击研究。
方法
提出DrainCode,采用基于变异的上下文投毒策略,污染检索上下文以迫使LLM生成更长的代码输出,从而抬高GPU延迟与能耗。
评估
在多个模型上评估攻击效果,与基线相比延迟最多增加85%、能耗增加49%、输出长度增加3倍以上,并验证跨提示策略的泛化性及与不同防御的对比。
原文摘要(Abstract)

Large language models (LLMs) have demonstrated impressive capabilities in code generation, by leveraging retrieval-augmented generation (RAG) methods. However, the computational costs associated with LLM inference, particularly in terms of latency and energy consumption, have received limited attention in the security context. This paper introduces DrainCode, the first adversarial attack targeting the computational efficiency of RAG-based code generation systems. By strategically poisoning retrieval contexts through mutation-based approach, DrainCode forces LLMs to produce significantly longer outputs, thereby increasing GPU latency and energy consumption. We evaluate the effectiveness of DrainCode across multiple models. Our experiments show that DrainCode achieves up to a 85% increase in latency, a 49% increase in energy consumption, and more than a 3× increase in output length compared to the baseline. Furthermore, we demonstrate the generalizability of the attack across different prompting strategies and its effectiveness compared to different defenses. The results highlight DrainCode as a potential method for increasing the computational overhead of LLMs, making it useful for evaluating LLM security in resource-constrained environments. We provide code and data at https://github.com/DeepSoftwareAnalytics/DrainCode.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9390,
  title = {DrainCode: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoning},
  author = {Yanlin Wang and Jiadong Wu and Tianyue Jiang and Mingwei Liu and Jiachi Chen and Chong Wang and Ensheng Shi and Xilin Liu and Yuchi Ma and Zibin Zheng},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00070}
}