LLM漏洞检测看似有效,实则缺乏安全推理能力。
Calibration Without Comprehension: Diagnosing the Limits of Fine-Tuning LLMs for Vulnerability Detection in Systems Software

- 构建含834个内核样本的严格时间划分数据集,诊断模型是否真懂安全。
- 84%污染样本无记忆信号,31%存在类别标注错误,数据污染无效。
- 微调仅调整输出阈值,不改变判断逻辑,属‘校准而非理解’。
当前大型语言模型在漏洞检测基准上的高分,可能源于数据污染而非真实安全推理。本文提出CWE-Trace框架,基于834个手动标注的Linux内核样本(涵盖74类漏洞),采用严格的时间划分(2025年前历史集与切断后无泄漏集),保留上下文相关的漏洞-补丁对,并引入方向性失败指数(DFI)和层级距离与方向(HDD)两个诊断指标。评估了8个原始模型和15个LoRA微调变体在非目标检测、目标检测及CWE分类任务的表现。结果表明:数据污染未带来可测量优势;功能级分析显示84%的名义污染样本无可用记忆信号(漏洞函数缺失或跨数据集映射),约31%的污染样本存在CWE误标;模型表现出稳定且系统性的失败模式(DFI范围-85.5至+94.8个百分点),从历史到切断后数据均持续存在且难以修正。微调仅改变输出阈值,未改变决策策略,形成‘校准但无理解’现象。最弱基线模型(DeepSeek-R1)在粗粒度分类中提升最大,揭示检测与理解能力可解耦。最佳检测准确率仅为52.1%(较随机高出2.1个百分点),精确CWE排名Top-1准确率低于1.3%,证实当前大模型在系统软件安全推理方面仍不可靠,无论微调策略如何。
原文摘要 · Abstract (English)
Whether LLMs scoring well on vulnerability benchmarks genuinely reason about security or merely pattern-match on contaminated data remains unresolved. We present CWE-Trace, a framework for LLM vulnerability detection built from 834 manually curated Linux kernel samples spanning 74 CWEs. The framework enforces a strict temporal split (pre-2025 historical set / post-cutoff leakage-free set), preserves context-aware vulnerable--patched pairs, and introduces two diagnostic metrics: the Directional Failure Index (DFI) and Hierarchical Distance and Direction (HDD). We evaluate eight vanilla LLMs and 15 LoRA fine-tuned variants across non-targeted detection, targeted detection, and CWE classification. Our analysis yields two key results. First, data contamination provides no measurable advantage. Function-level analysis shows that 84% of nominally contaminated samples carry no usable memorization signal: vulnerable functions are absent or cross-mapped across datasets, and ~31% of contaminated samples carry CWE misclassification. Second, backbone directional priors dominate fine-tuning. Models exhibit stable, systematic failure modes (DFI ranging from -85.5 to +94.8 pp) that persist from historical to post-cutoff data and resist correction. Fine-tuning shifts the output threshold without changing the decision policy. This is calibration without comprehension: output distributions adapt to training data while the underlying security reasoning remains absent. The weakest backbone at binary detection (DeepSeek-R1) gains the most in coarse CWE classification, revealing that detection and understanding are decoupled capabilities. The best detection score reaches only 52.1% (+2.1 pp above chance); exact CWE ranking remains below 1.3% Top-1 accuracy, confirming that current LLMs lack reliable security reasoning for systems software, regardless of fine-tuning strategy.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。