NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Coca: Improving and Explaining Graph Neural Network-Based Vulnerability Detection Systems

Sicong Cao, Xiaobing Sun, Xiaoxue Wu, David Lo, Lili Bo, Bin Li, Wei Liu · DOI

Introduction

Graph Neural Networks (GNNs) have become a standard approach for automated vulnerability detection due to their ability to capture the structural logic of code, such as data flow and control paths. However, these models often suffer from two critical limitations: a lack of robustness and poor explainability. GNN-based detectors can be fragile, with predictions flipping due to minor, non-semantic changes like variable renaming. Furthermore, when a vulnerability is detected, the models often fail to provide concise, human-readable explanations, leading to a "trust gap" between the tool and the developer.

The Coca Framework

The Coca framework addresses these issues through a two-stage approach comprising a Trainer (Coca_Tra) for robustness enhancement and an Explainer (Coca_Exp) for explainable detection. By decoupling these concerns, Coca ensures that explanations are derived from a model that is already resilient to syntactic noise.

The Coca framework integrates robustness enhancement and explainable detection into a unified workflow.

Robustness via Combinatorial Contrastive Learning

The Trainer component utilizes Combinatorial Contrastive Learning to force the model to focus on security-critical structural semantics rather than superficial syntax. This is achieved through two main steps:

  1. Data Augmentation: Six semantic-preserving transformations are applied to the code, such as renaming variables or swapping loop types (e.g., for to while).
  2. Contrastive Loss: The model is trained to recognize that these variants are functionally identical. By maximizing similarity between augmented versions of the same program and minimizing it between different programs, the model learns a more robust representation in the latent space.

Explainability via Dual-View Causal Inference

Once a robust model is established, the Explainer uses Dual-View Causal Inference to generate explanations. This method balances two perspectives:

  • Factual View: Identifies the subset of code sufficient to trigger a "vulnerable" label, ensuring high recall of the vulnerability context.
  • Counterfactual View: Determines the minimal set of statements whose removal would change the model's prediction, ensuring conciseness and precision.

Evaluation and Results

The authors evaluated Coca using a comprehensive benchmark of 335,671 C/C++ functions merged from five major datasets (Devign, ReVeal, Big-Vul, CrossVul, and CVEFixes).

Detection Performance

Integrating Coca's training methodology improved the F1-scores of state-of-the-art detectors like DeepWuKong and ReVeal by 10.26% to 18.43%. Visual analysis via t-SNE plots demonstrates that Coca-enhanced models achieve much clearer separation of features in the latent space compared to default models.

t-SNE visualizations of DeepWuKong (Default) vs. DeepWuKong (Coca_Tra), illustrating the improved feature clustering and robustness provided by the Coca framework.

Explanation Quality

In terms of explainability, Coca significantly outperformed baselines. Using the D2A dataset for ground truth, Coca improved Mean Statement Precision (MSP) by 21.91% and Mean Intersection over Union (MIoU) by 23.92%. A user study further validated these results, with 86% of security experts finding the explanations helpful for understanding the underlying vulnerabilities.

Conclusion

Coca successfully bridges the gap between high-performance detection and practical utility. By combining combinatorial contrastive learning with dual-view causal inference, it provides a framework that is both robust against adversarial syntactic changes and capable of producing precise, human-interpretable explanations.

Summary updated

BibTeX
@inproceedings{cao2024coca,
  author = {Sicong Cao and Xiaobing Sun and Xiaoxue Wu and David Lo and Lili Bo and Bin Li and Wei Liu},
  title = {{Coca: Improving and Explaining Graph Neural Network-Based Vulnerability Detection Systems}},
  booktitle = {ICSE},
  year = {2024},
  url = {https://openreview.net/forum?id=t6wyMU7mh7},
}
Figure