Source-linked AI summary

An Adversarial Zero-Shot Learning Approach for Anomaly Detection in Multivariate IoT Traffic Data

Mahshid Rezakhani, Tolunay Seyfi, Fatemeh Afghah

arXiv:2609.03505v1cs.LGcs.NI

TL;DR

IoT anomaly detection must contend with heterogeneous traffic, scarce labels, and domain variability across deployments. The paper combines a sequence-based LSTM–VAE with adversarial alignment, contrastive latent structuring, and adaptors for zero-shot transfer. Across six datasets and 44 scenarios, it reports strong generalization in several compatible settings, while some highly shifted TON–IoT and ACI–IoT targets remain difficult.

  • Problem

    Heterogeneous IoT traffic, domain shift, and scarce anomaly labels make it difficult to transfer detection across deployments, while few existing approaches jointly meet variable-length and strict zero-shot requirements.

    Source: §1 · pp. 1–2
  • Method

    The framework combines a sequence-based LSTM–VAE with adversarial domain alignment, contrastive latent structuring, and adaptor layers for zero-shot anomaly detection.

    Source: §3 · p. 4, §5 · p. 10
  • Results

    Across six benchmarks and 44 transfer scenarios, the method generalizes strongly in several compatible settings, but TON–IoT targets often have high recall and low precision while several ACI–IoT targets show poor recall and low MCC.

    Source: §5 · p. 10
  • Takeaways & Limitations

    The reconstruction-driven method works well when temporal and flow-level structures transfer, while direct contrastive domain adaptation can be more competitive under severe distribution shift.

    Source: §5 · p. 10

    Strict zero-shot alignment does not ensure sufficient latent coverage for every unseen deployment, with weak TON and ACI target cases illustrating the boundary.

    Source: §4.3 · p. 9

Abstract

from arXiv · show

Anomaly detection in Internet of Things (IoT) networks presents unique challenges due to the diversity of devices, lack of labeled data, and domain variability across environments. In this paper, we propose a novel framework for multivariate time-series anomaly detection that leverages adversarial learning and contrastive loss within a sequence-based Variational Autoencoder (VAE) architecture. Our method enables zero-shot domain adaptation by jointly optimizing domain-invariant latent representations and semantically structured embedding spaces, without requiring labeled data or raw feature transfer. To address the heterogeneity of IoT deployments, we introduce encoder and decoder adaptor layers that align feature distributions across domains while preserving contextual semantics. Additionally, we propose a destination-based segmentation strategy to better model real-world communication structures in IoT traffic. Our framework is comprehensively evaluated on six distinct datasets spanning industrial, enterprise, general-purpose, smart home, and military automation domains across 44 transfer scenarios. Experimental results demonstrate strong zero-shot generalization in several cross-domain settings and competitive performance against a contrastive domain-adaptation baseline under realistic, heterogeneous, and privacy-constrained IoT conditions.

1. Introduction

IoT anomaly detection matters for identifying both cyberattacks and operational failures, but heterogeneous traffic, domain shift, scarce labels, and fixed-length assumptions complicate deployment. The paper proposes a zero-shot LSTM–VAE framework combining adversarial domain adaptation and contrastive representation learning to handle variable-length sequences and unseen domains without raw data, labels, or retraining.

1. Introduction

  • Anomaly detection can identify both network attacks and reliability problems such as abnormal packet loss or latency surges.The cited examples include scanning, denial-of-service, botnet propagation, brute-force intrusions, and hardware or connectivity failures.Source: §1 · p. 1
  • IoT traffic varies across devices, protocols, sampling rates, and deployment environments, while labeled anomalies are scarce and common VAE approaches may assume fixed-length sequences or lack cross-domain transfer.These constraints motivate models that accept variable-length flows and generalize to unseen domains without target labels or fine-tuning.Source: §1 · pp. 1–2
  • The proposed framework integrates adversarial domain adaptation and contrastive representation learning into a sequence-driven LSTM–VAE for zero-shot detection in unseen domains.It supports variable-length sequences without raw feature transfer, labels, or target-domain retraining.Source: §1 · p. 2

2. Related Work

Prior IoT anomaly-detection approaches trade off supervision, portability, computational or engineering demands, and readiness for unseen domains. The paper positions its method as fully unsupervised on the source side, strict zero-shot at inference, and based on dual latent alignment without handcrafted features or raw target-feature transfer.

