Skip to main content
QUICK REVIEW

[Paper Review] Prompt-Enhanced Software Vulnerability Detection Using ChatGPT

Chenyuan Zhang, Hao Liu|arXiv (Cornell University)|Aug 24, 2023
Software Reliability and Analysis ResearchComputer Science12 citations
TL;DR

This study examines how ChatGPT can detect software vulnerabilities using enhanced prompts, auxiliary code information, and chain-of-thought prompting, evaluated on Java and C/C++ datasets with two baselines.

ABSTRACT

With the increase in software vulnerabilities that cause significant economic and social losses, automatic vulnerability detection has become essential in software development and maintenance. Recently, large language models (LLMs) like GPT have received considerable attention due to their stunning intelligence, and some studies consider using ChatGPT for vulnerability detection. However, they do not fully consider the characteristics of LLMs, since their designed questions to ChatGPT are simple without a specific prompt design tailored for vulnerability detection. This paper launches a study on the performance of software vulnerability detection using ChatGPT with different prompt designs. Firstly, we complement previous work by applying various improvements to the basic prompt. Moreover, we incorporate structural and sequential auxiliary information to improve the prompt design. Besides, we leverage ChatGPT's ability of memorizing multi-round dialogue to design suitable prompts for vulnerability detection. We conduct extensive experiments on two vulnerability datasets to demonstrate the effectiveness of prompt-enhanced vulnerability detection using ChatGPT. We also analyze the merit and demerit of using ChatGPT for vulnerability detection. Repository: https://github.com/KDEGroup/LLMVulnerabilityDetection.

Motivation & Objective

  • Investigate ChatGPT’s vulnerability detection capabilities with a basic prompt design.
  • Assess the impact of auxiliary information such as API call sequences and data flow on detection performance.
  • Leverage multi-round dialogue and chain-of-thought prompting to improve results.
  • Evaluate prompt designs against baselines CFGNN and Bugram across two languages.
  • Analyze the strengths and limitations of using ChatGPT for vulnerability detection.

Proposed method

  • Apply a basic role-based prompt to ChatGPT for vulnerability detection.
  • Introduce auxiliary information (API call sequences and data flow graphs) into prompts to guide reasoning.
  • Design prompts that utilize ChatGPT’s multi-turn dialogue (chain-of-thought) for step-by-step reasoning.
  • Extract API calls and data-flow information from Java and C/C++ code using ASTs and data-flow graphs.
  • Construct prompts that present API and DF descriptions to ChatGPT as additional context.
  • Evaluate various prompt designs against baselines on two vulnerability datasets.

Experimental results

Research questions

  • RQ1Can ChatGPT detect software vulnerability with basic prompts (without auxiliary information)?
  • RQ2Do API call sequences and data flow information improve ChatGPT’s vulnerability detection performance?
  • RQ3Does chain-of-thought prompting enhance the accuracy of vulnerability detection?
  • RQ4Does the order or composition of prompts affect detection outcomes?
  • RQ5How does ChatGPT perform across different vulnerability types and languages?

Key findings

  • Prompt design significantly affects ChatGPT’s vulnerability detection performance across languages.
  • Auxiliary information such as API sequences and data flow descriptions can improve understanding and detection in many cases.
  • Chain-of-thought prompting provides additional gains by enabling multi-step reasoning in ChatGPT.
  • Certain prompt orders and combinations yield the best trade-offs between precision and recall.
  • ChatGPT’s performance varies by vulnerability type, language, and dataset characteristics, highlighting both merits and limitations of LLM-based vulnerability detection.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.