Paper commentary
Federated Learning for Malware Detection in IoT Devices
- Problem Malware detection on IoT devices usually needs traffic pooled in one place, which conflicts with the privacy of the data involved.
- Method Trains supervised MLP classifiers and unsupervised autoencoders with federated aggregation over the nine N-BaIoT devices, then compares them with local-only and centralized training and tests robust aggregators under poisoning attacks.
- Results In the unsupervised setting, Multi-epoch avg reached a TNR of 92.61 on a new device, against 59.66 for the naive approach, and a TPR of 99.98 on known devices, against 88.00.

Figure 1 : Framework architecture and its components. The sharing of normalization values and the collaborative hyper- parameter selection are omitted for simplicity.
Original paper · CC BY 4.0 · Valerian Rey, Pedro Miguel Sánchez Sánchez, Alberto Huertas Celdrán, Gérôme Bovet, Martin Jaggi · Federated Learning for Malware Detection in IoT Devices · Original paper figure · Extracted the figure area from page 5 of the original PDF.Why pooled traffic data is hard to use for IoT malware detection
Many deployed IoT devices lack proper security, so detecting infected devices from their network behaviour is a practical need. The common pipeline collects device data at a central entity, trains a global model there and then distributes it or serves detection from the server. That pipeline breaks down when the monitored behaviour carries sensitive or confidential content, because a compromise of the central store would expose it.
Network communications are the dimension most often used to detect cyberattacks, which is why the framework takes its behaviour data from traffic.
Federated learning changes where training happens: each client trains an individual model on its own data and shares only the model parameters, which are then aggregated into a global model. Earlier federated intrusion detection work, as the authors point out, often lacks realistic datasets, an analysis of adversarial impact or a discussion of B5G deployment.
Existing federated security work also focuses on early intrusion detection and does not target malware that is already running on IoT devices. The scenario studied here combines non-IID data across devices, the need to flag unseen malware, the need to classify known malware, and the presence of adversarial clients.
How N-BaIoT is turned into client datasets
N-BaIoT holds the traffic of nine IoT devices, with benign packets and packets infected by Mirai and BASHLITE. Each packet is described by 115 numerical features, which are statistics on packet size, count and jitter over windows from 100 ms to 1 min. Benign samples total 555 932 (7.87%) and attack samples total 6 506 674 (92.13%) across the devices.
Packets captured close together have highly correlated features, so a random split would leak information between training and test data. The split is chronological, with a small block of unused samples between the train and test parts of each file. In the supervised setting, each device is split into a train set of 79%, an unused set of 1% and a test set of 20%.
In the unsupervised setting only benign data is used for training, so the device data is split into a train set of 39.5%, a threshold-selection set of 39.5%, an unused set of 1% and a benign test set of 20%, while all attack data is kept for final testing.
The class balance is changed in three ways for every device: the original 7.87% benign, 50% benign and 95% benign. The supervised solution uses 100000 samples per device, and the unsupervised solution uses 10000 samples per device. Re-balancing is done after the split, using upsampling or downsampling, so no test information leaks into training.
Client preprocessing and local models
Each client scales every feature with min-max scaling, computed only from its own training set. The scaled value is \(\tilde{x} = (x - x_{min}) / (x_{max} - x_{min})\), applied element-wise to the 115 features. Collaborative normalization lets the server reduce the per-client minima and maxima into global values, which every client then stores.
The authors note that this requires each client to reveal its exact minimum and maximum for every feature.
The supervised model is a binary classifier with four MLP architectures and one output neuron, with no hidden layer, or 1, 2 or 3 hidden layers of 115, 58 and 29 neurons. The exponential linear unit follows each hidden layer, and the tried widths correspond to 100%, 50% and 25% of the input dimension.
The unsupervised model is an autoencoder trained only on benign data, so it reconstructs benign samples well and deviating samples poorly. Its training loss is the mean squared error between reconstructed and input features. All autoencoder architectures use a coding dimension of 29, because a 115-dimensional code would let the network learn the identity function on any input.
A sample is flagged as anomalous when its mean squared reconstruction error exceeds a threshold. Each client computes its threshold as the mean plus the standard deviation of the reconstruction errors on its threshold-selection set, \(\mathrm{thr}_k = \mathrm{mean}(\mathrm{MSE}(\mathrm{Thr}_k; w_k)) + \mathrm{std}(\mathrm{MSE}(\mathrm{Thr}_k; w_k))\).
Two aggregation schedules and collaborative threshold selection
Both federated algorithms derive from FedAVG, in which a server averages the parameters that clients send after local training. MINI-BATCH AGGREGATION has clients send their model after every mini-batch update, so each client makes \(E \cdot n_k / B\) transmissions over the full training, with \(B\) the batch size and \(E\) the number of epochs.
MULTI-EPOCH AGGREGATION sends the model once per round, giving \(T\) transmissions per client, but each client performs \(T \cdot E \cdot n_k / B\) local updates.
Hyper-parameters that define the architecture must be common to all clients, so clients share validation results in a collaborative grid search and keep the setting with the best average. For the unsupervised model, the search selects by loss on benign validation data, while the supervised search selects by validation accuracy.
For the autoencoder, each client sends its local threshold and the server returns the average as the global threshold. This is not the same as computing one threshold over all threshold-selection data, because the standard deviation in the formula is non-linear. Sharing the full set of reconstruction errors with the server would avoid this difference, but the framework does not do it.
Federated results without attacks
Table 5 compares the naive approach, MULTI-EPOCH AVG, MINI-BATCH AVG and the centralized approach in the unsupervised setting with Autoencoder A. On the known devices, the TPR is 88.00 for the naive approach and 99.98 for both federated methods and the centralized method. On the known devices the naive approach has the highest TNR, at 97.38, against 94.84 for MULTI-EPOCH AVG, 95.12 for MINI-BATCH AVG and 95.56 for the centralized approach.
On the new device, the TPR is 99.98 for both federated methods and the centralized method, against 87.77 for the naive approach. The TNR on the new device is 59.66 for the naive approach, 92.61 for MULTI-EPOCH AVG, 91.78 for MINI-BATCH AVG and 92.76 for the centralized approach, where a higher TNR is better. The unsupervised comparison reports TPR and TNR only, not accuracy, so the results do not depend on the class balance.
In the supervised setting, accuracy on the known devices is plotted against federation round and training epoch, and the curves lie between 0.992 and 0.999. The authors report that the supervised federated runs reach the centralized accuracy in this scenario, while keeping the data local.
The global threshold of MULTI-EPOCH AVG settles at a larger value than the centralized threshold. The authors note that this is not surprising, since collaborative threshold selection is not equivalent to selecting one threshold on the whole threshold-selection set.
Attacks and robust aggregators
The analysis assumes an honest server, a majority of honest clients and a minority of potentially colluding malicious clients. Malicious clients of this kind are called Byzantine workers. Three data poisoning attacks based on label flipping are defined for the supervised setting: benign label flipping, attack label flipping and all labels flipping.
Benign label flipping aims at a TNR of 0%, attack label flipping aims at a TPR of 0%, and all labels flipping aims at an accuracy of 0%, with the flipped proportion \(p_{poison}\) set to 1 in the experiments.
The gradient factor attack multiplies the malicious gradients by a negative factor \(\alpha_{grad}\) before the model is shared, so that the average update factor over all clients equals −1. The condition is \(\frac{1}{K}(K - f + \alpha_{grad} \cdot f) = -1\), with \(K\) clients of which \(f\) are malicious.
The model cancelling attack sends the original global parameters multiplied by \(\alpha_{param}\), chosen so that the malicious weight cancels the honest weight. The condition is \(K - f + \alpha_{param} \cdot f = 0\), so the malicious clients must know \(f\) in advance.
The coordinate-wise median takes the median of each parameter across clients, and for an even number of clients it averages the two middle values. The coordinate-wise trimmed mean removes a fixed integer number c of the largest and smallest values per parameter before averaging, and is written TM(c). These aggregators need no knowledge of the client data distributions, but their convergence proofs do not hold here because the client datasets differ.
s-Resampling is combined only with TM(2), with s = 2, giving TM(2)◦ 2-Resampling.
Attack and aggregator results
The attack experiments use the supervised setting with 95% benign data and MINI-BATCH AGGREGATION with batch size 64.
With no malicious client, averaging is the best aggregator. Under the gradient factor and model cancelling attacks, a single malicious client turns the averaged model into a constant predictor, with an F1-Score near 10% for a constant positive predictor or 0% for a constant negative predictor.
The coordinate-wise median gives the best overall results among the aggregators tested under attack. With a single malicious client under all labels flipping and model cancelling, the averages are 90% and 92%, but the minimum over the 45 runs is 0% in both cases. With 3 malicious clients, the all labels flipping attack brings the median's average F1-Score down to around 14%.
The trimmed mean fails once the number of malicious clients exceeds c, as the model cancelling results show. TM(1) and TM(2) beat the median only without malicious clients, and by a small margin. TM(2)◦ 2-Resampling improves accuracy without malicious clients but reduces robustness, and s-Resampling is judged too weak for a federation this small.
The median improves resilience under the gradient factor and model cancelling attacks, but the performance remains substantially reduced. Under the all labels flipping attack, averaging still performs better than the robust functions. The authors expect other attacks that strongly change the weights to behave like the gradient factor and model cancelling attacks, but stealthy attacks were not tested.
Communication and local computation trade-off
MINI-BATCH AGGREGATION needs \(E \cdot n_k / B\) model transmissions per client, while MULTI-EPOCH AGGREGATION needs \(T\) transmissions per client. The number of local model updates grows by a factor of \(T\) for MULTI-EPOCH AGGREGATION.
In the supervised approach, MULTI-EPOCH AVG uses T = 30 transmissions, and MINI-BATCH AVG uses 39500 transmissions, with a model of size 94 kB. The communication cost is 2.82 MB for MULTI-EPOCH AVG and 3.713 GB for MINI-BATCH AVG under that assumed model size. Communication is about 1300 times lower for MULTI-EPOCH AVG in the supervised approach and about 2000 times lower in the unsupervised one.
MULTI-EPOCH AVG needs 3.75 times more local training iterations under the selected hyper-parameters. In the table the local training steps are 148080 for MULTI-EPOCH AVG and 39500 for MINI-BATCH AVG in the supervised approach. For the unsupervised approach, the table gives a model of size 27 kB, 810 kB of communication for MULTI-EPOCH AVG and 1.6 GB for MINI-BATCH AVG.
Limitations
The experiments use 8 clients for training, because N-BaIoT contains only nine devices and few suitable federated datasets exist. The adversaries are 1, 2 or 3 clients, which is 12.5%, 25% or 37.5% of the federation, and the authors argue the results extend to larger federations where adversaries stay below 50%.
The current robust aggregators do not give enough resilience once malicious clients exceed 25%, so other robust aggregation algorithms remain to be tested. Krum, Bulyan and AUROR are named as the candidates for future work. Evasion attacks, the unsupervised adversarial case and scalability to B5G-sized federations were not tested.
The server is a central point of failure, and the framework uses a timeout to skip clients that respond late. The Blockchain-based alternative that would remove the server was not implemented in the experiments.
Paper info
- Authors
- Valerian Rey, Pedro Miguel Sánchez Sánchez, Alberto Huertas Celdrán, Gérôme Bovet, Martin Jaggi
- Venue
- arXiv · Preprint
- First published
- 2021-4-15
- Added
- 2026-11-6
- Updated
- 2021-11-19
- Version
- v3
- arXiv
- 2104.09994
- DOI
- 10.1016/j.comnet.2021.108693
- Category
- cs.CR · cs.LG
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
This work investigates the possibilities enabled by federated learning concerning IoT malware detection and studies security issues inherent to this new learning paradigm. In this context, a framework that uses federated learning to detect malware affecting IoT devices is presented. N-BaIoT, a dataset modeling network traffic of several real IoT devices while affected by malware, has been used to evaluate the proposed framework. Both supervised and unsupervised federated models (multi-layer perceptron and autoencoder) able to detect malware affecting seen and unseen IoT devices of N-BaIoT have been trained and evaluated. Furthermore, their performance has been compared to two traditional approaches. The first one lets each participant locally train a model using only its own data, while the second consists of making the participants share their data with a central entity in charge of training a global model. This comparison has shown that the use of more diverse and large data, as done in the federated and centralized methods, has a considerable positive impact on the model performance. Besides, the federated models, while preserving the participant's privacy, show similar results as the centralized ones. As an additional contribution and to measure the robustness of the federated approach, an adversarial setup with several malicious participants poisoning the federated model has been considered. The baseline model aggregation averaging step used in most federated learning algorithms appears highly vulnerable to different attacks, even with a single adversary. The performance of other model aggregation functions acting as countermeasures is thus evaluated under the same attack scenarios. These functions provide a significant improvement against malicious participants, but more efforts are still needed to make federated approaches robust.
Quote from the paper
Valerian Rey, Pedro Miguel Sánchez Sánchez, Alberto Huertas Celdrán, Gérôme Bovet, Martin Jaggi (2021). Federated Learning for Malware Detection in IoT Devices. arXiv:2104.09994v3. https://doi.org/10.1016/j.comnet.2021.108693
BibTeX
@article{rey2021federated,
title = {{Federated Learning for Malware Detection in IoT Devices}},
author = {Valerian Rey and Pedro Miguel Sánchez Sánchez and Alberto Huertas Celdrán and Gérôme Bovet and Martin Jaggi},
year = {2021},
eprint = {2104.09994},
archivePrefix = {arXiv},
doi = {10.1016/j.comnet.2021.108693},
url = {https://arxiv.org/abs/2104.09994v3}
}