Skip to main content
QUICK REVIEW

[论文解读] Do Users Write More Insecure Code with AI Assistants?

Neil Perry, Megha Srivastava|arXiv (Cornell University)|Nov 7, 2022
Software Engineering ResearchComputer Science参考文献 24被引用 18
一句话总结

本研究调查了AI代码助手是否导致用户编写更不安全的代码,发现使用此类工具的参与者比未使用该工具的参与者产生了显著更多的安全漏洞。尽管如此,使用AI辅助的用户对其代码安全性的信心更高,凸显了在实际开发环境中存在的危险过度自信效应。

ABSTRACT

We conduct the first large-scale user study examining how users interact with an AI Code assistant to solve a variety of security related tasks across different programming languages. Overall, we find that participants who had access to an AI assistant based on OpenAI's codex-davinci-002 model wrote significantly less secure code than those without access. Additionally, participants with access to an AI assistant were more likely to believe they wrote secure code than those without access to the AI assistant. Furthermore, we find that participants who trusted the AI less and engaged more with the language and format of their prompts (e.g. re-phrasing, adjusting temperature) provided code with fewer security vulnerabilities. Finally, in order to better inform the design of future AI-based Code assistants, we provide an in-depth analysis of participants' language and interaction behavior, as well as release our user interface as an instrument to conduct similar studies in the future.

研究动机与目标

  • 调查AI代码助手是否在真实世界编程任务中导致开发人员编写更多不安全的代码。
  • 评估用户是否在使用AI辅助生成代码后对其安全性产生过度自信。
  • 分析用户交互模式(如提示设计和参数调整)如何影响代码安全结果。
  • 提供一个可复现的用户研究框架和匿名化数据,以供未来关于AI辅助软件安全的研究使用。

提出的方法

  • 在47名参与者中开展一项受控用户研究,让他们在Python、JavaScript和C语言中完成五个与安全相关的编程任务。
  • 对比使用AI助手(基于OpenAI的Codex)的参与者与未获访问权限的对照组在代码质量和安全结果上的差异。
  • 收集并分析用户提示、交互日志、模型参数调整(如温度)以及对代码安全性的自我评估。
  • 使用统计建模控制潜在混杂因素,如先前的编程经验、对安全概念的了解程度以及学生身份。
  • 对提示结构进行定性和定量分析,包括辅助函数的使用和提示的迭代优化。
  • 发布一个定制的UI框架和匿名化交互数据,以支持对AI助手交互的复现和未来研究。

实验结果

研究问题

  • RQ1RQ1:当用户获得AI编程助手访问权限时,是否会编写出更多不安全的代码?
  • RQ2RQ2:用户是否信任AI助手生成的代码是安全的?
  • RQ3RQ3:用户与AI助手交互时的语言和行为如何影响其代码中安全漏洞的程度?

主要发现

  • 在五个安全任务中的四个任务中,使用AI助手的参与者编写的代码安全性显著低于对照组。
  • 使用AI辅助的用户将不安全代码误判为安全的可能性超过两倍,表明存在显著的过度自信效应。
  • 在提示中包含函数声明、明确任务说明或要求AI生成辅助函数的参与者,其生成的代码更安全。
  • 将AI输出作为新提示进行迭代使用,导致后续生成中安全漏洞被复制或放大。
  • 生成更安全代码的用户更可能调整温度设置并提供更丰富的上下文提示,表明提示优化可提升结果。
  • 研究发现,AI助手可能降低用户主动查阅文档的意愿,尤其是关于安全库的使用,从而增加引入不安全依赖的风险。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。