[Paper Review] An Empirical Cybersecurity Evaluation of GitHub Copilot's Code Contributions
This study evaluates GitHub Copilot's security risks by testing its code generation across 89 scenarios targeting high-risk CWEs from MITRE's Top 25. It reveals that approximately 40% of the 1,692 generated programs contain vulnerabilities, highlighting significant security concerns in AI-assisted coding due to training on potentially buggy open-source code.
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.
Motivation & Objective
- To investigate the prevalence of insecure code in GitHub Copilot's outputs, especially in high-risk security contexts.
- To assess how diverse prompts, weaknesses, and software domains affect Copilot’s tendency to generate vulnerable code.
- To evaluate whether Copilot's training on open-source code exposes it to learning and reproducing exploitable patterns.
Proposed method
- The study designed 89 distinct code generation scenarios targeting high-risk CWEs from MITRE's Top 25 list.
- Copilot was prompted to generate code for each scenario, resulting in 1,692 total programs.
- Generated code was analyzed for vulnerabilities using static analysis and manual inspection based on known security patterns.
- The evaluation considered diversity across three axes: types of weaknesses, prompt variations, and software domains.
- Vulnerabilities were classified according to CWE mappings and validated against known exploit patterns.
- The study quantified the rate of insecure code across different configurations to identify risk factors.
Experimental results
Research questions
- RQ1What is the rate at which GitHub Copilot generates vulnerable code when prompted for high-risk security scenarios?
- RQ2How does prompt diversity influence the likelihood of Copilot generating insecure code?
- RQ3To what extent do different software domains affect the security quality of Copilot's code outputs?
- RQ4Which types of CWEs are most frequently generated by Copilot in insecure forms?
Key findings
- Approximately 40% of the 1,692 code samples generated by GitHub Copilot were found to be vulnerable to known security weaknesses.
- Copilot exhibited a higher propensity to generate insecure code when prompted with scenarios involving injection flaws and improper access control.
- The study found that prompt variation significantly influenced vulnerability rates, with certain phrasings increasing the risk of insecure output.
- Certain high-risk CWEs, particularly those related to input validation and authentication, were disproportionately generated in vulnerable forms.
- The results indicate that Copilot's training on open-source code exposes it to learning and reproducing insecure patterns present in that data.
- The findings suggest that AI pair programming tools like Copilot may inadvertently propagate security flaws if not carefully monitored.
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.