The Curse of Class Imbalance and Conflicting Metrics with Machine Learning for Side-channel Evaluations

Stjepan Picek, Annelie Heuser, Alan Jovic, Shivam Bhasin, Francesco Regazzoni

Abstract

Machine learning-based side-channel attacks (SCA) often struggle with imbalanced data, where certain leakage states, such as specific Hamming Weights, occur much more frequently than others. This paper investigates the impact of this imbalance on profiling attacks and highlights the inadequacy of standard machine learning metrics like accuracy in evaluating attack success. By evaluating various data-balancing techniques across multiple AES datasets, the authors demonstrate that methods like SMOTE can reduce the number of measurements needed for a successful attack by up to 8x. The study concludes that while deep learning is powerful, it remains susceptible to the "curse of class imbalance," necessitating the development of SCA-specific evaluation metrics and loss functions.

Introduction

Side-channel analysis (SCA) is a powerful technique for recovering secret cryptographic keys by measuring physical leakages, such as power consumption or electromagnetic radiation, during a device's operation. Modern "profiled" attacks leverage machine learning (ML) to build sophisticated models of a device's leakage. However, the application of ML to SCA is not straightforward. Two major hurdles often impede the effectiveness of these attacks: inherent class imbalance in leakage models and a fundamental mismatch between standard ML metrics and SCA performance indicators.

The Problem of Class Imbalance

Most SCA models utilize the Hamming Weight (HW) or Hamming Distance (HD) of intermediate values. In an 8-bit system, these values are not uniformly distributed. For instance, a HW of 4 occurs in 70 out of 256 possible cases, whereas a HW of 0 or 8 occurs only once.

Distribution of Hamming Weight (HW) values for an 8-bit variable, demonstrating significant class imbalance.

As shown in the table above, the majority of occurrences cluster around the middle values. ML classifiers naturally gravitate toward these majority classes (e.g., HW=4), often ignoring the rare but highly informative minority classes (e.g., HW=0). This bias can severely limit the model's ability to generalize across the entire leakage space.

Metric Mismatch: Accuracy vs. Guessing Entropy

A second critical issue is the reliance on standard ML metrics like Accuracy. While the ML community prioritizes accuracy, the SCA community focuses on Guessing Entropy (the average rank of the secret key) and Success Rate.

A model can achieve high accuracy by simply guessing the majority class every time. However, such a model fails completely to recover a key because it provides no discriminative power. Conversely, a model with "low accuracy" might still be excellent at ranking the correct key candidate near the top of its probability distribution.

Confusion matrix showing predicted vs. actual classes, highlighting how models can be biased toward majority classes.

The confusion matrix illustrates how predictions can be skewed. SCA success depends on the entire probability distribution output by a classifier, not just the "Top-1" prediction. Accuracy only considers the Top-1 prediction, making it a poor proxy for actual attack strength.

Methodology

The authors evaluate several strategies to combat imbalance and bridge the metric gap:

  • Data Balancing Techniques: Standard approaches like Random Undersampling and Oversampling are compared against more sophisticated methods like SMOTE (Synthetic Minority Over-sampling Technique) and SMOTE+ENN. SMOTE creates synthetic examples between existing minority points, while SMOTE+ENN cleans up noisy boundaries to improve classifier performance.
  • Classifiers: The study tests traditional ML models, such as Support Vector Machines (SVM) and Random Forests, alongside deep learning architectures like Multilayer Perceptrons (MLP) and Convolutional Neural Networks (CNN).
  • Datasets: Three distinct AES-based datasets are used to cover various signal-to-noise ratio (SNR) scenarios: DPAcontest v4 (high-SNR), AES_RD (low-SNR with random delays), and AES_HD (low-SNR hardware implementation).

Key Results and Insights

The research yields several significant findings:

  • Efficiency Gains with SMOTE: On the noisy AES_RD dataset, a standard Random Forest required 13,500 traces to recover the key. After applying SMOTE, the same classifier needed only 1,600 traces—an 8.4x improvement in attack efficiency.
  • Deep Learning Vulnerability: Even powerful CNNs and MLPs suffer from the "curse of class imbalance." Without explicit balancing, these models tend to collapse toward majority-class predictions, failing to exploit the full leakage signal.
  • Metric Divergence: The authors provide clear evidence that Guessing Entropy can improve (drop) even when Accuracy remains flat or decreases. This reinforces the need for SCA-specific evaluation during the ML training process.

Conclusion

This work demonstrates that class imbalance is a primary obstacle in ML-based side-channel attacks. While techniques like SMOTE offer substantial improvements, the fundamental mismatch between ML loss functions and SCA goals remains. Future research should focus on developing "SCA-aware" loss functions for deep learning that directly optimize for metrics like Guessing Entropy, rather than relying on deceptive proxies like accuracy.

Summary updated

Abstract

We concentrate on machine learning techniques used for profiled sidechannel analysis in the presence of imbalanced data. Such scenarios are realistic and often occurring, for instance in the Hamming weight or Hamming distance leakage models. In order to deal with the imbalanced data, we use various balancing techniques and we show that most of them help in mounting successful attacks when the data is highly imbalanced. Especially, the results with the SMOTE technique are encouraging, since we observe some scenarios where it reduces the number of necessary measurements more than 8 times. Next, we provide extensive results on comparison of machine learning and side-channel metrics, where we show that machine learning metrics (and especially accuracy as the most often used one) can be extremely deceptive. This finding opens a need to revisit the previous works and their results in order to properly assess the performance of machine learning in side-channel analysis.
BibTeX
@article{picek2018curse,
  author = {Stjepan Picek and Annelie Heuser and Alan Jovic and Shivam Bhasin and Francesco Regazzoni},
  title = {{The Curse of Class Imbalance and Conflicting Metrics with Machine Learning for Side-channel Evaluations}},
  journal = {IACR Cryptol. ePrint Arch.},
  year = {2018},
  url = {https://openreview.net/forum?id=GQFsUEfFFZ},
}
Figure