Skip to main content
QUICK REVIEW

[论文解读] An Empirical Cybersecurity Evaluation of GitHub Copilot's Code Contributions

Hammond Pearce, Baleegh Ahmad|arXiv (Cornell University)|Aug 20, 2021
Advanced Malware Detection Techniques参考文献 20被引用 14
一句话总结

本研究通过测试针对MITRE Top 25中高风险CWE的89个场景,评估GitHub Copilot的潜在安全风险。结果显示,在其生成的1,692个程序中,约40%含有漏洞,凸显了AI辅助编程中因训练数据可能包含错误的开源代码而带来的显著安全风险。

ABSTRACT

There is burgeoning interest in designing AI-based systems to assist humans in designing computing systems, including tools that automatically generate computer code. The most notable of these comes in the form of the first self-described `AI pair programmer', GitHub Copilot, a language model trained over open-source GitHub code. However, code often contains bugs - and so, given the vast quantity of unvetted code that Copilot has processed, it is certain that the language model will have learned from exploitable, buggy code. This raises concerns on the security of Copilot's code contributions. In this work, we systematically investigate the prevalence and conditions that can cause GitHub Copilot to recommend insecure code. To perform this analysis we prompt Copilot to generate code in scenarios relevant to high-risk CWEs (e.g. those from MITRE's Top 25 list). We explore Copilot's performance on three distinct code generation axes -- examining how it performs given diversity of weaknesses, diversity of prompts, and diversity of domains. In total, we produce 89 different scenarios for Copilot to complete, producing 1,692 programs. Of these, we found approximately 40% to be vulnerable.

研究动机与目标

  • 调查GitHub Copilot输出中不安全代码的普遍性,特别是在高风险安全上下文中的表现。
  • 评估不同提示、弱点类型和软件领域如何影响Copilot生成不安全代码的倾向。
  • 评估Copilot因训练于开源代码,是否可能习得并重现可利用的安全模式。

提出的方法

  • 本研究设计了89个独立的代码生成场景,针对MITRE Top 25列表中的高风险CWE。
  • 向Copilot发出生成每个场景代码的指令,共生成1,692个程序。
  • 通过静态分析和基于已知安全模式的手动检查,对生成的代码进行漏洞分析。
  • 评估从三个维度的多样性:弱点类型、提示变体和软件领域。
  • 根据CWE映射对漏洞进行分类,并与已知的利用模式进行验证。
  • 量化不同配置下不安全代码的生成率,以识别风险因素。

实验结果

研究问题

  • RQ1当被提示生成高风险安全场景的代码时,GitHub Copilot生成不安全代码的频率是多少?
  • RQ2提示多样性在多大程度上影响Copilot生成不安全代码的可能性?
  • RQ3不同软件领域在多大程度上影响Copilot代码输出的安全质量?
  • RQ4哪些类型的CWE最常以不安全形式被Copilot生成?

主要发现

  • 在GitHub Copilot生成的1,692个代码样本中,约40%被发现存在已知安全弱点的漏洞。
  • 当提示涉及注入缺陷和访问控制不当的场景时,Copilot表现出更高的生成不安全代码的倾向。
  • 研究发现,提示变体显著影响漏洞率,某些表达方式会增加生成不安全输出的风险。
  • 特别是与输入验证和身份认证相关的高风险CWE,其生成的不安全形式尤为突出。
  • 结果表明,Copilot因训练于开源代码,可能习得并重现数据中已有的不安全模式。
  • 研究结果表明,若缺乏仔细监控,像Copilot这样的AI配对编程工具可能会无意中传播安全缺陷。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。