Abstract
Detecting software vulnerabilities is a critical challenge in cybersecurity, where traditional static and dynamic analysis methods often fall short due to high false-positive rates or limited coverage. This paper introduces 3GNN, a deep learning framework that treats source code as a set of disaggregated graphs—Abstract Syntax Trees (AST), Control Flow Graphs (CFG), and Data Flow Graphs (DFG). By processing these representations through independent parallel pipelines, 3GNN avoids the noise inherent in fused graph structures. The model employs Crystal Graph Convolutional Networks and hierarchical pooling to focus on security-relevant code segments. Evaluations on the Draper and QEMU+FFmpeg datasets demonstrate that 3GNN significantly outperforms state-of-the-art models, achieving a 6.9% improvement in F1 score on the Draper benchmark.
Introduction
Software security traditionally relies on static analyzers, which frequently produce false positives, and dynamic analysis, which is resource-intensive and often misses edge cases. Recent AI-driven approaches have attempted to bridge this gap by treating code as text or as a single "fused" multi-graph. However, fusing disparate code relationships (syntax, control flow, and data flow) into a single complex graph can introduce significant noise, potentially obscuring subtle vulnerability signals. 3GNN addresses this by maintaining separate pipelines for different graph types, allowing the model to learn specialized vulnerability templates tailored to specific program constructs.
Methodology
The 3GNN architecture consists of four primary stages designed to extract and refine features from source code.
- Code-to-Graph Transformation: Source code is parsed into three distinct representations using the Joern tool: the AST (syntax), CFG (execution paths), and DFG (variable dependencies).
- Vectorization: Nodes are encoded using a combination of one-hot vectors for node types and a Transformer encoder to capture the semantic meaning of code tokens within each node.
- Information Exchange: This core innovation utilizes three parallel pipelines. Each pipeline employs Crystal Graph Convolutional Networks (CGCN) for message passing and Self-Attention Graph (SAG) Pooling. The hierarchical pooling mechanism is critical as it prunes irrelevant nodes, forcing the model to focus on the most suspicious parts of the code.
- Classification: The final representations from all three pipelines are concatenated and fed into a Multi-Layer Perceptron (MLP) for prediction.
To handle imbalanced datasets and functions containing multiple vulnerabilities, the authors introduced a novel two-factor loss function combining standard cross-entropy with a specialized binary loss.
Experimental Evaluation
The model was evaluated on two major C/C++ benchmarks:
- Draper: A massive, highly imbalanced dataset containing over 1.1 million functions collected from GitHub and Debian.
- QEMU+FFmpeg: A smaller, more balanced dataset of approximately 21,000 functions curated from real-world open-source projects.
Key Results
3GNN demonstrated superior performance across all primary metrics compared to text-based (BiLSTM), image-based (CNN), and standard graph-based (GGNN) baselines.
On the Draper dataset, 3GNN achieved an F1 score of 54.32, representing a 6.9% improvement over the next-best model (GGNN at 50.80). The model also maintained a high Matthews Correlation Coefficient (MCC), indicating robust performance even on highly imbalanced data.
Discussion and Insights
The success of the 3GNN approach highlights several key findings:
- Disaggregation vs. Fusion: Keeping graph types separate allows the model to capture specialized patterns, such as resource leaks in CFGs or dangerous syntax patterns in ASTs, without cross-type interference.
- Hierarchical Filtering: The use of SAG Pooling effectively "zooms in" on the specific statements relevant to a vulnerability, which typically reside in only a small fraction of the total code.
- AST Significance: While the combination of all three graphs is superior, the AST was found to be the most informative single representation, coming within 3.5% of the full 3GNN's performance.
- Hybrid Potential: The researchers found that using a Random Forest classifier on top of GNN-learned features (3GNN+RF) provided an additional performance boost, suggesting a role for classical ML in refining deep learning outputs.
Conclusion and Future Work
3GNN provides a more precise and effective way to model code for security analysis by leveraging disaggregated graph representations. Future work will focus on expanding language support beyond C/C++, improving the explainability of graph-based predictions to assist developers, and optimizing the model for extremely large, monolithic functions that currently exceed node limits.
Summary updated