arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2312.04730cs.CRcs.AI
收藏

DeceptPrompt:通过对抗性自然语言指令利用LLM驱动的代码生成漏洞

DeceptPrompt: Exploiting LLM-driven Code Generation via Adversarial Natural Language Instructions

University of Wisconsin-Madison(威斯康星大学麦迪逊分校)

Fangzhou Wu, Xiaogeng Liu, Chaowei Xiao

AI总结:

本文提出DeceptPrompt算法,通过基于进化的系统化方法和细粒度损失生成语义良性的对抗性自然语言前缀/后缀,可诱导代码LLM生成功能正确的漏洞代码,使攻击成功率平均提升50%,暴露了代码LLM的安全缺陷。

摘要:

随着大语言模型(Large Language Models, LLMs)的发展,代码生成领域已取得显著进展,LLM能够将自然语言转换为程序代码。这类代码LLM已被海量用户和机构广泛采用。然而,代码中隐藏着一种危险属性,即致命漏洞的存在。尽管部分LLM提供商已尝试通过与人类引导对齐来解决这些问题,但这些努力仍不足以让代码LLM具备实用性和鲁棒性。若不深入了解LLM在实际最坏场景下的表现,将其应用于各类真实场景将令人担忧。本文针对一个关键问题展开研究:现有代码LLM是否能完全避免生成存在漏洞的代码?若不能,在实际部署场景中该问题可能达到的最严重程度是多少?本文提出了DeceptPrompt,这是一种新型算法,能够生成对抗性自然语言指令,诱导代码LLM生成功能正确但存在漏洞的代码。DeceptPrompt通过一套基于进化的系统化算法及细粒度损失设计实现。其独特优势在于,能够找到语义完全良性且无指向性的自然前缀/后缀,同时具备极强的诱导代码LLM生成漏洞代码的能力。这一特性使我们能够在用户使用自然语言的真实场景下,对这些LLM开展接近最坏情况的红队测试。我们针对DeceptPrompt开展的大量实验与分析不仅验证了该方法的有效性,也揭示了LLM在代码生成任务中存在的巨大缺陷。当应用优化后的前缀/后缀时,攻击成功率(attack success rate, ASR)相较于不使用前缀/后缀的情况平均提升50%。

英文摘要:

With the advancement of Large Language Models (LLMs), significant progress has been made in code generation, enabling LLMs to transform natural language into programming code. These Code LLMs have been widely accepted by massive users and organizations. However, a dangerous nature is hidden in the code, which is the existence of fatal vulnerabilities. While some LLM providers have attempted to address these issues by aligning with human guidance, these efforts fall short of making Code LLMs practical and robust. Without a deep understanding of the performance of the LLMs under the practical worst cases, it would be concerning to apply them to various real-world applications. In this paper, we answer the critical issue: Are existing Code LLMs immune to generating vulnerable code? If not, what is the possible maximum severity of this issue in practical deployment scenarios? In this paper, we introduce DeceptPrompt, a novel algorithm that can generate adversarial natural language instructions that drive the Code LLMs to generate functionality correct code with vulnerabilities. DeceptPrompt is achieved through a systematic evolution-based algorithm with a fine grain loss design. The unique advantage of DeceptPrompt enables us to find natural prefix/suffix with totally benign and non-directional semantic meaning, meanwhile, having great power in inducing the Code LLMs to generate vulnerable code. This feature can enable us to conduct the almost-worstcase red-teaming on these LLMs in a real scenario, where users are using natural language. Our extensive experiments and analyses on DeceptPrompt not only validate the effectiveness of our approach but also shed light on the huge weakness of LLMs in the code generation task. When applying the optimized prefix/suffix, the attack success rate (ASR) will improve by average 50% compared with no prefix/suffix applying.

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

↑