Applying Self-supervised Learning to Network Intrusion Detection for Network Flows with Graph Neural Network

Renjie Xu, Guangwei Wu, Weiping Wang, Xing Gao, An He, Zhengpeng Zhang

TL;DR

This paper introduces NEGSC, a novel self-supervised Graph Neural Network (GNN) approach for network intrusion detection. It addresses the challenge of manually labeling network traffic data by learning to identify malicious flows and their types without supervision, achieving competitive results with state-of-the-art methods.

What Problem Does This Paper Address?

Network Intrusion Detection Systems (NIDS) are crucial for cybersecurity, but they face a significant challenge: the need for vast amounts of manually labeled network traffic data. This labeling process is time-consuming, expensive, and often impractical, especially given the ever-evolving nature of cyberattacks. Existing GNN-based NIDS often rely on supervised learning, and even semi-supervised methods struggle to fully leverage the inherent graph structure of network traffic. Furthermore, most current self-supervised methods only focus on distinguishing between benign and malicious traffic, failing to identify specific attack types. This paper aims to bridge this gap by developing a self-supervised GNN that can perform multiclass classification of network flows, identifying specific attack types without requiring labeled data.

Methods

The core of the proposed method, named NEGSC (NetFlow-Edge Generative Subgraph Contrast), consists of two main components:

  • NEGAT (NetFlow-Edge Graph Attention Network): This is a novel GNN encoder designed to extract features from network flow data. Unlike traditional GNNs that focus on node features, NEGAT emphasizes edge features (representing network flows) and incorporates an edge-featured self-attention mechanism. This allows it to better capture the relationships and importance of network traffic flows.
  • NEGSC (Self-supervised Framework): This component builds upon the Generative Subgraph Comparison (GSC) framework. It uses NEGAT to generate graph embeddings and then employs a contrastive learning approach. NEGSC samples subgraphs around center nodes and generates corresponding contrastive subgraphs. It then constructs positive (same center node) and negative (different center nodes) samples. A structured contrastive loss function, utilizing Wasserstein Distance for edge features and Gromov-Wasserstein Distance for topological structure, is introduced to differentiate between these samples and identify attack types.

Datasets

The authors evaluated their model on four publicly available NetFlow-based datasets:

  • NF-Bot-IoT [6]
  • NF-Bot-IoT-v2 [44]
  • NF-CSE-CIC-IDS2018 [6]
  • NF-CSE-CIC-IDS2018-v2 [44]

These datasets are commonly used for network intrusion detection and support both binary and multiclass classification scenarios.

Key Insights and Ideas

  • Edge-centricity in NIDS: The paper strongly argues that network flow data is inherently "edge-centered," meaning the critical information lies in the flows (edges) themselves, not just the hosts (nodes). This insight drives the design of their edge-focused encoder, NEGAT.
  • Self-supervised multiclass classification for NIDS: This is presented as a significant advancement, as most existing self-supervised methods are limited to binary classification (benign vs. malicious). The ability to identify specific attack types without labels is crucial for practical NIDS deployment.
  • Attention on Edges: Applying attention mechanisms to edges, rather than just nodes, is a key innovation that allows the model to better understand the nuances of network traffic flows.
  • Leveraging Graph Structure for Contrastive Learning: The use of Wasserstein and Gromov-Wasserstein distances to measure differences in edge features and topological structures, respectively, provides a robust way to distinguish between different types of network traffic in a self-supervised manner.

Key Results

  • Binary Classification: The proposed method (NEGAT + NEGSC) significantly outperforms the state-of-the-art self-supervised method Anomal-E across multiple metrics (Accuracy, Precision, Recall, F1) on all tested datasets. It also shows competitive results against the supervised method TS-IDS, sometimes even surpassing it.
  • Multiclass Classification: The model achieves high Recall and F1 scores on multiclass classification tasks, demonstrating its ability to distinguish between various attack types. For instance, on NF-CSE-CIC-IDS2018-v2, Recall reaches 97.85% and F1 reaches 97.43%.
  • Ablation Studies: Experiments confirm the effectiveness of both the NEGAT encoder and the NEGSC framework. Replacing NEGAT with E-GraphSAGE led to decreased performance, highlighting NEGAT's superiority for this task. Similarly, using the original GSC instead of NEGSC also resulted in lower scores.

Limitations and Future Work

  • Data Imbalance: The paper acknowledges that the datasets used exhibit a common real-world phenomenon of data imbalance, where benign samples significantly outnumber attack samples. While the model performs well, the authors suggest that more corresponding data might be needed for certain attack types, especially for self-supervised methods.
  • Performance on NF-BoT-IoT-v2: While generally strong, the model slightly underperforms TS-IDS on the NF-BoT-IoT-v2 dataset in terms of ROC curve micro-average. The authors attribute this to the self-supervised nature requiring more data than supervised methods.
  • Future Work: The authors plan to address data imbalance issues and incorporate the temporal dependency of network flows into their model. They also note that their NEGSC framework, designed for edge-centered NIDS, can handle both node and edge information, suggesting potential applications in other domains.

Summary updated

Abstract

Graph Neural Networks (GNNs) have garnered intensive attention for Network Intrusion Detection System (NIDS) due to their suitability for representing the network traffic flows. However, most present GNN-based methods for NIDS are supervised or semi-supervised. Network flows need to be manually annotated as supervisory labels, a process that is time-consuming or even impossible, making NIDS difficult to adapt to potentially complex attacks, especially in large-scale real-world scenarios. The existing GNN-based self-supervised methods focus on the binary classification of network flow as benign or not, and thus fail to reveal the types of attack in practice. This paper studies the application of GNNs to identify the specific types of network flows in an unsupervised manner. We first design an encoder to obtain graph embedding, that introduces the graph attention mechanism and considers the edge information as the only essential factor. Then, a self-supervised method based on graph contrastive learning is proposed. The method samples center nodes, and for each center node, generates subgraph by it and its direct neighbor nodes, and corresponding contrastive subgraph from the interpolated graph, and finally constructs positive and negative samples from subgraphs. Furthermore, a structured contrastive loss function based on edge features and graph local topology is introduced. To the best of our knowledge, it is the first GNN-based self-supervised method for the multiclass classification of network flows in NIDS. Detailed experiments conducted on four real-world databases (NF-Bot-IoT, NF-Bot-IoT-v2, NF-CSE-CIC-IDS2018, and NF-CSE-CIC-IDS2018-v2) systematically compare our model with the state-of-the-art supervised and self-supervised models, illustrating the considerable potential of our method. Our code is accessible through https://github.com/renj-xu/NEGSC.
BibTeX
@misc{xu2024applying,
  author = {Renjie Xu and Guangwei Wu and Weiping Wang and Xing Gao and An He and Zhengpeng Zhang},
  title = {{Applying Self-supervised Learning to Network Intrusion Detection for Network Flows with Graph Neural Network}},
  year = {2024},
  eprint = {2403.01501},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.01501},
}
Figure