On the Adversarial Risk of Test Time Adaptation: An Investigation into Realistic Test-Time Data Poisoning

Yongyi Su, Yushu Li, Nanqing Liu, Kui Jia, Xulei Yang, Chuan-Sheng Foo, Xun Xu

Test-Time Adaptation (TTA) has become a "holy grail" for deploying machine learning models in the wild. It allows a model to update its own weights on the fly as it encounters new, shifted data (like a self-driving car adjusting to a sudden snowstorm). But there’s a catch: if the model is learning from the data it sees at test time, what happens if an adversary "poisons" that data?

A new paper accepted at ICLR 2025, "On the Adversarial Risk of Test Time Adaptation: An Investigation into Realistic Test-Time Data Poisoning," takes a hard look at this vulnerability. The authors argue that previous studies overestimated the risk by using unrealistic "white-box" assumptions. By introducing a more practical threat model, they reveal that while TTA is vulnerable, it’s also more resilient than we thought.

TL;DR

This paper introduces RTTDP (Realistic Test-Time Data Poisoning), a framework that evaluates TTA security under practical constraints—without assuming the attacker has access to real-time model weights or other users' data. The study finds that while clever "in-distribution" attacks can significantly degrade performance, standard TTA components like Exponential Moving Averages (EMA) provide surprisingly robust natural defenses.

What Problem Does This Paper Address?

Most security research assumes an "all-knowing" attacker. In the context of Test-Time Data Poisoning (TTDP), previous work often assumed the adversary had white-box access (knowing the model's exact weights as they change) and access to benign data from other users to help craft the perfect "poison."

In the real world, an attacker usually only has the initial model (grey-box) and their own submitted samples. Furthermore, TTA models are moving targets—they change with every batch. The authors tackle the gap between these "overly optimistic" attack scenarios and the messy reality of cloud-deployed models, asking: How much damage can a realistic attacker actually do?

Methods

Realistic Test-Time Data Poisoning Framework

The authors propose three key innovations to make attacks both realistic and effective:

  1. Surrogate Model Distillation: Since the attacker can't see the live, adapting model, they maintain a "surrogate" model. They distill the target model’s behavior into this surrogate by observing how the live model responds to their queries, allowing them to generate effective gradients for the attack.
  2. Feature Consistency Regularization ($\mathcal{L}_{reg}$): A major finding was that poisoned samples often look like "outliers" in the model's internal feature space. To fix this, the authors added a constraint that forces poisoned samples to have similar feature distributions to benign ones. This makes the poison "in-distribution" and much harder for the model to ignore.
  3. TTA-Aware Objectives: They designed two specific attack goals:
  4. NHE (Notch High Entropy): Maximizes uncertainty while specifically ensuring the model doesn't pick the correct label.
  5. BLE (Balanced Low Entropy): Pushes the model to confidently predict the wrong class in a class-balanced way to avoid triggering diversity-based defenses.

Datasets

The researchers evaluated their methods on standard benchmarks for distribution shift, specifically the "C" (Corrupted) variants of popular datasets:

  • CIFAR10-C & CIFAR100-C: Small-scale images with 15 types of digital corruptions (blur, noise, weather).
  • ImageNet-C: Large-scale, real-world images with similar corruptions.
  • Models: They tested across various architectures, including WideResNet-28, ResNeXt-29, and ResNet-50.

Key Insights and Ideas

Comprehensive Attack Results and Feature Visualization
  • The "In-Distribution" Secret: The most effective way to poison a model isn't to make it "crazy" with noise, but to make the noise look like legitimate data features. By using $\mathcal{L}_{reg}$, the attack success rate jumped significantly because the model "trusted" the poisoned data enough to learn from it (as seen in the T-SNE visualization where poisoned samples blend with benign ones).
  • Surrogates are Sufficient: You don't need to know the exact weights of a model to break it. A distilled surrogate model provides enough information to craft devastating adversarial samples that rival white-box attacks.
  • TTA is Naturally Tougher Than Expected: Many "advanced" TTA methods (like CoTTA or ROID) use techniques like Exponential Moving Averages (EMA) and data augmentation to stay stable. The authors found these aren't just good for accuracy—they are excellent at filtering out the "shock" of poisoned data.

Key Results

The authors' RTTDP attack consistently outperformed previous state-of-the-art poisoning methods (like DIA and TePA) under realistic settings.

  • Impact on Naive TTA: On CIFAR10-C, a "Notch High Entropy" (NHE) attack pushed the error rate of the popular TENT method from 19.7% up to 73.8%.
  • Resilience of Advanced TTA: Methods like CoTTA and ROID proved much harder to crack. Even under heavy poisoning, their error rates often stayed within 2-5% of their "clean" performance, thanks to their internal stability mechanisms.
  • Defense Validation: The study confirmed that confidence thresholding (ignoring samples the model is unsure about) is one of the most effective ways to stop high-entropy poisoning attacks.

Limitations and Future Work

While the paper moves toward realism, it still assumes a grey-box scenario where the attacker knows the starting model and architecture. A true black-box attack (where the attacker knows nothing about the model) remains a challenge.

Additionally, the authors note that while current defenses work well, they weren't designed for security. Future work could involve creating "adversarially robust TTA" that explicitly detects and rejects samples that attempt to shift the model's feature distribution.

Source Code: https://github.com/Gorilla-Lab-SCUT/RTTDP

Summary updated

BibTeX
@inproceedings{su2025adversarial,
  author = {Yongyi Su and Yushu Li and Nanqing Liu and Kui Jia and Xulei Yang and Chuan-Sheng Foo and Xun Xu},
  title = {{On the Adversarial Risk of Test Time Adaptation: An Investigation into Realistic Test-Time Data Poisoning}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=7893vsQenk},
}
Figure