Abstract
Network Intrusion Detection Systems (NIDS) are essential for cybersecurity but often struggle with the scarcity of labeled attack data and the emergence of zero-day threats. This paper introduces GraphIDS, a self-supervised framework that integrates Graph Neural Networks (GNNs) and Transformers to model network traffic. By training a masked autoencoder to reconstruct normal traffic patterns, GraphIDS captures both local topological features and global co-occurrence contexts. Experimental results on standard benchmarks demonstrate that GraphIDS achieves state-of-the-art performance, outperforming existing baselines by up to 25 percentage points while maintaining high inference efficiency.
Introduction
Modern cybersecurity faces significant hurdles in intrusion detection. Most high-performing NIDS rely on supervised learning, which requires massive, expensive-to-produce labeled datasets. Furthermore, these models often fail to detect "zero-day" attacks that were not present in the training data. While unsupervised methods exist, they frequently fail to capture the complex, multi-step nature of sophisticated cyberattacks.
Existing graph-based approaches often decouple representation learning from anomaly detection, leading to suboptimal performance. GraphIDS addresses these challenges by creating an end-to-end system that learns the local structure of individual connections alongside the global context of network-wide communication patterns.
Methodology
Graph Construction
The first stage involves modeling network traffic as a directed graph. In this representation, nodes correspond to hosts (IP addresses), and edges represent communication flows between them. Unlike traditional GNNs that prioritize node features, GraphIDS focuses on edge features—such as packet counts and protocol information—as these carry the most critical indicators for intrusion detection.
Model Architecture
The GraphIDS architecture consists of two primary components:
- GNN Encoder (Local Context): The system utilizes E-GraphSAGE, an inductive GNN capable of handling unseen nodes during inference. It processes the "1-hop" neighborhood of a flow to extract immediate topological context.
- Transformer-based Masked Autoencoder (Global Context): Flow embeddings from the GNN are passed to a Transformer. During training, a "symmetric binary attention mask" randomly disables attention links between flows. This forces the model to learn co-occurrence patterns across the network rather than relying on specific connections.
Training and Inference
GraphIDS is trained exclusively on benign (normal) traffic. The objective is to reconstruct the original flow embeddings. During inference, the reconstruction error—calculated as the difference between the input embedding $h_i$ and the reconstructed embedding $\hat{h}_i$—serves as the anomaly score. High reconstruction errors indicate traffic patterns that deviate significantly from normal behavior, flagging them as potential intrusions.
Experimental Setup
The framework was evaluated on several versions of two prominent NetFlow benchmarks:
- NF-UNSW-NB15 (v2 and v3): Representing smaller-scale network environments.
- NF-CSE-CIC-IDS2018 (v2 and v3): Representing large-scale infrastructure.
The researchers noted that while v3 datasets include additional temporal features, excluding them resulted in more stable and efficient representations without sacrificing detection accuracy.
Results and Discussion
GraphIDS establishes a new state-of-the-art for self-supervised NIDS:
- Detection Accuracy: The model achieved a PR-AUC of 99.98% and a macro F1-score of 99.61% on the UNSW-NB15-v3 dataset.
- Comparative Performance: It outperformed leading baselines, such as Anomal-E and SAFE, by margins ranging from 5% to 25%.
- Operational Efficiency: The model is optimized for real-time monitoring, with an average inference time of 3.83 µs per sample and a modest GPU memory footprint of approximately 1.37 GB.
The success of GraphIDS stems from its unified architecture. By training the GNN and Transformer jointly, the system produces embeddings specifically optimized for the reconstruction task. The dual-modeling approach captures attacks that might appear benign in isolation but suspicious when analyzed within the broader network context.
Conclusion
GraphIDS demonstrates the power of combining local topological information with global relational context for self-supervised intrusion detection. Future work will explore the integration of multimodal data, such as system logs and API calls, to detect stealthy intrusions. Additionally, the development of online learning capabilities will allow the model to adapt to evolving network environments without requiring full retraining.
Summary updated