arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2601.20615cs.SE
收藏

DRAINCODE: 通过上下文污染对基于检索增强的代码生成进行隐秘的能量消耗攻击

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

Sun Yat-sen University(中山大学);Huawei Cloud Computing Technologies Co. Ltd.(华为云计算技术有限公司);Nanyang Technological University(南洋理工大学)

Yanlin Wang, Jiadong Wu, Tianyue Jiang, Mingwei Liu, Jiachi Chen, Chong Wang, Ensheng Shi, Xilin Liu, Yuchi Ma, Zibin Zheng

AI总结:

DrainCode通过上下文污染攻击,显著增加LLM的延迟和能耗,揭示了RAG代码生成系统在安全性和资源约束下的潜在风险。

摘要:

大型语言模型(LLMs)通过利用检索增强生成(RAG)方法在代码生成方面展示了令人印象深刻的能力。然而,LLM推理相关的计算成本,特别是延迟和能耗,在安全领域受到有限关注。本文介绍了DrainCode,这是首个针对RAG基于代码生成系统计算效率的对抗性攻击。通过一种基于突变的方法污染检索上下文,DrainCode迫使LLMs生成显著更长的输出,从而增加GPU延迟和能耗。我们评估了DrainCode在多个模型上的有效性。实验显示,DrainCode相比基线实现了高达85%的延迟增加,49%的能耗增加,以及超过3倍的输出长度增加。此外,我们展示了该攻击在不同提示策略下的通用性及其与不同防御措施的对比效果。结果突显DrainCode作为一种增加LLM计算开销的方法,使其在资源受限环境中评估LLM安全性时具有实用性。我们提供了代码和数据在https://github.com/DeepSoftwareAnalytics/DrainCode。

英文摘要:

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 a 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 an 85% increase in latency, a 49% increase in energy consumption, and more than a 3x 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