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

LineVD: Statement-level Vulnerability Detection using Graph Neural Networks

David Hin, Andrey Kan, Huaming Chen, Muhammad Ali Babar · DOI

Introduction

Automated software vulnerability detection (SVD) is a critical component of modern DevSecOps. However, most existing tools operate at the function level, flagging entire blocks of code as potentially dangerous. For developers working on large-scale projects, identifying the specific line responsible for a vulnerability within a multi-hundred-line function remains a manual, time-consuming task. LineVD addresses this gap by providing a deep learning framework designed for statement-level detection.

The Challenge of Granularity

The primary obstacle in moving from function-level to statement-level detection is the loss of context. A single line of code, such as an assignment or a function call, might appear benign in isolation. Its vulnerability often depends on the data flowing into it or the control logic surrounding it. Previous attempts to localize bugs using "Explainable AI" (XAI) techniques like GNNExplainer have proven noisy and often fail to provide the precision required for practical debugging.

Methodology: The LineVD Framework

LineVD treats statement-level detection as a node classification task on a graph. The framework consists of three main stages: feature extraction, graph construction, and learning.

Architecture of LineVD
  1. Feature Extraction: The model utilizes CodeBERT, a transformer-based model pretrained on a massive corpus of code, to generate high-dimensional embeddings for each statement. This captures the semantic meaning of the code tokens.
  2. Graph Construction: A Program Dependence Graph (PDG) is built where each statement is a node. Edges represent data dependencies (variable usage) and control dependencies (execution flow).
  3. Graph Neural Network (GNN): LineVD employs a Graph Attention Network (GAT). This allows the model to dynamically weigh the importance of neighboring statements, effectively learning which parts of the program context are most relevant to a specific line's security status.
  4. Joint Learning: To ensure consistency, the model is trained to predict both statement-level and function-level vulnerabilities simultaneously. An element-wise multiplication layer ensures that if a function is deemed safe, its constituent lines are also marked safe, significantly reducing false positives.

Experimental Results

The researchers evaluated LineVD using the Big-Vul dataset, which contains approximately 187,000 functions from over 300 C/C++ projects. The results demonstrate a significant advancement over previous state-of-the-art methods like IVDetect.

Performance Comparison of LineVD vs IVDetect

LineVD achieved an F1-score of 0.360, representing a 105% improvement over IVDetect. Furthermore, in the "N5" metric—which measures whether a vulnerable line appears in the top five predictions—LineVD reached a score of 0.900. This suggests that in 90% of cases, the actual bug is within the model's top five most suspicious lines.

Key Insights

  • Hierarchical Synergy: Combining statement and function-level predictions resulted in a 140% performance boost compared to statement-only models.
  • The Power of Pretraining: CodeBERT significantly outperformed traditional embeddings like GloVe or Doc2Vec, providing a richer semantic foundation for the GNN.
  • Operational Efficiency: Unlike interpretation-based models that require heavy post-processing, LineVD's direct prediction approach allows for sub-second inference times.

Limitations and Future Directions

While LineVD shows great promise, it currently struggles with "semantic-light" statements like break or goto and is limited to intra-procedural analysis. Future research will focus on expanding the model's scope to inter-procedural dependencies and refining GNN architectures to better capture deep logic flows without performance degradation.

Summary updated

BibTeX
@inproceedings{hin2022linevd,
  author = {David Hin and Andrey Kan and Huaming Chen and Muhammad Ali Babar},
  title = {{LineVD: Statement-level Vulnerability Detection using Graph Neural Networks}},
  booktitle = {MSR},
  year = {2022},
  url = {https://openreview.net/forum?id=YMXfD_sswn},
}
Figure