MADCAT: Combating Malware Detection Under Concept Drift with Test-Time Adaptation

Eunjin Roh, Yigitcan Kaya, Christopher Kruegel, Giovanni Vigna, Sanghyun Hong

TL;DR

Machine learning models for malware detection quickly degrade over time due to "concept drift"—the constant evolution of software and malicious techniques. MADCAT tackles this by pairing a classifier with a masked autoencoder (MAE) to perform self-supervised test-time training on incoming, unlabeled samples without needing human annotations. By learning to reconstruct masked features on a small, pseudo-balanced subset of inference data, MADCAT halts performance decay and substantially outperforms standard static detectors over multi-year deployments.

What Problem Does This Paper Address?

When machine learning models are deployed to detect malware, they inevitably run into concept drift: over months and years, benign applications adopt new APIs and libraries, while malware authors deliberately craft new evasion tactics and components. As a result, static models trained on past data steadily lose detection accuracy.

Standard industry solutions rely on continuous supervised re-training or active learning. However, these require analysts to constantly label newly emerging malware samples—a costly, slow, and human-intensive bottleneck. MADCAT explores an orthogonal question: Can a model adapt to evolving malware at test time using self-supervision on unlabeled data alone?

Methods

MADCAT combines a lightweight feedforward classifier (BinaryMLP) with a Masked Autoencoder (MAE) framework:

  1. Initial Training:
  2. The encoder-decoder network is first trained to reconstruct randomly masked binary feature vectors (masking ratio between 0.0 and 0.9, default 0.3) using cross-entropy loss.
  3. Once the MAE learns general representation structures, the encoder is frozen, and a classification head is trained on unmasked data using supervised ground-truth labels.
  4. Test-Time Adaptation (Self-Supervision):
  5. As new batches of unlabeled test samples arrive in deployment, a portion of each sample’s feature vector is masked.
  6. The encoder undergoes single-step gradient updates to minimize reconstruction loss on these test samples, updating its internal representations to match the current distribution. The classification head remains fixed.
  7. Handling Class Imbalance with Pseudo-Labeling:
  8. Unlabeled test streams are typically dominated by benign samples (~9:1 ratio). To prevent the encoder from over-adapting purely to benign feature distributions, MADCAT uses initial model predictions to generate pseudo-labels and balances the adaptation subset using one of three strategies: random sampling, confidence-based top-$N$, or confidence-based bucketing.
Input Sample ──► Mask Features ──► Encoder ──► Decoder ──► Reconstruction Loss (Encoder Update)
                       │
                       └──► [Updated Encoder] ──► Classification Head ──► Benign / Malware

Datasets

The authors evaluate MADCAT on the benchmark APIGraph dataset, which spans seven years of Android applications (2012–2018):

  • Features: 1,159-dimensional binary vectors of Drebin static features (e.g., requested permissions, API calls, components).
  • Scale: 320,487 total applications (28,904 malicious, 291,583 benign).
  • Temporal Split: Data from 2012–2014 serves as the initial training set (balanced via downsampling benign samples). Data from 2015–2018 is split into 48 monthly evaluation buckets, where each month is partitioned into 70% test-time adaptation data and 30% evaluation data.

Key Insights and Ideas

  • Reconstruction Forces Robust Representations: A masking ratio of $0.0$ (no masking) fails to help the model adapt. Forcing the encoder to reconstruct missing static features (optimal ratios: $0.1$–$0.6$) compels it to learn structural co-occurrences of APIs and permissions, making its embeddings resilient to feature shifts.
  • Independence from Oracle Labels: Because adaptation is driven purely by masked feature reconstruction, the model updates dynamically without waiting weeks for human analysts or threat feeds to label zero-day variants.
  • Pseudo-Labeling Rescues Skewed Feeds: While uncurated test streams skew heavily toward benign apps, selecting balanced batches via model pseudo-labels preserves adaptation stability without external supervision.

Key Results

  • Resisting Drift: Over the 4-year evaluation period (2015–2018), the unadapted baseline model experienced steady degradation, dropping to a mean F1 score of 0.7529. In contrast, MADCAT with ground-truth-balanced test-time training maintained a stable mean F1 score of 0.9281.
  • Label-Free Operation: When ground-truth balancing was replaced entirely with unsupervised pseudo-labeling, MADCAT still significantly outperformed the baseline, achieving mean F1 scores around 0.828–0.831 across all three selection heuristics (e.g., Confidence-based bucket mean F1: 0.8314).
  • Class-Level Dynamics: Class-wise breakdowns revealed that MADCAT's gains stem primarily from drastically improving benign classification accuracy (reducing false positives over time) while maintaining detection rates on malicious samples comparable to the baseline.

Limitations and Future Work

  • Domain Scope: Evaluation is limited to Android APKs using static binary feature vectors (Drebin/APIGraph). Behavior on other platforms (e.g., Windows PE binaries) and continuous dynamic analysis features remains unverified.
  • Pseudo-Labeling Gap: While pseudo-labeling removes the need for ground-truth annotations, there remains a notable performance gap between pseudo-labeled adaptation (~0.83 F1) and oracle-balanced adaptation (~0.93 F1).
  • Alternative Objectives: The study relies strictly on masked autoencoding; exploring contrastive learning or hybrid self-supervised objectives is left for future work.

Summary updated

BibTeX
@inproceedings{roh2025madcat,
  author = {Eunjin Roh and Yigitcan Kaya and Christopher Kruegel and Giovanni Vigna and Sanghyun Hong},
  title = {{MADCAT: Combating Malware Detection Under Concept Drift with Test-Time Adaptation}},
  booktitle = {PUT @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=a4fQhKVbYV},
}
Figure