[论文解读] Prompt-Enhanced Software Vulnerability Detection Using ChatGPT
本研究考察了 ChatGPT 如何通过增强提示、辅助代码信息和链式推理提示来检测软件漏洞,在 Java 和 C/C++ 数据集上对两种基线进行评估。
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.
研究动机与目标
- 研究使用基本提示设计的 ChatGPT 漏洞检测能力。
- 评估辅助信息(如 API 调用序列和数据流)对检测性能的影响。
- 利用多轮对话和链式推理提示来提升结果。
- 在两种语言上将提示设计与基线 CFGNN 和 Bugram 进行比较评估。
- 分析使用 ChatGPT 进行漏洞检测的优点与局限性。
提出的方法
- 对 ChatGPT 应用一个基本的基于角色的提示进行漏洞检测。
- 将辅助信息(API 调用序列和数据流图)引入提示中以指导推理。
- 设计利用 ChatGPT 的多轮对话(链式思考)进行逐步推理的提示。
- 使用 AST 和数据流图从 Java 和 C/C++ 代码中提取 API 调用和数据流信息。
- 构建向 ChatGPT 提供 API 和 DF 描述作为额外上下文的提示。
- 在两个漏洞数据集上对不同的提示设计与基线进行评估。
实验结果
研究问题
- RQ1在没有辅助信息的情况下,ChatGPT 能否仅用基本提示检测软件漏洞?
- RQ2API 调用序列和数据流信息是否提高了 ChatGPT 的漏洞检测性能?
- RQ3链式思考提示是否提高漏洞检测的准确性?
- RQ4提示的顺序或组成是否会影响检测结果?
- RQ5ChatGPT 在不同漏洞类型和语言上的表现如何?
主要发现
- 提示设计在跨语言的 ChatGPT 漏洞检测性能上有显著影响。
- 诸如 API 序列和数据流描述等辅助信息在很多情况下可提高理解和检测。
- 链式推理提示通过实现多步推理为 ChatGPT 带来额外提升。
- 某些提示顺序和组合在精确率与召回率之间取得最佳平衡。
- ChatGPT 的性能因漏洞类型、语言和数据集特征而异,凸显了基于大型语言模型的漏洞检测的优点与局限性。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。