[Paper Review] LineVD: Statement-level Vulnerability Detection using Graph Neural Networks
LineVD treats statement-level vulnerability detection as node classification on program graphs, using CodeBERT for code embeddings and GNNs to exploit data/control dependencies, achieving substantial gains over prior interpretation-based models.
Current machine-learning based software vulnerability detection methods are primarily conducted at the function-level. However, a key limitation of these methods is that they do not indicate the specific lines of code contributing to vulnerabilities. This limits the ability of developers to efficiently inspect and interpret the predictions from a learnt model, which is crucial for integrating machine-learning based tools into the software development workflow. Graph-based models have shown promising performance in function-level vulnerability detection, but their capability for statement-level vulnerability detection has not been extensively explored. While interpreting function-level predictions through explainable AI is one promising direction, we herein consider the statement-level software vulnerability detection task from a fully supervised learning perspective. We propose a novel deep learning framework, LineVD, which formulates statement-level vulnerability detection as a node classification task. LineVD leverages control and data dependencies between statements using graph neural networks, and a transformer-based model to encode the raw source code tokens. In particular, by addressing the conflicting outputs between function-level and statement-level information, LineVD significantly improve the prediction performance without vulnerability status for function code. We have conducted extensive experiments against a large-scale collection of real-world C/C++ vulnerabilities obtained from multiple real-world projects, and demonstrate an increase of 105\% in F1-score over the current state-of-the-art.
Motivation & Objective
- Address the limitation of function-level vulnerability predictions by enabling statement-level localization of vulnerabilities.
- Leverage control and data dependencies between statements via graph neural networks.
- Integrate function-level and statement-level information to improve prediction accuracy in SVD.
- Provide a scalable, fully supervised approach with real-world, imbalanced data.
Proposed method
- Represent each function as a graph where nodes are statements and edges encode control and data dependencies (PDG/CDG).
- Extract function- and statement-level embeddings with CodeBERT, using a dedicated tokenization and the classification token for embeddings.
- Apply Graph Attention Networks to propagate contextual information across statements using the PDG/CDG edges.
- Train a shared classifier that blends statement-level GNN outputs with the function-level embedding, including an element-wise interaction to align predictions.
- Optimize with cross-entropy loss on statement labels, using a training regime that balances function-level samples and evaluates at the statement level.
Experimental results
Research questions
- RQ1RQ1: How does LineVD improve statement-level vulnerability prediction compared with the state-of-the-art interpretation-based SVD model IVDetect?
- RQ2RQ2: How do different code embedding methods (CodeBERT, Doc2Vec, GloVe) affect statement-level SVD performance?
- RQ3RQ3: What is the impact of using GNNs (GCN vs. GAT) and graph types (PDG vs. CDG) on performance, and how does function-level information help?
- RQ4RQ4: How does LineVD perform in cross-project scenarios where test data come from unseen projects?
- RQ5RQ5: Which statement types are best distinguished by LineVD in real-world data?
Key findings
- LineVD achieves a 105% increase in F1-score over the current state-of-the-art interpretation-based model.
- LineVD benefits from jointly learning function-level and statement-level information, significantly outperforming single-source-information baselines.
- Using PDG/CDG with GNNs (GAT often preferred) improves statement-level vulnerability detection compared to non-graph baselines.
- LineVD demonstrates effectiveness under realistic imbalanced data and cross-project splits on Big-Vul, a large real-world dataset with ~10k vulnerable and ~177k non-vulnerable samples.
- CodeBERT-based embeddings outperform Doc2Vec and GloVe for statement-level SVD within LineVD’s framework.
- The study provides a public replication package with dataset, code, and models.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.