CFVul:用反事实约束缓解函数级漏洞检测中的修复逆转问题
Mitigating fix reversal: Counterfactual constraints for function-level vulnerability detection
AI 导读
研究者提出 CFVul,针对函数级漏洞检测中的修复逆转问题——即修复版本被赋予高于漏洞版本的漏洞概率。实验表明该现象主要源于长度捷径,漏洞概率随函数长度增加而上升。在 PrimeVul 数据集上,CFVul 的 PairRank 达 59.4%;对函数长度增加超 15% 的修复,PairRank 从 CodeBERT 的 25.8% 升至 48.4%,且仅需现有修复对即可应用于多种预训练代码模型。
正文 · 原文
Abstract:Function-level vulnerability detectors often exhibit fix reversal, assigning a higher vulnerability probability to a fixed version than to its vulnerable counterpart. Fixes usually lengthen functions, and larger length increases are associated with more severe reversal. Code-transformation experiments indicate that fix reversal mainly stems from a length shortcut: vulnerability probability increases with function length when content is fixed. We propose CFVul to address this problem. Sliding-window encoding covers complete functions, retaining fix information beyond the truncation boundary. During training, a content constraint encourages the vulnerable version to receive a higher vulnerability probability under a common length input. During inference, a length constraint averages vulnerability probabilities over fixed reference lengths, reducing the influence of actual length changes. On PrimeVul, CFVul achieves a fix-pair ranking metric, PairRank, of 59.4\%, exceeding the existing methods compared. For fixes that increase function length by more than 15\%, PairRank rises from CodeBERT's 25.8\% to 48.4\%. PairRank also improves in experiments with four additional models and three additional datasets. By weakening the length shortcut, CFVul reduces cases in which fixed versions receive higher vulnerability probabilities than vulnerable versions. It requires only existing fix pairs and applies to multiple pretrained code models, facilitating adoption in existing detectors.
| Comments: | 21 pages, 9 figures |
| Subjects: | Cryptography and Security (cs.CR); Artificial Intelligence (cs.AI); Software Engineering (cs.SE) |
| Cite as: | arXiv:2611.24489 [cs.CR] |
| (or arXiv:2611.24489v1 [cs.CR] for this version) | |
| https://doi.org/10.48550/arXiv.2611.24489 arXiv-issued DOI via DataCite (pending registration) |
Submission history
From: Shihao Li [view email]
[v1]
Wed, 18 Nov 2026 14:21:12 UTC (757 KB)
来源:arXiv cs.AI · arxiv.org