2.1. Supervised and Semi-Supervised AD

  • Supervised and semi-supervised methods can perform strongly in-domain, but label dependence, modality specialization, limited temporal modeling, or policy coupling constrain deployment or portability.Examples include ST-VAE, SwinIoT, TF–IDF system-call pipelines, and SDN-integrated policies.Source: §2.1 · p. 2

2.2. Unsupervised AD

  • Unsupervised methods avoid labels but face trade-offs involving compute, training stability, domain-specific graph construction, feature engineering, or platform-bound toolchains.Federated variants improve privacy through decentralized training but can depend on synchronized participation and face stragglers and non-IID data.Source: §2.2 · p. 2

2.3. Few-/Zero-Shot AD and Domain Shift Without Retraining

  • Many few- or zero-label adaptation methods still fine-tune on target data, whereas this framework performs no target loss computation or target-side retraining.Its contrastive and adversarial objectives are learned on source and auxiliary domains.Source: §2.3 · p. 2

2.4. Positioning and Distinctions

  • The method’s stated distinctions are unsupervised source-side training, strict zero-shot inference, contrastive semantic structuring plus adversarial domain invariance, and operation without handcrafted features or graph construction.It transfers via learned source/auxiliary-domain parameters without raw feature transfer from target sites.Source: §2.4 · p. 2

2.5. Comparison With Representative Methods

  • The comparison framework assesses representative methods by supervision, multivariate-flow modality, variable-length support, domain-shift handling, zero-/few-shot readiness, and retraining needs.The supplied passage describes the comparison axes, not individual table outcomes.Source: §2.5 · p. 2

3. System Model

The system combines an LSTM-VAE with adaptor layers and adversarial and contrastive learning to learn transferable representations from two unlabeled source datasets. It defines a strict zero-shot task in which a held-out target is not used for training, alignment, loss computation, or adaptation, and is scored directly after training.

3. System Model

  • The framework combines an LSTM-VAE, input/output adaptors, adversarial domain alignment, and contrastive latent structuring to learn transferable representations from two unlabeled source datasets.At inference, it detects anomalies using reconstruction error and latent deviations in an unseen target domain.Source: Figure 1 · p. 3, §3 · pp. 3–4

3.1. Problem Definition

  • The task uses primary and auxiliary source domains to train a detector for a held-out target whose distribution is unavailable during training.The target is excluded from both training stages, including adversarial alignment and contrastive learning.Source: §3.1 · p. 4
  • The trained encoder–decoder scores target sequences by reconstruction error and latent deviation, with anomalies assigned when the score exceeds a predefined threshold.Target labels are reserved for final evaluation and are not used for training, alignment, threshold selection, or adaptation.Source: §3.1 · p. 4

3.2. Sequence-Based VAE

The sequence-based VAE encodes multivariate IoT traffic sequences into a latent representation and reconstructs them step by step. Its recurrent structure models temporal patterns, with reconstruction deviations signaling potential anomalies.

3.2. Sequence-Based VAE

  • The sequence-based VAE encodes an observed traffic sequence into a latent representation while retaining structural and temporal features.It assumes a standard Gaussian prior over the latent variables and uses a Gaussian encoder to approximate the intractable posterior.Source: §3.2 · p. 4
  • The LSTM encoder processes the sequence and computes a final hidden state that summarizes its temporal dependencies.The latent variables are derived from this summary and sampled using learned parameters.Source: §3.2 · pp. 4–5
  • An LSTM decoder reconstructs the sequence one step at a time from the latent representation and the previous reconstructed step.The reparameterization trick enables backpropagation through latent sampling.Source: §3.2 · pp. 4–5
  • Reconstruction deviations signal potential anomalies, and the sequence formulation models both short- and long-term traffic patterns.The passage describes detection of sudden and gradual attacks across varied environments.Source: §3.2 · p. 5

3.3. Variable-Length Sequence Adaptation

The framework accommodates variable-duration traffic sequences and combines adversarial domain alignment with contrastive learning to structure latent representations. Training aligns source domains while leaving the held-out target domain unused until zero-shot evaluation.

