How ChatGPT is Solving Vulnerability Management Problem

Peiyu Liu, Junming Liu, Lirong Fu, Kangjie Lu, Yifan Xia, Xuhong Zhang, Wenzhi Chen, Haiqin Weng, Shouling Ji, Wenhai Wang

Abstract

Recently, ChatGPT has attracted great attention from the code analysis domain. Prior works show that ChatGPT has the capabilities of processing foundational code analysis tasks, such as abstract syntax tree generation, which indicates the potential of using ChatGPT to comprehend code syntax and static behaviors. However, it is unclear whether ChatGPT can complete more complicated real-world vulnerability management tasks, such as the prediction of security relevance and patch correctness, which require an all-encompassing understanding of various aspects, including code syntax, program semantics, and related manual comments. In this paper, we explore ChatGPT's capabilities on 6 tasks involving the complete vulnerability management process with a large-scale dataset containing 70,346 samples. For each task, we compare ChatGPT against SOTA approaches, investigate the impact of different prompts, and explore the difficulties. The results suggest promising potential in leveraging ChatGPT to assist vulnerability management. One notable example is ChatGPT's proficiency in tasks like generating titles for software bug reports. Furthermore, our findings reveal the difficulties encountered by ChatGPT and shed light on promising future directions. For instance, directly providing random demonstration examples in the prompt cannot consistently guarantee good performance in vulnerability management. By contrast, leveraging ChatGPT in a self-heuristic way -- extracting expertise from demonstration examples itself and integrating the extracted expertise in the prompt is a promising research direction. Besides, ChatGPT may misunderstand and misuse the information in the prompt. Consequently, effectively guiding ChatGPT to focus on helpful information rather than the irrelevant content is still an open problem.

Introduction

Vulnerability management is a high-stakes, labor-intensive process essential for software security. It involves a complex chain of tasks ranging from the initial reporting of an issue to the final merging of a stable patch into a repository. While Large Language Models (LLMs) have shown promise in general coding, the security domain is uniquely challenging due to its reliance on deep program semantics and domain-specific expertise. This paper provides the first holistic evaluation of ChatGPT’s performance across the entire vulnerability management lifecycle.

The Vulnerability Management Pipeline

The researchers evaluated ChatGPT across six distinct stages of the software security lifecycle, as illustrated in the figure below. These stages represent the journey from issue discovery to final repository commitment.

The six stages of the vulnerability management lifecycle, from reporting to repository merging.
  1. Bug Report Summarization: Condensing technical reports into actionable summaries.
  2. Security Bug Identification: Distinguishing security threats (SBRs) from general non-security bugs (NBRs).
  3. Vulnerability Severity Evaluation: Mapping bugs to CVSS severity scores.
  4. Vulnerability Repair: Generating code fixes for identified vulnerabilities.
  5. Patch Correctness Assessment: Verifying if a generated fix actually addresses the underlying issue.
  6. Stable Patch Classification: Determining if a patch is suitable for long-term release.

Methodology: Evaluation Framework

To rigorously test ChatGPT, the authors developed a three-phase evaluation pipeline designed to optimize prompt performance before large-scale testing.

The three-phase evaluation pipeline: Template Designing, Best Template Selection, and Large-Scale Evaluation.

Prompt Engineering Strategies

The study explored several prompting strategies, including simple 0-shot instructions and few-shot examples. A key technical contribution is the Self-Heuristic Prompting method. Instead of providing the model with random examples, the researchers first asked ChatGPT to analyze a set of examples and "summarize the rules/expertise" required for the task. This AI-generated expertise was then integrated into the final prompt, significantly boosting performance on complex reasoning tasks.

Key Insights and Results

The Natural Advantage of LLMs

ChatGPT demonstrated a "natural" proficiency in text-heavy tasks. In Bug Report Summarization, even a simple 0-shot prompt allowed GPT-3.5 to achieve an F1 score of 34.33, outperforming the specialized state-of-the-art (SOTA) tool iTAPE (31.36).

The Power of Self-Heuristics

For complex reasoning, such as mapping a bug to a CVSS severity score, providing raw examples often confused the model. However, the self-heuristic approach led to a massive performance jump. While GPT-3.5 initially struggled, GPT-4 using self-heuristic prompts achieved results comparable to specialized tools like DiffCVSS.

Vulnerability Repair and Patch Assessment

GPT-4 showed remarkable capability in code-centric tasks:

  • Vulnerability Repair: It successfully fixed 10 out of 12 real-world vulnerabilities, surpassing previous LLM-based benchmarks.
  • Patch Correctness: GPT-4 outperformed the specialized tool Invalidator across all metrics, achieving an F1 score of 0.727 compared to 0.675.

Conservative Bias

When identifying security bugs, ChatGPT exhibited a "conservative" bias, often flagging fewer items as security-related. Performance in this area was improved by using expertise prompts that specifically guided the model to look for indicators like memory leaks or null pointer problems.

Discussion and Future Directions

Despite its potential, ChatGPT faces several hurdles in the security domain. The model occasionally misidentifies the root cause of bugs or generates syntactically correct but logically flawed patches. Furthermore, providing too much information (e.g., combining code with lengthy bug descriptions) can sometimes lead to hallucinations or a focus on irrelevant details.

Future research should move toward Automated Prompt Engineering (APE) and explore the fine-tuning of smaller, domain-specific models to overcome the generalist limitations of large-scale LLMs. Effectively guiding models to focus on helpful information while ignoring noise remains an open and critical problem in automated vulnerability management.

Summary updated

BibTeX
@inproceedings{liu2024how,
  author = {Peiyu Liu and Junming Liu and Lirong Fu and Kangjie Lu and Yifan Xia and Xuhong Zhang and Wenzhi Chen and Haiqin Weng and Shouling Ji and Wenhai Wang},
  title = {{How ChatGPT is Solving Vulnerability Management Problem}},
  booktitle = {USENIX Security},
  year = {2024},
  url = {https://openreview.net/forum?id=ObAqsGQ1xb},
}
Figure