A Method for Network Intrusion Detection Using Flow Sequence and BERT Framework

Loc Gia Nguyen, Kohei Watabe

TL;DR

This paper introduces a novel Network Intrusion Detection System (NIDS) that leverages the power of Bidirectional Encoder Representations from Transformers (BERT) to analyze sequences of network flows, not just individual flows. This approach significantly improves the system's ability to adapt to evolving network behaviors and new attack patterns, a critical challenge for current NIDS.

What Problem Does This Paper Address?

Network Intrusion Detection Systems (NIDS) are crucial for safeguarding computer networks. While flow-based NIDS, which aggregate packet data, have gained popularity due to their efficiency, they struggle with "domain adaptation." This means they perform poorly when the network's normal behavior or attack patterns change over time, a common issue in real-world deployments. Existing machine learning models often fail to adapt because they analyze individual flows in isolation, missing the broader context provided by temporal sequences of network activity. This paper aims to bridge this gap by using sequential flow information to enhance domain adaptation capabilities.

Methods

The core innovation lies in treating sequences of network flows as analogous to sentences in natural language. The authors employ the BERT framework, a powerful deep learning model for natural language processing, to extract meaningful representations from these flow sequences.

Here's a breakdown of their approach:

  • Flow Sequencing: Instead of analyzing single network flows, the system considers a sequence of temporally adjacent flows. This allows it to capture patterns that emerge over time, such as rapid changes in port numbers indicative of an attacker probing a specific service.
  • BERT for Feature Extraction: BERT is pre-trained on a large corpus of unlabeled data (specifically, benign network flows in this case) using tasks like Masked Language Modeling (MLM). This pre-training allows BERT to learn rich contextual representations of flow sequences. For this NIDS, BERT transforms each flow sequence into a fixed-size vector.
  • MLP for Classification: A Multi-layer Perceptron (MLP) then takes the BERT-generated vector representation and classifies the flow sequence as either benign or malicious.

This approach is novel because it's the first to apply BERT for improving domain adaptation in NIDS by leveraging sequential flow information.

Datasets

The study utilizes the following benchmark datasets:

  • CIDDS-001: This dataset contains unidirectional NetFlow data and includes two environments: a simulated OpenStack environment and an external server environment. A change between these environments is considered a domain shift.
  • CIDDS-002: This dataset also contains unidirectional NetFlow data from a simulated OpenStack environment. A change from CIDDS-001 to CIDDS-002 OpenStack is also treated as a domain shift.

These datasets are valuable because they are recent, labeled, and represent different network environments, making them suitable for evaluating domain adaptation capabilities.

Key Insights and Ideas

  • Context is King: Analyzing sequences of flows, rather than isolated flows, provides crucial contextual information that significantly improves the ability to distinguish between benign and malicious activity, especially in dynamic network environments.
  • BERT's Adaptability: BERT's ability to learn contextual representations from sequential data, originally developed for natural language, proves highly effective for network traffic analysis, enhancing domain adaptation.
  • Feature Agnostic Patterns: The patterns identified in flow sequences are "feature agnostic," meaning they can appear with arbitrary flow features. This robustness makes the approach less susceptible to changes in individual flow feature distributions across different domains.
  • Imbalance Matters: The performance of NIDS can be significantly affected by data imbalance (e.g., many more benign flows than malicious ones). The study explores training on both imbalanced and balanced datasets to assess robustness.

Key Results

The proposed BERT-based NIDS demonstrated strong performance across different test environments:

  • Improved Domain Adaptation: The system consistently achieved good results on both CIDDS-001 external and CIDDS-002 test sets when trained on CIDDS-001 internal data.
  • Competitive Performance: In the first experiment (training on CIDDS-001 internal), the proposed method outperformed other classifiers in accuracy and F1-score on both test sets.
  • Balanced vs. Imbalanced: While the proposed method generally performed well, its performance on CIDDS-002 was notably worse when trained on an imbalanced dataset compared to a balanced one. This highlights the continued importance of data balancing for certain classifiers.
  • Comparison with EFC: The Energy-based Flow Classifier (EFC), a method designed for domain adaptation, performed well on CIDDS-001 external but significantly underperformed on CIDDS-002, suggesting its limitations in larger, imbalanced datasets.

Limitations and Future Work

  • Precision Impact: The proposed method sometimes resulted in lower precision (more false positives) compared to methods like KNN. This is because it detects more anomalous flows, including some benign ones that appear unusual in context.
  • Future Work: The authors plan to extend their work by modeling the distribution of benign flow sequences and using deviations from this distribution to detect anomalous flows, moving towards a more unsupervised or semi-supervised approach. They also aim to explore using feedforward neural networks for classification, which might offer further improvements.

Summary updated

BibTeX
@inproceedings{nguyen2023method,
  author = {Loc Gia Nguyen and Kohei Watabe},
  title = {{A Method for Network Intrusion Detection Using Flow Sequence and BERT Framework}},
  booktitle = {ICC},
  year = {2023},
}
Figure