arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2611.06583cs.SE
收藏

PatchCon:面向漏洞检测的感知补丁加权监督对比学习

PatchCon: Patch-aware Weighted Supervised Contrastive Learning for Vulnerability Detection

KU Leuven(荷语鲁汶大学)

Chaomeng Lu, Pooya Rostami Mazrae, Bert Lagaisse

AI总结:

提出基于CodeBERT的PatchCon模型,联合优化漏洞分类与对比学习,在PairVul-Linux等数据集上提升漏洞检测性能,成本低于GPT-4o方法。

摘要:

自动化漏洞检测对保障现代软件系统安全至关重要,但现有基于学习的方法常将函数视为独立样本,且未充分利用漏洞修复补丁提供的监督信息。本文提出PatchCon,一种基于CodeBERT的感知补丁对比学习模型,用于函数级漏洞检测。PatchCon联合优化漏洞分类与监督对比学习,将带漏洞的函数-补丁对视为难负样本并赋予更大对比权重,以捕捉修复引入的与安全相关的细微差异。为评估补丁级区分能力,采用两个成对指标衡量模型能否正确区分漏洞函数与其修复后的对应函数。通过大量实验在PairVul-Linux上评估PatchCon,包括与当前最优方法的对比、 ablation研究、超参数敏感性分析及统计显著性检验;还按通用弱点枚举(CWE)类型、函数长度、补丁大小进行细粒度分析,并在训练数据截止后披露的Linux内核漏洞上进一步评估PatchCon。在PairVul-Linux上,PatchCon在分类和成对指标上均优于代表性预训练代码模型及对比学习基线,将成对准确率从最强复现基线的0.2060提升至0.3264,且成对准确率与基于GPT-4o的大语言模型(LLM)方法相当,成本却低得多。在复现模型中,PatchCon在训练期间未见过的通用漏洞披露(CVE)条目的测试对及新披露漏洞上也取得最高成对准确率。

英文摘要:

Automated vulnerability detection is critical for securing modern software systems, yet existing learning-based approaches often treat functions as independent samples and underuse the supervision provided by vulnerability-fixing patches. In this paper, we propose PatchCon, a CodeBERT-based patch-aware contrastive learning model for function-level vulnerability detection. PatchCon jointly optimizes vulnerability classification and supervised contrastive learning, and treats vulnerable-patched function pairs as hard negatives with larger contrastive weights to capture subtle security-relevant differences introduced by fixes. To evaluate patch-level discrimination, we use two pairwise metrics that measure whether a model can correctly distinguish vulnerable functions from their patched counterparts. We evaluate PatchCon on PairVul-Linux through extensive experiments, including state-of-the-art comparisons, ablation studies, hyperparameter sensitivity analysis, and statistical significance testing. We also conduct fine-grained analyses by Common Weakness Enumeration (CWE) type, function length, and patch size, and further evaluate PatchCon on Linux kernel vulnerabilities disclosed after the training data cutoff. On PairVul-Linux, PatchCon outperforms representative pretrained code models and contrastive learning baselines on both classification and pairwise metrics, improves pairwise accuracy over the strongest reproduced baseline from 0.2060 to 0.3264, and achieves pairwise accuracy comparable to that of a GPT-4o-based large language model (LLM) method at a substantially lower cost. Among the reproduced models, PatchCon also achieves the highest pairwise accuracy on test pairs from Common Vulnerabilities and Exposures (CVE) entries unseen during training and on newly disclosed vulnerabilities.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