ANVIL:无需标记训练数据的基于异常的漏洞识别
ANVIL: Anomaly-based Vulnerability Identification without Labelled Training Data
AI总结:
本文提出ANVIL,通过将漏洞检测转化为异常检测,利用大语言模型对代码进行掩码重建,结合多种指标提升检测性能,在PrimeVul数据集上优于现有监督检测器。
摘要:
基于监督学习的漏洞检测器常因标注数据有限而表现不佳。相比之下,大语言模型(LLMs)在大量未标注代码库上训练,但直接提示检测漏洞时仅略优于猜拳。本文将漏洞检测重新定义为异常检测,基于漏洞代码稀有且相对于LLM学习的模式为异常的假设。我们引入ANVIL,执行掩码代码重建任务:LLM重建被掩码的代码行,与原始代码的偏差被评分作为异常。我们提出一种混合异常评分,结合精确匹配、交叉熵损失、预测置信度和结构复杂性。我们在多个LLM家族、评分方法和上下文大小上评估我们的方法,并在LLM训练截止后检测漏洞。在PrimeVul数据集上,ANVIL优于LineVul、LineVD和LLMAO等现有监督检测器,达到最高Top-3准确率的2倍,Normalized MFR提高75%,ROC-AUC显著提升。最后,通过将ANVIL与模糊器结合,我们发现两个此前未知的漏洞,证明了异常引导检测的实用性。
英文摘要:
Supervised-learning-based vulnerability detectors often fall short due to limited labelled training data. In contrast, Large Language Models (LLMs) are trained on vast unlabelled code corpora, yet perform only marginally better than coin flips when directly prompted to detect vulnerabilities. In this paper, we reframe vulnerability detection as anomaly detection, based on the premise that vulnerable code is rare and thus anomalous relative to patterns learned by LLMs. We introduce ANVIL, which performs a masked code reconstruction task: The LLM reconstructs a masked line of code, and deviations from the original are scored as anomalies. We propose a hybrid anomaly score that combines exact match, cross-entropy loss, prediction confidence, and structural complexity. We evaluate our approach across multiple LLM families, scoring methods, and context sizes, and against vulnerabilities after the LLM's training cut-off. On the PrimeVul dataset, ANVIL outperforms state-of-the-art supervised detectors - LineVul, LineVD, and LLMAO - achieving up to 2x higher Top-3 accuracy, 75% better Normalized MFR, and a significant improvement on ROC-AUC. Finally, by integrating ANVIL with fuzzers, we uncover two previously unknown vulnerabilities, demonstrating the practical utility of anomaly-guided detection.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。