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

WildCode 再探:关于 LLM 生成代码安全性的综合实证研究

WildCode Revisited: A Comprehensive Empirical Study on the Security of LLM-Generated Code

Sheridan College(谢里丹学院);Queen’s University(女王大学);Université du Québec en Outaouais (UQO)(魁北克大学瓦塔瓦校区);Concordia University(康科迪亚大学)

Kobra Khanmohammadi, Pooria Roy, Raphael Khoury, Abdelwahab Hamou-Lhadj, Wilfried Patrick Konan, Alexander Da Re, Nicholas Rebelo Melo

AI总结:

通过大规模实证分析真实场景下 ChatGPT 生成的代码,研究其正确性与安全性,并评估常见提示工程策略的有效性,发现 LLM 生成的代码在安全性方面经常不足。

摘要:

LLM 模型越来越多地被用于生成代码,但这些代码的质量和安全性往往不确定。最近几项研究敲响了警钟,表明此类 AI 生成的代码可能特别容易受到网络攻击。然而,这些研究大多依赖于专门为研究生成的代码,这引发了对此类实验真实性的质疑。在本研究中,我们对 ChatGPT 生成的真实代码进行了大规模实证分析。我们从正确性和安全性两方面评估了 ChatGPT 生成的代码,并深入探讨了向模型请求代码的用户的意图。我们还进行了一项实验,使用真实提示评估常见提示工程策略的有效性。我们的研究支持了早期使用合成查询的研究,并证明了 LLM 生成的代码在安全性方面经常不足。此外,我们观察到用户很少询问他们要求 LLM 提供的代码的安全特性。

英文摘要:

LLM models are increasingly used to generate code, but the quality and security of this code are often uncertain. Several recent studies have raised alarm bells, indicating that such AI-generated code may be particularly vulnerable to cyberattacks. However, most of these studies rely on code that is generated specifically for the study, which raises questions about the realism of such experiments. In this study, we perform a large-scale empirical analysis of real-life code generated by ChatGPT. We evaluate code generated by ChatGPT both with respect to correctness and security and delve into the intentions of users who request code from the model. We further performed an experiment to evaluate the effectiveness of common prompt engineering strategies using real-life prompts. Our study supports earlier research that employed synthetic queries and produced proof that LLM-generated code is frequently insufficient in terms of security. Additionally, we observe that users don't ask many questions about the security characteristics of the code they ask LLMs to provide.

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

↑