一句话:提出 CFExplainer,用反事实解释 GNN 漏洞检测,通过最小图扰动揭示漏洞根因。
漏洞检测对软件系统安全与可靠性至关重要,图神经网络(GNN)因能捕捉源代码语义结构而成为主流代码嵌入方法,但其黑箱特性导致可解释性不足。已有基于事实推理的解释器只能分析促成预测的关键特征,无法回答“若将代码图改为其他结构,GNN 决策会如何变化”这类反事实问题。为此,本文提出 CFExplainer,一种面向 GNN 漏洞检测的反事实解释器。它寻找对输入代码图的最小扰动,使模型预测发生改变,并将该扰动作为反事实解释,从而定位检测到的漏洞的根本原因,为开发者修复漏洞提供有价值的信息。在四个基于 GNN 的漏洞检测模型上进行的大量实验表明,CFExplainer 优于现有最先进的事实推理型解释器。
Vulnerability detection is crucial for ensuring the security and reliability of software systems. Recently, Graph Neural Networks (GNNs) have emerged as a prominent code embedding approach for vulnerability detection, owing to their ability to capture the underlying semantic structure of source code. However, GNNs face significant challenges in explainability due to their inherently black-box nature. To this end, several factual reasoning-based explainers have been proposed. These explainers provide explanations for the predictions made by GNNs by analyzing the key features that contribute to the outcomes. We argue that these factual reasoning-based explanations cannot answer critical what-if questions: "What would happen to the GNN's decision if we were to alter the code graph into alternative structures?" Inspired by advancements of counterfactual reasoning in artificial intelligence, we propose CFExplainer, a novel counterfactual explainer for GNN-based vulnerability detection. Unlike factual reasoning-based explainers, CFExplainer seeks the minimal perturbation to the input code graph that leads to a change in the prediction, thereby addressing the what-if questions for vulnerability detection. We term this perturbation a counterfactual explanation, which can pinpoint the root causes of the detected vulnerability and furnish valuable insights for developers to undertake appropriate actions for fixing the vulnerability. Extensive experiments on four GNN-based vulnerability detection models demonstrate the effectiveness of CFExplainer over existing state-of-the-art factual reasoning-based explainers.
@inproceedings{paperbot8481,
title = {Graph Neural Networks for Vulnerability Detection: A Counterfactual Explanation},
author = {Zhaoyang Chu and Yao Wan and Qian Li and Yang Wu and Hongyu Zhang and Yulei Sui and Guandong Xu and Hai Jin},
booktitle = {ISSTA},
year = {2024},
doi = {10.1145/3650212.3652136}
}