A Transformer-Based Intrusion Detection System for Zero-Day Attack Detection in IoT Networks
Murtadha D. Hssayeni, Imad Mahgoub · Future Internet · 2026
The possibility of zero-day attacks on Internet of Things (IoT) networks is high, particularly in dynamic and heterogeneous IoT environments, including emerging battlefield scenarios (IoBT). Detecting these attacks requires adaptive and generalizable security mechanisms. Due to the unique and unknown signatures of these attacks, they go undetected using signature-based Intrusion Detection Systems (IDSs) on the one side. On the other side, current anomaly-based IDSs that employ traditional machine learning on statistical features struggle to adapt and generalize to unknown networks, which is the case in IoBT. Transformer-based deep learning models have shown the capability of learning complex sequential patterns. This ability can be leveraged to analyze packet payloads that encompass opcodes capable of executing malicious patterns within an IoT network. In this work, we propose a dual-stage Transformer IDS that operates on the raw payload of network packets to detect zero-day attacks. Due to the lack of IoBT datasets, we evaluate the algorithm on three comprehensive IoT traffic benchmarks—MQTT-IoT, IoT-23, and CIC-IoT-2022—which have a high number of IoT devices and various attacks. Importantly, model evaluation is performed in two cross-validation settings to address the key operational challenges associated with unseen scenarios and networks. The evaluation settings are split-at-scenario to evaluate the detection ability of zero-day attacks and split-at-dataset to evaluate the model’s generalizability to new environments. In the former, the average increase in the F1-score of the proposed algorithm over the baseline model is 44% in detecting four zero-day attacks presented in the MQTT-IoT dataset. In the latter, the average increase in the F1-score is 16% in detecting malicious attacks across the three datasets. These results show the benefit of advanced AI in securing the next generation of IoT systems in future Internet applications.