VISION: Robust and Interpretable Code Vulnerability Detection Leveraging Counterfactual Augmentation
Not on the map. Why?
Abstract (arXiv)
Automated detection of vulnerabilities in source code is an essential cybersecurity challenge, underpinning trust in digital systems and services. Graph Neural Networks (GNNs) have emerged as a promising approach as they can learn structural and logical code relationships in a data-driven manner. However, their performance is severely constrained by training data imbalances and label noise. GNNs often learn 'spurious' correlations from superficial code similarities, producing detectors that fail to generalize well to unseen real-world data. In this work, we propose a unified framework for robust and interpretable vulnerability detection, called VISION, to mitigate spurious correlations by systematically augmenting a counterfactual training dataset. Counterfactuals are samples with minimal semantic modifications but opposite labels. Our framework includes: (i) generating counterfactuals by prompting a Large Language Model (LLM); (ii) targeted GNN training on paired code examples with opposite labels; and (iii) graph-based interpretability to identify the crucial code statements relevant for vulnerability predictions while ignoring spurious ones. We find that VISION reduces spurious learning and enables more robust, generalizable detection, improving overall accuracy (from 51.8% to 97.8%), pairwise contrast accuracy (from 4.5% to 95.8%), and worst-group accuracy (from 0.7% to 85.5%) on the Common Weakness Enumeration (CWE)-20 vulnerability. We further demonstrate gains using proposed metrics: intra-class attribution variance, inter-class attribution distance, and node score dependency. We also release CWE-20-CFA, a benchmark of 27,556 functions (real and counterfactual) from the high-impact CWE-20 category. Finally, VISION advances transparent and trustworthy AI-based cybersecurity systems through interactive visualization for human-in-the-loop analysis.
Key facts. Cited by 3 papers in the map (data through 14 Oct 2026). Builds on 25 of its 42 references that are in the map. First posted on arXiv 26 Aug 2025.
Builds on
25 of 42 references.
References · 25
- 2017A Unified Approach to Interpreting Model Predictionscited by 6,555
- 2016"Why Should I Trust You?": Explaining the Predictions of Any Classifiercited by 5,070
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2017Counterfactual Explanations without Opening the Black Box: Automated Decisions and the GDPRcited by 1,089
- 2019GNNExplainer: Generating Explanations for Graph Neural Networkscited by 737
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
- 2019Learning the Difference that Makes a Difference with Counterfactually-Augmented Datacited by 439
- 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 272
- 2020PGM-Explainer: Probabilistic Graphical Model Explanations for Graph Neural Networkscited by 211
- 2021Simple data balancing achieves competitive worst-group-accuracycited by 178
- 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 139
- 2020Explaining NLP Models via Minimal Contrastive Editing (MiCE)cited by 106
13 more
- 2023DiverseVul: A New Vulnerable Source Code Dataset for Deep Learning Based Vulnerability Detectioncited by 102
- 2022Graph Rationalization with Environment-based Augmentationscited by 70
- 2021Vulnerability Detection with Fine-grained Interpretationscited by 56
- 2023Data Quality for Software Vulnerability Datasetscited by 51
- 2022Robust Counterfactual Explanations for Tree-Based Ensemblescited by 49
- 2023Robust Counterfactual Explanations for Neural Networks With Probabilistic Guaranteescited by 45
- 2024Navigating Shortcuts, Spurious Correlations, and Confounders: From Origins via Detection to Mitigationcited by 25
- 2021Security Vulnerability Detection Using Deep Learning Natural Language Processingcited by 12
- 2024Graph Neural Networks for Vulnerability Detection: A Counterfactual Explanationcited by 12
- 2021Solving the Class Imbalance Problem Using a Counterfactual Method for Data Augmentationcited by 8
- 2024Towards Formalizing Spuriousness of Biased Datasets Using Partial Information Decompositioncited by 6
- 2024Enhancing Code Vulnerability Detection via Vulnerability-Preserving Data Augmentationcited by 5
- 2024Data Quality Issues in Vulnerability Detection Datasetscited by 5
Built on by
Citing papers per year: 2025: 1; 2026: 2.
3 papers.