Skip to main content
QUICK REVIEW

[论文解读] Chain-of-Thought Prompting of Large Language Models for Discovering and Fixing Software Vulnerabilities

Yu Nong, Mohammed Aldeen|arXiv (Cornell University)|Feb 27, 2024
Advanced Malware Detection TechniquesComputer Science被引用 9
一句话总结

本论文提出 Vulnerability-Semantics-guided Prompting (VSP),这是一种 chain-of-thought prompting 方法,使 LLMs 能够识别、发现并修补软件漏洞,在合成数据集和 CVE 数据集上的 F1 得分显著高于基线。

ABSTRACT

Security vulnerabilities are increasingly prevalent in modern software and they are widely consequential to our society. Various approaches to defending against these vulnerabilities have been proposed, among which those leveraging deep learning (DL) avoid major barriers with other techniques hence attracting more attention in recent years. However, DL-based approaches face critical challenges including the lack of sizable and quality-labeled task-specific datasets and their inability to generalize well to unseen, real-world scenarios. Lately, large language models (LLMs) have demonstrated impressive potential in various domains by overcoming those challenges, especially through chain-of-thought (CoT) prompting. In this paper, we explore how to leverage LLMs and CoT to address three key software vulnerability analysis tasks: identifying a given type of vulnerabilities, discovering vulnerabilities of any type, and patching detected vulnerabilities. We instantiate the general CoT methodology in the context of these tasks through VSP , our unified, vulnerability-semantics-guided prompting approach, and conduct extensive experiments assessing VSP versus five baselines for the three tasks against three LLMs and two datasets. Results show substantial superiority of our CoT-inspired prompting (553.3%, 36.5%, and 30.8% higher F1 accuracy for vulnerability identification, discovery, and patching, respectively, on CVE datasets) over the baselines. Through in-depth case studies analyzing VSP failures, we also reveal current gaps in LLM/CoT for challenging vulnerability cases, while proposing and validating respective improvements.

研究动机与目标

  • 用受限的任务特定数据,通过利用 LLM 和 CoT prompting 来促使进行漏洞分析。
  • 提出 VSP 将漏洞语义映射到链式推理,以实现聚焦分析。
  • 在三个任务上评估 VSP——识别、发现、和修补——在多种 LLM 和数据集上的表现。

提出的方法

  • 引入捕捉漏洞陈述及其上下文数据/控制流关系的 Vulnerability Semantics。
  • 以漏洞语义为中心,在 CoT 基础的少量示例提示(VSP)中作为统一策略。
  • 在 VSP 内提供针对识别(二元)、发现(多类)和修补(文本到文本)的特定任务提示方案。
  • 使用围绕 C/C++ 的五个 CWE 构建的示例,并在 SARD(合成)和 CVE(真实世界)数据集上使用 GPT-3.5、Llama2、Falcon 进行测试。
  • 将 VSP 与 Standard Prompting、Standard Few-shot、Naive CoT、Zero-Shot VSP 以及 Other-Type VSP 基线进行比较。
Figure 1: Illustrations of vulnerability semantics (a) and VSP exemplars for the three vulnerability analysis tasks (b,c,d).
Figure 1: Illustrations of vulnerability semantics (a) and VSP exemplars for the three vulnerability analysis tasks (b,c,d).

实验结果

研究问题

  • RQ1当由漏洞语义引导时,LLM 能否有效执行漏洞识别、发现和修补?
  • RQ2带有漏洞语义指导的 CoT 提示是否比标准提示和朴素 CoT 在多种 LLM 和数据集上提升性能?
  • RQ3这些提示在不同的漏洞类型(CWEs)和真实世界 CVE 数据中的迁移性如何?

主要发现

  • VSP 提示在各模型与数据集上的漏洞识别获得最佳 F1(例如,在 GPT-3.5 的 SARD 上为 65.29%)。
  • 在 CVE 数据上,VSP 在识别任务上对 GPT-3.5 达到 58.48% F1,显著优于标准提示。
  • 对于漏洞发现,VSP 在 CVE 上对 GPT-3.5 将宏平均 F1 提升至 36.34%,在 SARD 上为 55.83%(宏平均)。
  • 对于漏洞修补,VSP 在合成数据上达到 97.65% F1,在 CVE 上为 20.00%,优于基线。
  • VSP 使发现 22 个真正的零日 CVE 漏洞成为可能(40.00% 准确度),而基线为 9 个(16.36% 准确度)。
  • 故障分析指出上下文不足、CWE 遗忘、控制/数据流分析不完整,并提出有针对性的改进。
Figure 2: An overview of vulnerability-semantics-guided prompting for vulnerability analysis tasks.
Figure 2: An overview of vulnerability-semantics-guided prompting for vulnerability analysis tasks.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。