[Paper Review] Using BERT Encoding to Tackle the Mad-lib Attack in SMS Spam Detection.
This paper investigates BERT's robustness against Mad-lib attacks—where spam messages are obfuscated by synonym substitution—to evade detection. Using a dataset of 5,572 SMS spam messages, it shows that BERT maintains 96% balanced accuracy even with an average of 1.82 substituted words per message, while traditional models (BoW and TFIDF) degrade to chance performance, demonstrating BERT's superior semantic resilience to synonym-based evasion attacks.
One of the stratagems used to deceive spam filters is to substitute vocables with synonyms or similar words that turn the message unrecognisable by the detection algorithms. In this paper we investigate whether the recent development of language models sensitive to the semantics and context of words, such as Google's BERT, may be useful to overcome this adversarial attack (called as per the word substitution game). Using a dataset of 5572 SMS spam messages, we first established a baseline of detection performance using widely known document representation models (BoW and TFIDF) and the novel BERT model, coupled with a variety of classification algorithms (Decision Tree, kNN, SVM, Logistic Regression, Naive Bayes, Multilayer Perceptron). Then, we built a thesaurus of the vocabulary contained in these messages, and set up a Mad-lib attack experiment in which we modified each message of a held out subset of data (not used in the baseline experiment) with different rates of substitution of original words with synonyms from the thesaurus. Lastly, we evaluated the detection performance of the three representation models (BoW, TFIDF and BERT) coupled with the best classifier from the baseline experiment (SVM). We found that the classic models achieved a 94% Balanced Accuracy (BA) in the original dataset, whereas the BERT model obtained 96%. On the other hand, the Mad-lib attack experiment showed that BERT encodings manage to maintain a similar BA performance of 96% with an average substitution rate of 1.82 words per message, and 95% with 3.34 words substituted per message. In contrast, the BA performance of the BoW and TFIDF encoders dropped to chance. These results hint at the potential advantage of BERT models to combat these type of ingenious attacks, offsetting to some extent for the inappropriate use of semantic relationships in language.
Motivation & Objective
- To evaluate the effectiveness of BERT embeddings in detecting SMS spam under adversarial synonym substitution attacks.
- To compare BERT's performance against traditional text representation models (BoW and TFIDF) under such attacks.
- To assess whether contextual language models like BERT can maintain high detection accuracy when messages are semantically altered using synonym substitution.
- To identify the limits of robustness of BERT in handling adversarial perturbations in spam detection.
Proposed method
- Constructed a thesaurus from the vocabulary in the SMS spam dataset to enable controlled synonym substitution.
- Trained and evaluated multiple classifiers (SVM, Logistic Regression, etc.) on BoW, TFIDF, and BERT embeddings to establish baseline performance.
- Generated a held-out test set where each message was modified with varying rates of synonym substitution to simulate Mad-lib attacks.
- Measured detection performance using balanced accuracy (BA) across all models and attack levels.
- Selected SVM as the best-performing classifier from the baseline experiment for use in the attack evaluation phase.
- Evaluated the robustness of each representation model (BoW, TFIDF, BERT) under increasing substitution rates in the Mad-lib attack.
Experimental results
Research questions
- RQ1Can BERT embeddings maintain high spam detection accuracy when messages are altered via synonym substitution (Mad-lib attack)?
- RQ2How does the performance of traditional models like BoW and TFIDF degrade under synonym-based adversarial attacks compared to BERT?
- RQ3At what average substitution rate does BERT's detection performance begin to decline significantly?
- RQ4What is the threshold of semantic perturbation beyond which BERT still outperforms classical models in spam detection?
Key findings
- BERT achieved a balanced accuracy of 96% on the original dataset, outperforming BoW and TFIDF, which reached 94%.
- Under Mad-lib attacks with an average of 1.82 substituted words per message, BERT maintained a balanced accuracy of 96%.
- With 3.34 substituted words per message on average, BERT's balanced accuracy remained at 95%, indicating strong robustness.
- In contrast, BoW and TFIDF models' balanced accuracy dropped to chance levels under the same attack conditions.
- The results indicate that BERT's contextual understanding enables it to recognize spam despite semantic obfuscation through synonym substitution.
- The study demonstrates that BERT models are more resilient to synonym-based adversarial attacks than traditional bag-of-words and TFIDF representations.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.