IEEE Transactions on Software Engineering

Vulnerability Detection via Multiple-Graph-Based Code Representation

Aug. 2024, pp. 2178-2199, vol. 50

DOI Bookmark: 10.1109/TSE.2024.3427815

Authors

Fangcheng Qiu, State Key Laboratory of Blockchain and Data Security, Zhejiang University, Hangzhou, Zhejiang, China
Zhongxin Liu, State Key Laboratory of Blockchain and Data Security, Zhejiang University, Hangzhou, Zhejiang, China
Xing Hu, School of Software Technology, Zhejiang University, Ningbo, Zhejiang, China
Xin Xia, Software Engineering Application Technology Lab, Huawei, Hangzhou, Zhejiang, China
Gang Chen, College of Computer Science and Technology, Zhejiang University, Hangzhou, Zhejiang, China
Xinyu Wang, College of Computer Science and Technology, Zhejiang University, Hangzhou, Zhejiang, China

Keywords

Semantics, Codes, Source Coding, Graph Neural Networks, Software, Feature Extraction, Deep Learning, Vulnerability Detection, Deep Learning, Code Representation, Graph Neural Network, Code Representation, Vulnerability Detection, Neural Network, Deep Learning, Convolutional Neural Network, Graphical Representation, Source Code, Input Function, Feature Matrix, Semantic Features, Representation Of Function, Graph Neural Networks, Fine Grained Information, Multiple Graphs, Vulnerability Functions, Training Set, Structural Information, Validation Set, Convolutional Layers, Semantic Information, Graph Abstraction, Graph Attention Network, Control Flow Graph, Convolutional Neural Network Model, Graph Convolutional Network, Raw Text, Functional Graph, Static Analysis, Matthews Correlation Coefficient, Conv Layer

Abstract

During software development and maintenance, vulnerability detection is an essential part of software quality assurance. Even though many program-analysis-based and machine-learning-based approaches have been proposed to automatically detect vulnerabilities, they rely on explicit rules or patterns defined by security experts and suffer from either high false positives or high false negatives. Recently, an increasing number of studies leverage deep learning techniques, especially Graph Neural Network (GNN), to detect vulnerabilities. These approaches leverage program analysis to represent the program semantics as graphs and perform graph analysis to detect vulnerabilities. However, they suffer from two main problems: (i) Existing GNN-based techniques do not effectively learn the structural and semantic features from source code for vulnerability detection. (ii) These approaches tend to ignore fine-grained information in source code. To tackle these problems, in this paper, we propose a novel vulnerability detection approach, named MGVD (Multiple-Graph-Based Vulnerability Detection), to detect vulnerable functions. To effectively learn the structural and semantic features from source code, MGVD uses three different ways to represent each function into multiple forms, i.e., two statement graphs and a sequence of tokens. Then we encode such representations to a three-channel feature matrix. The feature matrix contains the structural feature and the semantic feature of the function. And we add a weight allocation layer to distribute the weights between structural and semantic features. To overcome the second problem, MGVD constructs each graph representation of the input function using multiple different graphs instead of a single graph. Each graph focuses on one statement in the function and its nodes denote the related statements and their fine-grained code elements. Finally, MGVD leverages CNN to identify whether this function is vulnerable based on such feature matrix. We conduct experiments on 3 vulnerability datasets with a total of 30,341 vulnerable functions and 127,931 non-vulnerable functions. The experimental results show that our method outperforms the state-of-the-art by 9.68% – 10.28% in terms of F1-score.

References

  1. CVE-2021-40524

Similar Articles