关于基于LLM的漏洞检测你想知道却不敢问的一切
Everything You Wanted to Know About LLM-based Vulnerability Detection But Were Afraid to Ask
AI总结:
本文针对现有基于LLM的漏洞检测评估忽略上下文导致结果不可靠的问题,提出CORRECT评估框架,通过上下文丰富数据集评估13个LLMs,推翻了三个社区常见误解,揭示了模型性能提升的关键因素及新缺陷。
摘要:
大型语言模型(LLMs)凭借其在代码生成和修复方面的成功,成为自动化漏洞检测的有前景工具。然而,尽管被广泛采用,一个关键问题仍未解决:LLMs是否真能有效检测真实世界的漏洞?当前评估常针对孤立函数或文件评估模型,忽略了理解漏洞所必需的更广泛执行和数据流上下文。这一疏忽导致两种误导性结果:错误结论和有缺陷的理由,共同削弱了先前评估的可靠性。因此,本文挑战社区中三个广泛持有的信念:LLMs是(i)不可靠的,(ii)对代码补丁不敏感,以及(iii)跨模型规模性能已达平台期。我们认为这些信念是缺乏上下文评估的产物。为解决此问题,我们提出CORRECT(带信任的代码上下文丰富推理评估)——一个将上下文信息系统地融入基于LLM的漏洞检测的新评估框架。我们构建了包含2000个漏洞-补丁程序对(覆盖99个CWE)的上下文丰富数据集,并评估了4个模型家族的13个LLMs。我们的框架获取二元预测和自然语言理由,后者通过LLM-as-a-judge技术进一步验证。我们的发现推翻了现有误解:当提供足够上下文时,最先进的LLMs性能显著提升(例如,关键CWE上F1分数达0.7,精确率为0.8)。我们表明,大多数假阳性源于推理错误而非错误分类;虽然模型和测试时缩放能提升性能,但会引入收益递减和召回率权衡。最后,我们揭示了当前基于LLM的检测系统的新缺陷,如有限的泛化能力和过度思考偏差。
英文摘要:
Large Language Models are a promising tool for automated vulnerability detection, thanks to their success in code generation and repair. However, despite widespread adoption, a critical question remains: Are LLMs truly effective at detecting real-world vulnerabilities? Current evaluations, which often assess models on isolated functions or files, ignore the broader execution and data-flow context essential for understanding vulnerabilities. This oversight leads to two types of misleading outcomes: incorrect conclusions and flawed rationales, collectively undermining the reliability of prior assessments. Therefore, in this paper, we challenge three widely held community beliefs: that LLMs are (i) unreliable, (ii) insensitive to code patches, and (iii) performance-plateaued across model scales. We argue that these beliefs are artifacts of context-deprived evaluations. To address this, we propose CORRECT (Context-Rich Reasoning Evaluation of Code with Trust), a new evaluation framework that systematically incorporates contextual information into LLM-based vulnerability detection. We construct a context-rich dataset of 2,000 vulnerable-patched program pairs spanning 99 CWEs and evaluate 13 LLMs across four model families. Our framework elicits both binary predictions and natural-language rationales, which are further validated using LLM-as-a-judge techniques. Our findings overturn existing misconceptions. When provided with sufficient context, SOTA LLMs achieve significantly improved performance (e.g., 0.7 F1-score on key CWEs), with 0.8 precision. We show that most false positives stem from reasoning errors rather than misclassification, and that while model and test-time scaling improve performance, they introduce diminishing returns and trade-offs in recall. Finally, we uncover new flaws in current LLM-based detection systems, such as limited generalization and overthinking biases.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。