[论文解读] LLM4Vuln: A Unified Evaluation Framework for Decoupling and Enhancing LLMs' Vulnerability Reasoning
该论文提出了 LLM4Vuln,一个模块化框架,将LLM漏洞推理与知识检索、上下文增强、提示设计解耦;以及 UniVul,一个用于评估六个LLMs在3,528个受控情景中的147个真实漏洞和147个非漏洞案例的多语言漏洞知识基准。
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.
研究动机与目标
- 将LLM漏洞推理与外部辅助(知识获取、上下文、提示)解耦,以便理解内在能力。
- 提供统一、可检索的漏洞知识库和可上下文补充的代码用于标准化评估。
- 量化知识、上下文和提示对不同语言和模型的漏洞检测的影响程度。
- 通过一个试点的赏金计划研究展示实际应用价值,以验证现实世界的实用性。
提出的方法
- 将漏洞检测任务形式化为函数 R = fL(T, K, C, P, I),以将模型能力与增强分离。
- 引入四个可插拔组件(知识检索、上下文补充、提示方案、指令遵循),用于受控评估和增强。
- 构建 UniVul,这是一套在 Solidity、Java、C/C++ 中具有可检索的漏洞知识和可上下文补充的代码的基准,包括知识集和测试集。
- 使用向量数据库(FAISS)和摘要来实现知识检索和基于摘要的漏洞信息匹配。
- 采用 GPT-4.1 辅助的标注流程来产生标准化评估指标(TP、TN、FP、FN、FPt)并计算精确度/召回率。
- 在 3 种语言和 3,528 个情景中评估六个 LLMs(GPT-4.1、Phi-3、Llama-3、o4-mini、DeepSeek-R1、QwQ-32B)。
实验结果
研究问题
- RQ1LLM 漏洞推理在多大程度上来自模型本身 vs 外部辅助?
- RQ2知识增强、上下文补充和提示方案优化对漏洞推理的边际效用有多大?
- RQ3传统基础模型在利用外部增强进行漏洞检测方面与深度推理模型相比有何差异?
- RQ4LLM4Vuln 是否能在多语言和多类型模型之间可靠地评估漏洞推理?
- RQ5该框架在识别零日漏洞方面的现实世界适用性如何?
主要发现
- 知识增强在不同语言上产生异质性影响;对 Solidity 有显著提升,但对 Java 和 C/C++ 的传统模型影响有限甚至负面。
- 上下文补充效果不一致;传统模型受益于上下文,而深度推理模型有时在没有上下文时表现更好。
- 链路推理(CoT)提示提高了精确度并减少了误报,深度推理模型在 CoT 提示下表现更稳定。
- 传统基础模型更受外部增强的裨益,而深度推理模型在开箱即用的漏洞推理方面表现更强。
- 使用最佳配置进行的试点赏金研究识别出14个真实漏洞,奖金总额为3,576美元,验证了实用性。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。