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

Sequential Graph Neural Networks for Source Code Vulnerability Identification

Ammar Ahmed, Anwar Said, Mudassir Shabbir, Xenofon D. KoutsoukosarXiv 2023 · DOI

Abstract

As open-source software becomes increasingly prevalent, the automated identification of security vulnerabilities has become a critical challenge. Traditional static and dynamic analysis tools often struggle with high false-positive rates and manual overhead. This paper introduces SEGNN (SEquential Graph Neural Network), a novel architecture that treats source code as a "sequential graph" to capture both logical flow and operational order. Alongside the model, the authors present CVEFGE, a high-quality dataset of C/C++ vulnerabilities curated from the CVE database. SEGNN achieves state-of-the-art results, outperforming existing benchmarks by up to 20% in identifying vulnerable functions.

Introduction

The complexity of modern software makes manual security auditing nearly impossible at scale. While Machine Learning (ML) offers a path toward automated vulnerability detection, it faces two primary hurdles: the scarcity of high-quality, structurally rich datasets and the difficulty of modeling the inherent complexity of source code. Source code is not merely a sequence of tokens; it possesses a nested, structural logic that standard models often fail to capture. The authors address these issues by proposing a framework that leverages Control Flow Graphs (CFGs) and a specialized neural architecture designed for graph-structured data with sequential dependencies.

The SEGNN Framework

The SEGNN architecture processes code through a multi-stage pipeline designed to preserve semantic and structural information.

The complete SEGNN architecture, featuring Gated Graph Recurrent Layers and Graph Attention (GAT) layers.

1. Embedding and Graph Construction

Code functions are first transformed into Control Flow Graphs (CFGs). In this representation, nodes correspond to basic blocks of code, and edges represent the flow of execution. To convert these blocks into numerical vectors, the source code is tokenized and processed using Word2Vec, creating rich node embeddings that serve as the initial state for the network.

2. Sequential Learning with GGRN

The core innovation of SEGNN is the Gated Graph Recurrent Network (GGRN). Standard Graph Neural Networks (GNNs) typically treat a node's neighbors as an unordered set. However, in programming, the order of operations is vital. GGRNs utilize Gated Recurrent Units (GRUs) to propagate information across the graph in a way that respects the sequential nature of code execution, allowing the model to learn the "story" of the function's logic.

3. Graph Attention and Classification

Following the sequential module, the model employs three layers of Graph Attention Networks (GAT). These layers allow the model to dynamically weigh the importance of different neighboring nodes, helping it focus on subtle code patterns—such as a missing bounds check or an uninitialized pointer—that often signal a vulnerability. Finally, a global max-pooling layer and a fully connected layer classify the function as either vulnerable or non-vulnerable.

The CVEFGE Dataset

A significant contribution of this work is the CVEFunctionGraphEmbeddings (CVEFGE) dataset. The authors crawled the CVE database from 2002 to 2021, extracting real-world vulnerable C/C++ functions and their corresponding CFGs. This dataset contains over 32,000 instances, providing a more robust and authentic training ground than previous synthetic or poorly labeled datasets.

Distribution of vulnerability types (e.g., DoS, Overflow) across the projects analyzed in the CVEFGE dataset.

Key Results and Insights

Experimental evaluations compared SEGNN against several baselines, including GraphSAGE and GAT. SEGNN achieved a peak accuracy of 79.47% on the CVEFGE dataset. A critical finding was the impact of data quality: even baseline models saw performance jumps of nearly 20% when switched from older datasets like Big-Vul to the new CVEFGE dataset. This suggests that the primary bottleneck in the field has been the lack of well-curated, real-world structural data.

Furthermore, the integration of recurrent components proved essential. By capturing the sequence of operations within the graph structure, SEGNN demonstrated a superior ability to generalize across different types of vulnerabilities compared to models that treat code structure as a static, unordered graph.

Conclusion and Future Work

SEGNN represents a significant step forward in fine-grained vulnerability identification. By focusing on function-level granularity, the model provides actionable insights for developers. While currently limited to C/C++, future work aims to expand the framework to other languages like Python and Java, and to explore more complex graph representations such as Program Dependence Graphs (PDG) to further deepen the model's semantic understanding.

Summary updated

BibTeX
@misc{ahmed2023sequential,
  author = {Ammar Ahmed and Anwar Said and Mudassir Shabbir and Xenofon D. Koutsoukos},
  title = {{Sequential Graph Neural Networks for Source Code Vulnerability Identification}},
  year = {2023},
  eprint = {2306.05375},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.05375},
}
Figure