arrow
Return

An Interpretable Vulnerability Detection Method Based on Graph and Code Slicing

delete2026-01-01
delete0
PRE
AI
G
Gao, Wenchao *
S
Suo, Jianhua
Z
Zhang, Ao
DOI:10.11999/JEIT250363delete
deleteOriginal
deleteShare
deleteSave
Abstract

Abstract

En 中文
Objective Deep learning technology is widely applied to source code vulnerability detection. Existing approaches are mainly sequence-based or graph-based. Sequence-based models convert structured code into linear sequences, which leads to the loss of syntactic and structural information and often results in a high false positive rate. Graph-based models capture structural features but cannot represent execution order, and their detection granularity is usually limited to the function level. Both types of methods lack interpretability, which restricts the ability of developers to locate vulnerability sources. Large Language Models (LLMs) show progress in code understanding; however, they still exhibit high computational cost, hallucination risk in security analysis, and insufficient modeling of complex program logic. To address these issues, an interpretable vulnerability detection method based on Graph and Slicing Vulnerability Detection (GSVD) is proposed. Structural semantics and sequential information are integrated, and fine-grained, line-level explanations are provided for prediction results. Methods The proposed method consists of four modules: code graph feature extraction, code sequence feature extraction, feature fusion, and an interpreter module ( Fig. 1). First, the source code is normalized, and the Joern static analysis tool is applied to generate multiple code graphs, including the Abstract Syntax Tree (AST), Data Dependency Graph (DDG), and Control Dependency Graph (CDG). These graphs represent program structure, data flow, and control flow, respectively. Node features are initialized using CodeBERT embeddings combined with one-hot encodings of node types. Based on the adjacency matrix of each graph, a Gated Graph Convolutional Network (GGCN) with a self-attention pooling layer is employed to extract deep structural semantic features. A code slicing algorithm based on taint analysis (Algorithm 1) is then designed. In this algorithm, taint sources are identified, and taints are propagated according to data and control dependencies to generate concise slices associated with potential vulnerabilities. Unrelated code is removed, and the resulting slices are processed using a Bidirectional Long Short-Term Memory (BiLSTM) network to capture long-range sequential dependencies. After graph and sequence features are extracted, a gating mechanism is applied for feature fusion. The fused feature vectors are further processed using a Gated Recurrent Unit (GRU), which learns dependencies between structural and sequential representations through dynamic state updates. To support vulnerability detection and localization, a Vulnerability Detection Explainer (VDExplainer) is designed. Inspired by the Hyperlink-Induced Topic Search (HITS) algorithm, node authority and hub scores are iteratively computed under an edge-mask constraint to estimate node importance and provide node-level interpretability. Results and Discussions The effectiveness of the GSVD model is evaluated through comparative experiments on the Devign dataset (FFmpeg + Qemu), as shown in (Table 2). GSVD is compared with several baseline models and achieves the highest accuracy and F1-score, reaching 64.57% and 61.89%, respectively. Recall increases to 62.63%, indicating improved vulnerability detection capability and reduced missed reports. To evaluate the GRU-based fusion module, three fusion strategies are compared: feature concatenation, weighted sum, and attention mechanism (Table 3). GSVD achieves the best overall performance. Although its precision (61. 17%) is slightly lower than that of the weighted sum method (63.33%), accuracy, recall, and F1-score exhibit more balanced performance. Ablation studies (Tables 4'5) further demonstrate the contribution of the slicing algorithm. The taint propagation-based slicing method reduces the average number of code lines from 51.98 to 17.30, corresponding to a reduction of 66.72%, and lowers the data redundancy rate to 6.42%. In comparison, VulDeePecker and SySeVR report redundancy rates of 19.58% and 22.10%, respectively. This reduction in noise yields a 1.53% improvement in F1-score, confirming that the slicing module enhances focus on critical code segments. The interpretability of GSVD is validated on the Big-Vul dataset using the VDExplainer module (Table 6). Compared with the standard Graph Neural Network Explainer (GNNExplainer), higher localization accuracy is achieved at all evaluation thresholds. When 50% of the nodes are selected, localization accuracy increases by 7.65%, demonstrating the advantage of VDExplainer in node-level vulnerability explanation. Conclusions The GSVD model overcomes the limitations of single-modal methods by integrating graph structures with taint-based code slicing. Both detection accuracy and interpretability are improved. The VDExplainer enables node-level and line-level localization, enhancing practical applicability. Experimental results confirm the advantages of the proposed method in vulnerability detection and explanation.
Keywords:
Vulnerability detection
Deep learning
Graph neural network
Code slicing
Interpretability
Combining Graph-Based Learning With Automated Data Collection for Code Vulnerability Detection
err2021-01-01
err166
errOAAI
errWang, Huanting; Ye, Guixin; Tang, Zhanyong; Tan, Shin Hwei; Huang, Songfang; Fang, Dingyi; Feng, Yansong; Bian, Lizhong; Wang, Zheng
errShare
errSave
Vulnerability Detection via Multiple-Graph-Based Code Representation
err2024-08-01
err1
PREAI
errQiu, Fangcheng; Liu, Zhongxin; Hu, Xing; Xia, Xin; Chen, Gang; Wang, Xinyu
errShare
errSave
Code Aggregate Graph: Effective Representation for Graph Neural Networks to Detect Vulnerable Code
err2022-01-01
err4
errOAAI
errNguyen, Hoang Viet; Zheng, Junjun; Inomata, Atsuo; Uehara, Tetsutaro
errShare
errSave
errShare
errSave

Journal

J
journal of electronics & information technology
IF:
0
Papers:
203
Citations:
3

Organization

China University of Mining & Technology cover
China University of Mining & Technology
Scholars:
4.1K
Papers: 1.4K
Citations: 483
Cited Papers

Cited Papers

No cited papers available