Software Vulnerability Detection with GPT and In-Context Learning
Authors:
- 18 August 2023
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 229-236
Abstract
Code vulnerability detection is a software security analysis technique that focuses on recognizing and resolving possible code vulnerabilities and weaknesses. Its primary objective is to mitigate the chances of malicious attacks and system failures. Vulnerabilities encompass mistakes, defects, or insecure programming methodologies found within the code, which can lead to security risks, service denials, data leaks, and various other concerns. Previous research has predominantly focused on deep learning models such as VulDeePecker, Russell, and SySeVR. With the advent of large language models, impressive advancements have been made in various domains, including natural language generation, text classification, and sentiment analysis. However, there is currently no effective method for utilizing large language models in vulnerability detection. Therefore, this study explores and validates the application of such models for code vulnerability detection. In this paper we present a context-based learning approach to enhance the capability of code vulnerability detection named VUL-GPT. Our method combines code retrieval and code analysis, leveraging in-context learning to improve the performance of the GPT model in vulnerability detection. Specifically, we use GPT to generate analysis content for the test code and employ code retrieval methods such as BM-25 and TF-IDF to retrieve the most similar code snippet and its vulnerability information from the training set. Subsequently, we input them along with the test code and its analysis into the GPT model, leveraging the contextual learning ability of the large language model for vulnerability detection. Our experiments demonstrate that combining with code retrieval and code analysis, the GPT models can detect code vulnerability detection more effectively.Keywords
This publication has 22 references indexed in Scilit:
- GitHub Copilot AI pair programmer: Asset or Liability?Journal of Systems and Software, 2023
- Retrieval-Based Prompt Selection for Code-Related Few-Shot Learning2023
- Asleep at the Keyboard? Assessing the Security of GitHub Copilot’s Code Contributions2022
- SySeVR: A Framework for Using Deep Learning to Detect Software VulnerabilitiesIEEE Transactions on Dependable and Secure Computing, 2021
- A Novel Neural Source Code Representation Based on Abstract Syntax Tree2019
- SMOKE: Scalable Path-Sensitive Memory Leak Detection for Millions of Lines of Code2019
- Automated Vulnerability Detection in Source Code Using Deep Representation Learning2018
- Modeling and Discovering Vulnerabilities with Code Property Graphs2014
- Static detection of leaks in polymorphic containers2006
- Some Simple Effective Approximations to the 2-Poisson Model for Probabilistic Weighted Retrieval1994