LLM4Vuln: A Unified Evaluation Framework for Decoupling and Enhancing LLMs' Vulnerability Reasoning

📄 arXiv: 2401.16185v4 📥 PDF

作者: Yuqiang Sun, Daoyuan Wu, Yue Xue, Han Liu, Wei Ma, Lyuye Zhang, Yang Liu, Yingjiu Li

分类: cs.CR, cs.AI, cs.SE

发布日期: 2024-01-29 (更新: 2025-06-07)

备注: This is a technical report by Nanyang Technological University. Updated to support Solidity, Java and C/C++


💡 一句话要点

提出LLM4Vuln框架以解耦和增强LLMs的漏洞推理能力

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 漏洞检测 大型语言模型 评估框架 知识增强 上下文补充 编程语言 软件安全 零日漏洞

📋 核心要点

  1. 现有方法在使用LLMs进行漏洞检测时,缺乏对其漏洞推理能力来源的深入理解,导致评估不够全面。
  2. 本文提出LLM4Vuln框架,旨在解耦LLMs的漏洞推理能力与其他辅助能力,以便进行更准确的评估。
  3. 通过构建UniVul基准并测试六种LLMs,发现知识增强和上下文补充对漏洞推理能力的影响显著,识别出14个零日漏洞。

📝 摘要(中文)

大型语言模型(LLMs)在多种任务中展现出显著潜力,包括漏洞检测等需要人类水平智能的任务。然而,现有的使用LLMs进行漏洞检测的努力仍处于初步阶段,缺乏对LLMs漏洞推理能力来源的深入理解。本文旨在将LLMs的漏洞推理与其他能力(如漏洞知识采纳、上下文信息检索和高级提示方案)解耦。我们提出了LLM4Vuln,一个统一的评估框架,用于分离和评估LLMs的漏洞推理能力,并考察与其他增强结合时的改进。为支持这一评估,我们构建了UniVul,这是第一个提供可检索知识和上下文补充代码的基准,涵盖Solidity、Java和C/C++三种代表性编程语言。通过LLM4Vuln和UniVul,我们对六种代表性LLMs进行了测试,发现知识增强、上下文补充和提示方案的影响各异,并识别出四个试点漏洞赏金计划中的14个零日漏洞,获得了$3,576的赏金。

🔬 方法详解

问题定义:本文旨在解决现有LLMs在漏洞检测中对推理能力来源的模糊性,现有方法未能有效区分模型自身能力与外部辅助的影响。

核心思路:提出LLM4Vuln框架,通过解耦漏洞推理与其他能力,提供更清晰的评估标准,帮助研究人员理解LLMs的真实能力。

技术框架:LLM4Vuln框架包括多个模块:首先是漏洞推理能力的独立评估,其次是与知识检索、上下文补充和提示方案的结合评估,最后是综合分析结果。

关键创新:最重要的创新在于构建了UniVul基准,提供了可检索的知识和上下文补充代码,首次在三个编程语言中实现了这一功能,显著提升了评估的全面性和准确性。

关键设计:在实验中,采用了多种参数设置和损失函数,确保模型在不同场景下的鲁棒性,同时设计了针对不同编程语言的特定网络结构以优化性能。

🖼️ 关键图片

img_0

📊 实验亮点

实验结果显示,使用LLM4Vuln框架的LLMs在漏洞推理能力上表现出显著提升,尤其是在知识增强和上下文补充的情况下。通过对147个真实漏洞和147个非漏洞案例的测试,识别出14个零日漏洞,获得了$3,576的赏金,验证了该框架的有效性。

🎯 应用场景

该研究的潜在应用领域包括软件安全、漏洞检测和代码审计等。通过提供更准确的漏洞推理能力评估,LLM4Vuln框架可以帮助开发人员和安全研究人员更有效地识别和修复安全漏洞,从而提升软件的安全性和可靠性。

📄 摘要(原文)

Large language models (LLMs) have demonstrated significant potential in various tasks, including those requiring human-level intelligence, such as vulnerability detection. However, recent efforts to use LLMs for vulnerability detection remain preliminary, as they lack a deep understanding of whether a subject LLM's vulnerability reasoning capability stems from the model itself or from external aids such as knowledge retrieval and tooling support. In this paper, we aim to decouple LLMs' vulnerability reasoning from other capabilities, such as vulnerability knowledge adoption, context information retrieval, and advanced prompt schemes. We introduce LLM4Vuln, a unified evaluation framework that separates and assesses LLMs' vulnerability reasoning capabilities and examines improvements when combined with other enhancements. To support this evaluation, we construct UniVul, the first benchmark that provides retrievable knowledge and context-supplementable code across three representative programming languages: Solidity, Java, and C/C++. Using LLM4Vuln and UniVul, we test six representative LLMs (GPT-4.1, Phi-3, Llama-3, o4-mini, DeepSeek-R1, and QwQ-32B) for 147 ground-truth vulnerabilities and 147 non-vulnerable cases in 3,528 controlled scenarios. Our findings reveal the varying impacts of knowledge enhancement, context supplementation, and prompt schemes. We also identify 14 zero-day vulnerabilities in four pilot bug bounty programs, resulting in $3,576 in bounties.