DoS and DDoS mitigation using Variational Autoencoders

Eirik Molde Bårli, Anis Yazidi, Enrique Herrera-Viedma, Hårek Haugerud

Abstract

Traditional rule-based systems often struggle to mitigate Distributed Denial of Service (DDoS) attacks because malicious packets frequently mimic legitimate traffic. This paper introduces two novel deep learning approaches using Variational Autoencoders (VAEs) to autonomously filter malicious network flows. The primary method, Latent Layer Classification (LLC-VAE), utilizes the VAE's latent space for classification, achieving over 93% accuracy on unseen network topologies and demonstrating the potential for generative models in real-time cyber defense.

Introduction

Denial of Service (DoS) and DDoS attacks aim to overwhelm servers by exhausting bandwidth or compute resources. As botnets grow in scale, capable of unleashing terabits of data per second, the core challenge remains identification: in isolation, a malicious packet often looks identical to a benign one. It is the volume and coordination of traffic that define the attack. Current mitigation systems typically rely on static pattern recognition or simple frequency thresholds, both of which are prone to errors or require constant manual updates. This research explores an autonomous, intelligent system capable of learning behavioral differences between normal and malicious traffic flows without hardcoded rules.

Methods

The authors propose two distinct architectures built on Variational Autoencoders (VAEs). Unlike standard autoencoders, VAEs map data to probability distributions, forcing the model to learn smooth, continuous representations that are ideal for grouping similar network behaviors.

Latent Layer Classification (LLC-VAE)

This is the primary approach. Network traffic flows are processed by the VAE's encoder. Instead of simply decoding the latent space ($z$) back to the input, a fully connected classification layer is attached directly to the latent space. The model is optimized using a combined loss function: Reconstruction Loss (R-Loss), KL-Divergence Loss (KL-Loss), and Prediction/Cross-Entropy Loss (P-Loss).

The LLC-VAE architecture, showing the flow from input to latent space (z), the classification layer, and the various loss components.

Loss Based Detection (LBD-VAE)

This anomaly detection approach involves training a VAE exclusively on benign traffic. The hypothesis is that the model will reconstruct normal traffic with low loss but fail on malicious traffic, resulting in high reconstruction loss. A secondary classifier is then used to flag attacks based on these loss values.

Feature Selection

Using Local Interpretable Model-agnostic Explanations (LIME), the authors analyzed 76 network flow features. They eventually pruned the input to the 40 most impactful features to improve efficiency and performance.

Experimental Setup

The models were evaluated using flow-based network traffic data:

  • CSECICIDS2018: Used for training and validation, containing over 7.3 million benign and 1.9 million malicious flows (e.g., Slowloris, LOIC).
  • CICIDS2017: Used as a test set. Because this dataset was generated on a different network topology, it serves as a rigorous test of the model's ability to generalize beyond memorizing specific network configurations.

Key Insights and Results

One of the most significant findings was that removing Source and Destination IP addresses improved test accuracy by 16%. Including IPs caused the model to overfit by memorizing specific attacker addresses rather than learning underlying behavioral patterns. Additionally, the authors found that the standard KL-Loss multiplier used in generative tasks was too aggressive; reducing it to $1 \cdot 10^{-6}$ allowed the model to prioritize classification accuracy while retaining regularization benefits.

Performance Metrics: * Accuracy: On the validation set, LLC-VAE achieved 99.59% benign accuracy and 99.98% malicious accuracy. On the unseen CICIDS2017 test set, it maintained ~96.6% benign and ~93% malicious accuracy, outperforming baseline CNNs. * Throughput: The system is highly efficient, processing batches of 1,024 flows in 10.8 milliseconds, which translates to roughly 92,000 to 97,000 flows per second. * LBD-VAE Limitations: The anomaly-detection approach (LBD-VAE) performed poorly, as the gap in reconstruction loss between normal and malicious traffic was insufficient for reliable classification.

Conclusion

While the LLC-VAE shows great promise for autonomous DDoS mitigation, a 3.4% false positive rate on benign traffic suggests it should be used as part of a multi-layered defense pipeline rather than a standalone solution. Future work will focus on refining anomaly detection loss formulations and testing the models against the chaotic noise of real-world internet traffic.

Summary updated

BibTeX
@article{barli2021dos,
  author = {Eirik Molde Bårli and Anis Yazidi and Enrique Herrera-Viedma and Hårek Haugerud},
  title = {{DoS and DDoS mitigation using Variational Autoencoders}},
  journal = {Computer Networks},
  year = {2021},
  doi = {10.1016/j.comnet.2021.108399},
}
Figure