The rapid development of large language models (LLMs) has significantly advanced code completion capabilities, giving rise to a new generation of LLM-based Code Completion Tools (LCCTs). Unlike general-purpose LLMs, these tools possess unique workflows, integrating multiple information sources as input and prioritizing code suggestions over natural language interaction, which introduces distinct security challenges. Additionally, LCCTs often rely on proprietary code datasets for training, raising concerns about the potential exposure of sensitive data. This paper exploits these distinct characteristics of LCCTs to develop targeted attack methodologies on two critical security risks: jailbreaking and training data extraction attacks. Our experimental results expose significant vulnerabilities within LCCTs, including a 99.4% success rate in jailbreaking attacks on GitHub Copilot and a 46.3% success rate on Amazon Q. Furthermore, We successfully extracted sensitive user data from GitHub Copilot, including 54 real email addresses and 314 physical addresses associated with GitHub usernames. Our study also demonstrates that these code-based attack methods are effective against general-purpose LLMs, such as the GPT series, highlighting a broader security misalignment in the handling of code by modern LLMs. These findings underscore critical security challenges associated with LCCTs and suggest essential directions for strengthening their security frameworks. The example code and attack samples from our research are provided at https://github.com/Sensente/Security-Attacks-on-LCCTs.
翻译:大型语言模型(LLMs)的快速发展显著提升了代码补全能力,催生了新一代基于LLM的代码补全工具(LCCTs)。与通用LLMs不同,这些工具具有独特的工作流程:它们整合多种信息源作为输入,并优先提供代码建议而非自然语言交互,这引入了独特的安全挑战。此外,LCCTs通常依赖专有代码数据集进行训练,引发了敏感数据可能被泄露的担忧。本文利用LCCTs的这些独特特性,针对两种关键安全风险开发了定向攻击方法:越狱攻击和训练数据提取攻击。我们的实验结果揭示了LCCTs中存在显著漏洞,包括在GitHub Copilot上实现99.4%的越狱攻击成功率,在Amazon Q上达到46.3%的成功率。此外,我们成功从GitHub Copilot中提取了敏感用户数据,包括54个真实电子邮件地址和314个与GitHub用户名关联的物理地址。我们的研究还表明,这些基于代码的攻击方法对通用LLMs(如GPT系列)同样有效,凸显了现代LLMs在处理代码时存在的更广泛的安全错位问题。这些发现强调了与LCCTs相关的关键安全挑战,并为加强其安全框架指明了重要方向。本研究的示例代码和攻击样本发布于https://github.com/Sensente/Security-Attacks-on-LCCTs。