Unknown Attack Detection in IoT Networks using Large Language Models: A Robust, Data-efficient Approach

Shan Ali, Feifei Niu, Paria Shirani, Lionel C. BriandarXiv 2026 · DOI

TL;DR

This paper introduces SiamXBERT, a novel Siamese network-based approach that leverages a domain-specific large language model (SecBERT) for robust and data-efficient detection of unknown (zero-day) cyberattacks in IoT networks. By learning similarity relationships between benign and attack behaviors, SiamXBERT significantly outperforms state-of-the-art methods, especially in low-data scenarios and across different datasets, without relying on packet payloads.

What Problem Does This Paper Address?

The proliferation of Internet of Things (IoT) devices has led to a surge in cyberattacks. A critical challenge in securing these networks is the detection of "unknown" or "zero-day" attacks – threats that deviate from previously observed patterns and are not present in training datasets. Traditional intrusion detection systems (IDS) often struggle with this due to:

  • Data Scarcity: They typically require large amounts of labeled data, which is often unavailable for new or rare attacks.
  • Encrypted Traffic: Many methods rely on inspecting packet payloads, which are inaccessible in encrypted IoT traffic.
  • Distribution Shifts: Models trained on one dataset often perform poorly on data from different network environments or with evolving attack patterns.
  • Resource Constraints: IoT devices themselves are often resource-constrained, limiting the complexity of deployed detection solutions.

Existing solutions often fall short by demanding extensive training data, inspecting payloads, or failing to generalize to unseen threats, creating a need for robust, data-efficient, and payload-free methods.

Methods

The core of the proposed solution is SiamXBERT, a framework that combines a Siamese network architecture with a transformer-based large language model (LLM) specifically fine-tuned for cybersecurity (SecBERT). Here's a breakdown of its key components:

  • Dual-Modality Feature Extraction: SiamXBERT integrates features from two sources:
  • Flow-level features: Extracted using Zeek, capturing connection-level information like duration, byte counts, and protocol types.
  • Packet-level features: Extracted using DPKT, focusing on header information and packet-level dynamics.
  • Derived features: Four novel features are introduced to capture directional flow characteristics and rate-normalized properties, enhancing behavioral modeling. This dual-modality approach ensures compatibility with encrypted traffic as it avoids payload inspection.

  • Siamese Network with SecBERT: The SecBERT model acts as the encoder within a Siamese network. It processes serialized feature representations (LLM prompts) of network flows. The Siamese architecture learns a similarity function rather than strict decision boundaries. This is achieved through meta-learning, where the model is trained to pull embeddings of similar samples (anchor and positive) closer together while pushing dissimilar samples (anchor and negative) apart, using a triplet loss.

  • Meta-Learning and Threshold Selection: Instead of learning a single classifier, SiamXBERT employs meta-learning to train task-specific models for known attack classes. For detecting unknown attacks, a crucial step is threshold selection. This involves simulating unknown scenarios by treating each known attack class as "pseudo-unknown" and calibrating a decision threshold that maximizes the F1-score for these simulated unknown attacks. This learned threshold is then used during inference to classify samples as either a known class or an unknown class.

Datasets

The study utilizes two widely-used IoT security datasets for evaluation:

  • CICIoT2023: A comprehensive dataset with 33 attacks and benign traffic, mimicking a realistic IoT deployment with 105 devices. It provides 39 packet-level features.
  • IoT-23: A dataset collected over a year, containing malware captures and benign traffic, with 15 attack types. It provides 21 flow-level features.

The authors extracted both flow-level and packet-level features from these datasets using Zeek and DPKT to ensure a unified feature representation for all models.

Key Insights and Ideas

  • Metric Learning for Open-Set Problems: The core idea of learning a similarity space (metric learning) is particularly well-suited for the open-set problem of unknown attack detection, as it doesn't require pre-defined boundaries for every possible attack.
  • LLMs as Powerful Feature Extractors: Domain-specific LLMs like SecBERT, when fine-tuned, can extract rich, transferable representations from network traffic data, outperforming traditional ML and DL models, especially in data-scarce scenarios.
  • Dual-Modality is Key for Encrypted Traffic: Combining flow and packet header information is crucial for detecting attacks in encrypted IoT traffic, where payload inspection is impossible.
  • Threshold Calibration is Critical for Unknown Detection: Simply classifying based on similarity isn't enough; a carefully calibrated threshold is essential to distinguish between known and truly unknown threats.
  • Dataset Characteristics Matter: The performance of cross-dataset evaluation can be asymmetric, influenced by the complexity and structure of the datasets themselves.

Key Results

  • Superior Unknown Attack Detection: SiamXBERT consistently outperformed state-of-the-art baselines (ACGAN, SAFE-NID, IDS-Agent, RFG-HELAD) in detecting unknown attacks, achieving significantly higher unknown F1-scores (U-F1). For example, it achieved up to a 78.8% improvement in U-F1 on CICIoT2023 and 415.4% on IoT-23 in within-dataset settings.
  • Data Efficiency: SiamXBERT achieved its strong performance by training on only 100 samples per class, a fraction of the data required by baseline methods (often 10% of the dataset).
  • Robustness Across Datasets: SiamXBERT demonstrated strong generalization capabilities, performing well in both within-dataset and cross-dataset evaluations, particularly when trained on the IoT-23 dataset.
  • LLMs Outperform ML/DL for Known Attacks: In large-scale settings, LLM-based models consistently outperformed traditional ML and DL models for known attack detection, showcasing better scalability and robustness.

Limitations and Future Work

  • Dataset Limitations: The evaluation was conducted on two specific IoT datasets (CICIoT2023 and IoT-23). While diverse, they may not fully represent the vast spectrum of real-world IoT deployments, emerging attack types, or proprietary environments.
  • Generalizability to Other Environments: Further validation on larger-scale, more diverse, and real-world traffic traces is needed to confirm the generalizability of SiamXBERT.
  • Future Work: The authors plan to extend SiamXBERT by:
  • Incorporating additional modalities like temporal traffic dynamics, protocol semantics, and device-level context.
  • Evaluating on a broader range of datasets and real-world scenarios.
  • Further exploring its robustness against evolving attack behaviors.

Summary updated

BibTeX
@misc{ali2026unknown,
  author = {Shan Ali and Feifei Niu and Paria Shirani and Lionel C. Briand},
  title = {{Unknown Attack Detection in IoT Networks using Large Language Models: A Robust, Data-efficient Approach}},
  year = {2026},
  eprint = {2602.12183},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.12183},
}
Figure