Identifying Adversarial Attacks on Text Classifiers

Zhouhang Xie, Jonathan Brophy, Adam Noack, Wencong You, Kalyani Asthana, Carter Perkins, Sabrina Reis, Sameer Singh, Daniel LowdarXiv 2022

Adversarial attacks on Natural Language Processing (NLP) models pose a significant security risk. By making subtle, often imperceptible changes to input text, attackers can cause state-of-the-art classifiers to produce incorrect outputs. While most research focuses on making models more robust, this paper introduces a complementary forensic approach: attack identification. Instead of merely attempting to ignore perturbations, the authors demonstrate that it is possible to detect if an attack has occurred and identify the specific algorithm used.

The Text Classification Attack Benchmark (TCAB)

To facilitate research in adversarial forensics, the authors released the Text Classification Attack Benchmark (TCAB). This dataset is unprecedented in scale and diversity, containing 1.5 million attack instances. It spans six distinct domains, including sentiment analysis (SST-2, IMDB, Climate Change) and abuse detection (Wikipedia, Hatebase, Civil Comments).

The benchmark includes successful adversarial examples generated by 12 different attack algorithms targeting three major transformer architectures: BERT, RoBERTa, and XLNet. This comprehensive dataset allows researchers to study the unique "fingerprints" left by various automated manipulation techniques.

The TLC Feature Framework

The core of the proposed identification method is the extraction of TLC features, which capture evidence of manipulation from three distinct perspectives:

  1. Text Properties (T): These are surface-level statistics such as average word length, punctuation density, and the frequency of non-ASCII characters. Automated attacks often introduce unusual character distributions.
  2. Language Model Properties (L): Using models like GPT-2 and RoBERTa, the system measures the "naturalness" of the text. Adversarial perturbations frequently result in awkward phrasing or low-probability token sequences that these models can flag as suspicious.
  3. Target Classifier Properties (C): This category captures the internal state of the victim model, including node activations and gradients. These features reveal how the model's internal logic is being disrupted by the input.
The attack identification pipeline extracts TLC features to feed into a detection or labeling classifier.

These features are aggregated into a fixed-length vector and processed by standard machine learning classifiers, such as LightGBM, to perform binary attack detection and multiclass attack labeling.

Key Results and Insights

The researchers found that adversarial attacks leave distinct signatures that are highly identifiable. The TLC-based models significantly outperformed baseline approaches:

  • Detection Performance: The models achieved between 84% and 97% accuracy in distinguishing clean text from adversarial examples. Notably, the detectors generalized well; a model trained on attacks against BERT could still detect attacks aimed at XLNet with high reliability.
  • Labeling Performance: Identifying which of the 12 specific algorithms was used is a more complex task, yet the models achieved 45% to 71% accuracy. This represents a substantial leap over the random baseline of approximately 8.3%.
Labeling accuracy across various datasets and feature combinations, showing the impact of combining Text, Language, and Classifier features.

Analysis revealed that Language Model (L) features are particularly effective at spotting word-level substitutions, which often break semantic flow. Meanwhile, Classifier (C) features and BERT embeddings proved most influential for the multiclass labeling task, as they capture the specific ways different algorithms interact with the target model's architecture.

Conclusion and Future Directions

This forensic approach provides a new layer of defense for NLP systems. By identifying the specific tools used by an attacker, platform moderators can gain insights into the sophistication and intent of adversarial campaigns. Future work will focus on improving domain-agnostic detection and testing these methods against human-generated adversarial examples in real-world environments.

Summary updated

BibTeX
@misc{xie2022identifying,
  author = {Zhouhang Xie and Jonathan Brophy and Adam Noack and Wencong You and Kalyani Asthana and Carter Perkins and Sabrina Reis and Sameer Singh and Daniel Lowd},
  title = {{Identifying Adversarial Attacks on Text Classifiers}},
  year = {2022},
  eprint = {2201.08555},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2201.08555},
}
Figure