3.3. Variable-Length Sequence Adaptation

  • Variable-length sequences avoid padding short flows with little useful context or truncating long flows before gradual anomalies emerge.The LSTM encodes sequences into compact latent representations without requiring a shared duration; adversarial and contrastive learning are combined to preserve useful behavioral structure across lengths and domains.Source: §3.3 · p. 5

3.4. Adversarial and Contrastive Learning for Domain-Invariant Representations

  • Adversarial alignment and cosine-based contrastive learning are integrated during latent-space training, with the held-out target domain excluded.The encoder is trained to suppress source-domain artifacts while preserving temporal structure useful for unseen deployments.Source: §3.4 · p. 5

3.4.1. Adversarial Domain Alignment

  • A discriminator distinguishes primary-source from auxiliary-source latent representations while a gradient-reversal layer trains the encoder to make them difficult to separate.This objective encourages removal of domain-specific nuisance factors and retention of more transferable features.Source: §3.4.1 · p. 5

3.4.2. Cosine-Based Contrastive Learning

  • Cosine-based contrastive learning encourages similar temporal patterns to remain close and dissimilar patterns to separate in latent space.Its margin controls the minimum desired separation between anchor-negative pairs.Source: §3.4.2 · p. 5

3.4.3. Combined Objective

  • The combined objective balances adversarial domain confusion and contrastive latent organization, while reserving the target domain for final zero-shot evaluation.It uses no target-domain labels, target-domain loss computation, or target-side fine-tuning during optimization.Source: §3.4.3 · pp. 5–6

3.5. Domain-Specific Adaptors for Variability Handling

Lightweight domain-specific adaptors address heterogeneous IoT feature distributions around a shared LSTM-VAE. The source-trained shared model is applied directly to the held-out target domain without training a target-specific adaptor.

3.5. Domain-Specific Adaptors for Variability Handling

  • Differences in feature scale, ordering, units, protocols, and device behavior can make a shared sequence model learn dataset-specific artifacts instead of transferable temporal structure.The framework places lightweight domain-specific adaptor layers around the shared LSTM-VAE to reduce this effect.Source: §3.5 · p. 6
  • The encoder adaptor maps domain-specific input sequences into a shared feature space before the shared LSTM encoder produces latent representations.A decoder adaptor maps the decoder output back into the corresponding domain-specific feature space; the adaptors absorb feature variability while the shared model focuses on transferable temporal dynamics.Source: §3.5 · p. 6
  • At strict zero-shot inference, the shared encoder-decoder is applied directly to the held-out target domain without training a target-specific adaptor.The anomaly decision uses reconstruction and latent-deviation scores.Source: §3.5 · p. 6

3.6. Loss Functions and Training Phases

Training proceeds from primary-source VAE pretraining to source–auxiliary alignment, followed by strict zero-shot inference on a held-out target domain. The target domain is excluded from training and used only for final evaluation.

3.6. Loss Functions and Training Phases

  • Training has two stages: primary-source reconstruction pretraining, then adversarial and contrastive alignment between primary and auxiliary source domains.The held-out target domain is excluded from both stages and reserved for final zero-shot evaluation.Source: §3.6 · p. 6

3.6.1. Phase 1: VAE Pretraining on the Primary Source Domain

  • Phase 1 trains the LSTM-VAE on the primary source domain to reconstruct normal temporal behavior and regularizes the approximate posterior toward a standard Gaussian prior.The objective weights reconstruction fidelity and latent regularization.Source: §3.6.1 · p. 6

3.6.2. Phase 2: Source–Auxiliary Alignment

  • Phase 2 uses a discriminator and gradient reversal to make primary- and auxiliary-source representations difficult to distinguish, alongside cosine-based contrastive latent structuring.The objective balances adversarial domain confusion and contrastive organization; target data is not used in this phase.Source: §3.6.2 · p. 6

3.6.3. Phase 3: Strict Zero-Shot Inference

  • In Phase 3, the frozen encoder and decoder score target sequences using reconstruction error and latent deviation, with a predefined threshold determining anomalous classifications.Target labels are used only to compute final evaluation metrics.Source: §3.6.3 · p. 7

3.7. Evaluation Datasets

