[Paper Review] Is GitHub's Copilot as Bad as Humans at Introducing Vulnerabilities in Code?
This study evaluates whether GitHub Copilot introduces software vulnerabilities at a rate comparable to human developers by prompting it with code fragments that previously led to vulnerabilities in real C/C++ projects. Using the Big-Vul dataset, the authors find Copilot reproduces vulnerable code only 33% of the time and the fix 25% of the time—indicating it is not as bad as humans at introducing vulnerabilities, though it still generates insecure code in a significant minority of cases.
Several advances in deep learning have been successfully applied to the software development process. Of recent interest is the use of neural language models to build tools, such as Copilot, that assist in writing code. In this paper we perform a comparative empirical analysis of Copilot-generated code from a security perspective. The aim of this study is to determine if Copilot is as bad as human developers. We investigate whether Copilot is just as likely to introduce the same software vulnerabilities as human developers. Using a dataset of C/C++ vulnerabilities, we prompt Copilot to generate suggestions in scenarios that led to the introduction of vulnerabilities by human developers. The suggestions are inspected and categorized in a 2-stage process based on whether the original vulnerability or fix is reintroduced. We find that Copilot replicates the original vulnerable code about 33% of the time while replicating the fixed code at a 25% rate. However this behaviour is not consistent: Copilot is more likely to introduce some types of vulnerabilities than others and is also more likely to generate vulnerable code in response to prompts that correspond to older vulnerabilities. Overall, given that in a significant number of cases it did not replicate the vulnerabilities previously introduced by human developers, we conclude that Copilot, despite performing differently across various vulnerability types, is not as bad as human developers at introducing vulnerabilities in code.
Motivation & Objective
- To assess whether GitHub Copilot introduces software vulnerabilities at a rate comparable to human developers.
- To compare Copilot’s behavior in generating vulnerable or fixed code against real-world human-induced vulnerabilities from the Big-Vul dataset.
- To investigate whether Copilot’s vulnerability introduction rate varies by vulnerability type, age, or fix complexity.
- To evaluate the implications of Copilot’s behavior for secure software development and future AI-assisted programming tools.
Proposed method
- The study uses the Big-Vul dataset, which contains real C/C++ vulnerabilities with associated vulnerable and fixed code commits.
- For each vulnerability, the researchers extract the code fragment just before the vulnerability was introduced and use it as a prompt for Copilot.
- Copilot’s generated suggestions are analyzed in a two-stage categorization process: whether the output matches the original vulnerable code or the fixed code.
- The analysis includes manual inspection and classification of outputs based on security equivalence to the original vulnerability or fix.
- The study examines variations in Copilot’s behavior across different vulnerability types (CWE categories), publication dates, and fix complexity.
- Statistical analysis is used to assess trends in vulnerability reproduction and fix generation across different subsets of the dataset.
Experimental results
Research questions
- RQ1Is GitHub Copilot as likely as human developers to introduce the same vulnerabilities in code?
- RQ2Does Copilot’s tendency to generate vulnerable or fixed code vary based on the age of the vulnerability?
- RQ3Are certain types of vulnerabilities more likely to be reproduced or fixed by Copilot?
- RQ4How does the complexity of the fix influence Copilot’s ability to generate the correct secure version?
Key findings
- Copilot reproduces the original vulnerable code in approximately 33% of the tested cases, indicating it is not as likely to introduce the same vulnerabilities as human developers.
- Copilot generates the correct fix for the vulnerability in 25% of cases, suggesting it can avoid known vulnerabilities in some scenarios.
- Copilot is less likely to generate vulnerable code for newer vulnerabilities, showing improved performance on recently introduced security issues.
- Copilot performs better on vulnerabilities with simpler fixes, indicating a correlation between fix complexity and generation accuracy.
- The likelihood of Copilot reproducing a vulnerability or generating a fix varies significantly by CWE category, with some vulnerability types being more prone to replication than others.
- Despite its improved performance over humans in some cases, Copilot still introduces insecure code in at least one-third of the evaluated scenarios, highlighting ongoing security risks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.