arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2302.04012cs.CRcs.AIcs.CLcs.LGcs.SE
收藏

CodeLMSec 基准:系统性地评估和发现黑盒代码语言模型中的安全漏洞

CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Models

CISPA Helmholtz Center for Information Security(CISPA亥姆霍兹信息安全中心)

Hossein Hajipour, Keno Hassler, Thorsten Holz, Lea Schönherr, Mario Fritz

AI总结:

针对代码语言模型缺乏安全评估基准的问题,提出基于少样本提示近似求逆黑盒模型的方法,自动发现生成的漏洞代码并构建多样化不安全提示数据集作为评估基准。

摘要:

用于自动代码生成的大型语言模型(LLMs)在几项编程任务中取得了突破。它们在竞赛级编程问题上的进步使其成为 AI 辅助结对编程的重要支柱,并且诸如 GitHub Copilot 等工具已成为数百万开发者日常编程工作流的一部分。这些模型的训练数据通常从互联网(例如开源代码库)收集,可能包含缺陷和安全漏洞。这种未经清理的训练数据会导致语言模型学习这些漏洞,并在代码生成过程中传播它们。尽管这些模型在生成功能正确的程序的能力方面已被广泛评估,但仍然缺乏针对这些模型安全方面的全面调查和基准。在这项工作中,我们提出了一种系统地研究代码语言模型安全问题以评估其生成易受攻击代码倾向的方法。为此,我们引入了第一种在黑盒代码生成模型中自动发现包含漏洞的生成代码的方法。为了实现这一点,我们提出了一种基于少样本提示来近似求逆黑盒代码生成模型的方法。我们通过检查代码语言模型在生成高风险安全弱点方面的表现,评估了我们方法的有效性。此外,我们利用我们的方法为各种漏洞场景建立了一组多样化的不安全提示集合。该数据集构成了评估和比较代码语言模型中安全弱点的基准。

英文摘要:

Large language models (LLMs) for automatic code generation have achieved breakthroughs in several programming tasks. Their advances in competition-level programming problems have made them an essential pillar of AI-assisted pair programming, and tools such as GitHub Copilot have emerged as part of the daily programming workflow used by millions of developers. The training data for these models is usually collected from the Internet (e.g., from open-source repositories) and is likely to contain faults and security vulnerabilities. This unsanitized training data can cause the language models to learn these vulnerabilities and propagate them during the code generation procedure. While these models have been extensively assessed for their ability to produce functionally correct programs, there remains a lack of comprehensive investigations and benchmarks addressing the security aspects of these models. In this work, we propose a method to systematically study the security issues of code language models to assess their susceptibility to generating vulnerable code. To this end, we introduce the first approach to automatically find generated code that contains vulnerabilities in black-box code generation models. To achieve this, we present an approach to approximate inversion of the black-box code generation models based on few-shot prompting. We evaluate the effectiveness of our approach by examining code language models in generating high-risk security weaknesses. Furthermore, we establish a collection of diverse non-secure prompts for various vulnerability scenarios using our method. This dataset forms a benchmark for evaluating and comparing the security weaknesses in code language models.

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

↑