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

“你仍然需要学习”——关于大语言模型生成代码的安全性研究

"You still have to study" -- On the Security of LLM generated code

Stefan Goetz, Andreas Schaad

AI总结:

该研究针对4款主流LLM生成代码的安全性展开分析,以MITRE CWE为标准测试Python与Javascript代码,发现初始生成代码不安全占比最高达65%,经熟练工程师人工引导后可接近100%安全,凸显人工安全指导的必要性。

摘要:

我们见证了AI助手的应用日益增多,甚至被用于常规的(课堂)编程任务。然而,程序员基于所谓“提示词”生成的代码并不总能达到公认的安全标准。一方面,这可能是因为训练数据中缺乏最佳实践示例;另一方面,程序员所写提示词的实际质量似乎会影响生成代码是否存在漏洞。本文中,我们针对4款主流大语言模型(LLM)生成代码的安全性展开分析。我们以Python和Javascript语言为案例开展研究,采用MITRE CWE(通用缺陷枚举)目录作为核心安全判定标准。结果显示,使用不同的提示技术时,部分LLM最初生成的代码中有65%被受过训练的安全工程师判定为不安全。另一方面,在熟练工程师不断增加的人工引导下,几乎所有受分析的LLM最终都能生成接近100%安全的代码。

英文摘要:

We witness an increasing usage of AI-assistants even for routine (classroom) programming tasks. However, the code generated on basis of a so called "prompt" by the programmer does not always meet accepted security standards. On the one hand, this may be due to lack of best-practice examples in the training data. On the other hand, the actual quality of the programmers prompt appears to influence whether generated code contains weaknesses or not. In this paper we analyse 4 major LLMs with respect to the security of generated code. We do this on basis of a case study for the Python and Javascript language, using the MITRE CWE catalogue as the guiding security definition. Our results show that using different prompting techniques, some LLMs initially generate 65% code which is deemed insecure by a trained security engineer. On the other hand almost all analysed LLMs will eventually generate code being close to 100% secure with increasing manual guidance of a skilled engineer.

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

↑