The evaluation uses six datasets to span enterprise, industrial, military-oriented, academic, and smart-home traffic. Paired source domains are used to test transfer to a held-out target under zero-shot conditions.

  • Together, the six-dataset suite spans five deployment domains and supports 44 source–auxiliary–target combinations with the target held out during training.The target dataset is used only for final metric computation.Source: §3.7 · pp. 7–8
  • CICIDS 2018, WUSTL-IIOT-2021, and ACI-IoT-2023 cover enterprise, industrial, and military-oriented traffic with differing benign and attack distributions.The datasets range from predominantly benign industrial traffic to an attack-dominant military-oriented environment.Source: §3.7 · p. 7
  • CICIDS 2017 includes benign and common, up-to-date attacks, with robustness evaluated across temporal captures and protocol variations; UNSW-NB15 tests cross-protocol and attack-style generalization, and TON-IoT is smart home-oriented.Source: §3.7 · p. 7

4. Model Evaluation and Analysis

Evaluation uses strict zero-shot transfer, with target data withheld from training and inference losses. Results are mixed: the method performs well in several CICIDS settings, but transfer weaknesses and comparison with DACAD vary by target domain.

4.1. Experimental Protocol

  • Target labels are excluded from training, alignment, threshold selection, and model selection; accuracy, MCC, recall, precision, F1, and FPR measure transfer.The protocol is intended to measure strict zero-shot rather than target-adaptive performance.Source: §4.1 · p. 8
  • The combined-source confusion matrix has 66 false negatives and 330 false positives, with the passage reporting its top accuracy and most balanced classification performance.The CICIDS-only scenario has moderate false positives; the WUSTL-only model has increased false positives and false negatives.Source: §4.1 · p. 8

4.2. Zero-Shot Inference Protocol (No Target Loss)

  • At inference, no target data or loss is used; decisions rely on reconstruction errors and latent deviations.Source: §4.2 · p. 8

4.3. Cross-Domain Benchmarking and Latent Alignment via t-SNE

  • Source pairs involving CICIDS, NB15, or WUSTL often form smooth latent manifolds; TON-source embeddings can become nearly one-dimensional, while ACI pairs remain more scattered.The authors caution that compactness alone may not preserve enough variability for unseen target modes.Source: §4.3 · p. 8
  • Across 44 transfers, several CICIDS targets perform strongly, while TON often trades precision for recall and ACI shows weak recall and MCC.The cross-domain results are presented in Tables 2 and 3.Source: §4.3 · p. 8, Table 2 · p. 9, Table 3 · p. 9

4.4. Comparison with DACAD

  • Relative to DACAD, the framework combines adversarial alignment with contrastive latent structuring, supports variable-length flows, and segments traffic by destination endpoint.The destination-centric strategy is described as preserving device-level communication context.Source: §4.4 · p. 10
  • Against DACAD, a contrastive domain-adaptation baseline, outcomes are mixed: the proposed method favors CICIDS targets, while DACAD performs better in several NB15, TON-IoT, and ACI-IoT settings.The comparison is described as complementary rather than a uniform advantage for either method.Source: §4.4 · pp. 9–10

5. Conclusion

The paper introduces a contrastive adversarially adaptive LSTM–VAE for zero-shot IoT traffic anomaly detection. Across six benchmarks and 44 transfer scenarios, it generalizes strongly in some structurally compatible settings, while performance varies under severe domain shift.

  • The framework combines variational reconstruction, adversarial source-domain alignment, and cosine-based contrastive latent structuring for strict zero-shot anomaly detection.It avoids target-side labels, target-domain loss, and fine-tuning.Source: §5 · p. 10
  • Across six benchmarks and 44 transfers, the framework generalizes strongly in several settings, particularly for CICIDS2017 and CICIDS2018 targets.The conclusion also reports degradation in smart-home and military-IoT targets when aligned sources lack sufficient latent coverage.Source: §5 · p. 10
  • Comparison with DACAD shows complementary performance: reconstruction-driven detection works well when temporal and flow structure transfers, while direct contrastive adaptation can be more competitive under severe shift.Source: §5 · p. 10

CRediT authorship contribution statement

The statement lists the authors’ contributions across conceptualization, methods, software, validation, analysis, investigation, data curation, writing, and visualization. It also assigns supervision, project administration, and funding acquisition to Fatemeh Afghah.

Loading 2609.03505v1…