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

Fine-Grained Source Code Vulnerability Detection via Graph Neural Networks (S)

Jingjing Wang, Minhuan Huang, Yuanping Nie, Xiaohui Kuang, Xiang Li, Wenjing ZhongSEKE 2023

Abstract

Current deep learning-based vulnerability detection methods often operate at a coarse function level, leaving security auditors with the daunting task of manually locating bugs within large codebases. This paper presents a novel Graph Neural Network (GNN) framework that leverages multidimensional Code Property Graphs (CPGs) and a custom Influence Score (IS) to provide fine-grained, line-level vulnerability localization. Evaluated on real-world C/C++ projects, the approach demonstrates significant improvements in precision and auditing efficiency.

Introduction

The rapid growth of software complexity has led to a surge in exploitable vulnerabilities. While automated detection using deep learning is a promising solution, existing models frequently treat code as a flat sequence of tokens, ignoring its inherent structural logic. Furthermore, most models only provide function-level alerts, which are insufficient for large-scale projects where a single function may contain hundreds of lines. To address these challenges, this research proposes a GNN-based model that understands program structure and pinpoints specific buggy lines.

Proposed Framework

The system architecture is divided into three specialized modules: Embedding, Location, and Classification.

The three-module architecture: Embedding, Location, and Classification modules work together to detect and locate vulnerabilities.
  1. Embedding Module: This module transforms source code into Code Property Graphs (CPGs), which integrate Abstract Syntax Trees (AST), Control Flow Graphs (CFG), and Data Flow Graphs (DFG). Nodes are encoded using a scheme that captures both structural attributes and semantic meaning.
  2. Location Module: Utilizing Graph Convolutional Networks (GCNs), this module aggregates neighborhood information and calculates an Influence Score (IS) for each node. These scores are used to identify and rank the nodes most likely to be associated with a vulnerability, which are then mapped back to source code line numbers.
  3. Classification Module: A BiLSTM serves as a readout function, capturing the sequential dependencies between the most influential nodes before a final Softmax layer predicts the function's vulnerability status.

Embedding and Feature Representation

To capture both structural attributes and semantic meaning, the model employs a multidimensional encoding scheme.

The node embedding process: Code normalization and token generation precede Word2Vec feature mapping to create comprehensive node vectors.

As shown in the embedding process, nodes are first normalized to remove project-specific naming conventions. Tokens are then generated and mapped to vectors using Word2Vec. The final node vector $V_{node}$ is a concatenation of attribute vectors (e.g., variable types, operators) and code semantic vectors ($V_{code}$).

Experimental Evaluation

The model was tested on a Hybrid Dataset (HD) of synthetic samples and a Real-project Dataset (RD) comprising over 17,000 programs from 13 major open-source projects like the Linux Kernel, FFmpeg, and OpenSSL.

Key Results

  • State-of-the-Art Accuracy: On the RD dataset, the model achieved a 17.0% gain in Precision and a 12.0% improvement in F1-score compared to existing methods like Devign and Vuldeepecker.
  • Auditing Efficiency: The line-level localization proved highly effective. By focusing on the top 50 lines flagged by the model's Influence Score, auditors could reduce their manual review workload by approximately 47.9% while still identifying the majority of vulnerabilities.
  • Robustness: The GNN-based approach significantly outperformed traditional static analysis tools like Cppcheck and Flawfinder, which struggled with the complexity of real-world code.

Conclusion

By moving beyond coarse-grained detection, this research provides a practical tool for security professionals. The integration of CPGs and the Influence Score allows the model to capture the "story" of a vulnerability, offering both high detection accuracy and interpretable localization. Future work will focus on extending support to additional programming languages and refining the localization parameters to adapt to different software weaknesses.

Summary updated

BibTeX
@inproceedings{wang2023fine,
  author = {Jingjing Wang and Minhuan Huang and Yuanping Nie and Xiaohui Kuang and Xiang Li and Wenjing Zhong},
  title = {{Fine-Grained Source Code Vulnerability Detection via Graph Neural Networks (S)}},
  booktitle = {SEKE},
  year = {2023},
  doi = {10.18293/seke2023-115},
}
Figure