Mitigating fix reversal: Counterfactual constraints for function-level vulnerability detection
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. No citing papers in the map yet (data through 24 Nov 2026). Builds on 31 of its 50 references that are in the map. Submitted 18 Nov 2026, announced 19 Nov 2026.
Builds on
31 of 50 references.
References · 31
- 2020Shortcut Learning in Deep Neural Networkscited by 2,138
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,337
- 2019Distributionally Robust Neural Networks for Group Shifts: On the Importance of Regularization for Worst-Case Generalizationcited by 1,325
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 926
- 2019Learning the Difference that Makes a Difference with Counterfactually-Augmented Datacited by 478
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 371
- 2019Don't Take the Easy Way Out: Ensemble Based Methods for Avoiding Known Dataset Biasescited by 289
- 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 287
- 2018What is the Effect of Importance Weighting in Deep Learning?cited by 255
- 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 162
- 2020Deep Learning based Vulnerability Detection: Are We There Yet?cited by 152
- 2021Scaling Deep Contrastive Learning Batch Size under Memory Limited Setupcited by 140
19 more
- 2019Unlearn Dataset Bias in Natural Language Inference by Fitting the Residualcited by 121
- 2021Counterfactual Invariance to Spurious Correlations: Why and How to Pass Stress Testscited by 81
- 2024Vul-RAG: Enhancing LLM-based Vulnerability Detection via Knowledge-level RAGcited by 70
- 2021Vulnerability Detection with Fine-grained Interpretationscited by 57
- 2023Uncovering the Limits of Machine Learning for Automatic Vulnerability Detectioncited by 38
- 2021ReGVD: Revisiting Graph Neural Networks for Vulnerability Detectioncited by 33
- 2024Top Score on the Wrong Exam: On Benchmarking in Machine Learning for Vulnerability Detectioncited by 31
- 2024MegaVul: A C/C++ Vulnerability Dataset with Comprehensive Code Representationcited by 30
- 2024To Err is Machine: Vulnerability Detection Challenges LLM Reasoningcited by 25
- 2025SecVulEval: Benchmarking LLMs for Real-World C/C++ Vulnerability Detectioncited by 21
- 2023Distinguishing Look-Alike Innocent and Vulnerable Code by Subtle Semantic Representation Learning and Explanationcited by 12
- 2024Vul-LMGNNs: Fusing language models and online-distilled graph neural networks for code vulnerability detectioncited by 12
- 2023Towards Causal Deep Learning for Vulnerability Detectioncited by 10
- 2025FuncVul: An Effective Function Level Vulnerability Detection Model using LLM and Code Chunkcited by 5
- 2025VISION: Robust and Interpretable Code Vulnerability Detection Leveraging Counterfactual Augmentationcited by 5
- 2026A Function-Level Vulnerability Score Measures Flag Rate More Than the Model: Protocol Effects on Paired Benchmarkscited by 2
- 2024Game Rewards Vulnerabilities: Software Vulnerability Detection with Zero-Sum Game and Prototype Learningcited by 1
- 2025Weakly Supervised Vulnerability Localization via Multiple Instance Learningcited by 1
- 2026Focus on What Matters: Fisher-Guided Adaptive Multimodal Fusion for Vulnerability Detectioncited by 1
Built on by
Not cited yet.