Skip to main content
QUICK REVIEW

[Paper Review] MalBERT: Using Transformers for Cybersecurity and Malicious Software Detection

Abir Rahali, Moulay A. Akhloufi|arXiv (Cornell University)|Mar 5, 2021
Advanced Malware Detection TechniquesComputer Science31 references23 citations
TL;DR

This paper proposes MalBERT, a novel Transformer-based model that treats Android app source code as text for static malware detection. By fine-tuning BERT on preprocessed code features—including permissions, intents, and activities—it achieves 97.61% accuracy in binary classification and 91.02% in multi-class malware categorization, outperforming LSTM and other Transformer baselines.

ABSTRACT

In recent years we have witnessed an increase in cyber threats and malicious software attacks on different platforms with important consequences to persons and businesses. It has become critical to find automated machine learning techniques to proactively defend against malware. Transformers, a category of attention-based deep learning techniques, have recently shown impressive results in solving different tasks mainly related to the field of Natural Language Processing (NLP). In this paper, we propose the use of a Transformers' architecture to automatically detect malicious software. We propose a model based on BERT (Bidirectional Encoder Representations from Transformers) which performs a static analysis on the source code of Android applications using preprocessed features to characterize existing malware and classify it into different representative malware categories. The obtained results are promising and show the high performance obtained by Transformer-based models for malicious software detection.

Motivation & Objective

  • Address the growing threat of sophisticated malware that evades traditional detection methods.
  • Explore the potential of Transformer-based models, particularly BERT, for static analysis of Android malware.
  • Develop a novel feature representation by modeling source code as a sequence of text tokens (e.g., permissions, intents, activities) for NLP-style classification.
  • Demonstrate that pre-trained language models can outperform RNN-based models like LSTM in malware detection tasks.
  • Release a preprocessed Android malware dataset with 11 categories to support future research.

Proposed method

  • Preprocess Android app source code to extract and represent key features such as permissions, intents, activities, and API calls as a textual sequence.
  • Treat the preprocessed code features as natural language input and fine-tune a pre-trained BERT model for both binary (malicious/benign) and multi-class (11 malware categories) classification.
  • Use attention mechanisms in the Transformer architecture to capture long-range dependencies and critical patterns in the code structure.
  • Apply transfer learning by fine-tuning the BERT model on a public Android malware dataset (Androzoo) with 11 malware categories.
  • Evaluate performance using accuracy, Matthews Correlation Coefficient (MCC), F1-score, and cross-entropy loss on a held-out test set.
  • Compare BERT against baseline models including LSTM, XLNet, RoBERTa, and DistilBERT to assess relative performance.

Experimental results

Research questions

  • RQ1Can a pre-trained Transformer model like BERT be effectively adapted for static malware detection using source code as text input?
  • RQ2How does BERT-based malware detection compare in performance to traditional RNN-based models like LSTM and other pre-trained NLP models?
  • RQ3What is the impact of different pre-trained language models (e.g., XLNet, RoBERTa, DistilBERT) on malware classification accuracy and generalization?
  • RQ4Does modeling Android source code as a sequence of tokens (e.g., permissions, intents) enable effective representation learning for malware classification?
  • RQ5Can fine-tuned BERT achieve high performance in both binary and multi-class malware detection tasks on a real-world Android malware dataset?

Key findings

  • BERT achieved the highest binary classification accuracy of 97.61%, significantly outperforming LSTM (94.05%), XLNet (95.79%), RoBERTa (95.33%), and DistilBERT (95.42%).
  • In multi-class malware classification across 11 categories, BERT achieved 91.02% accuracy, outperforming all baselines, including LSTM (85.07%) and DistilBERT (59.81%).
  • BERT also achieved the highest Matthews Correlation Coefficient (MCC) of 0.9559 in binary classification, indicating strong performance on imbalanced data.
  • The model required only two epochs of fine-tuning before loss began to increase, indicating efficient convergence with optimal learning rate.
  • Cross-entropy loss was minimized for BERT (0.1274) in binary classification, showing better model calibration than other models.
  • The study demonstrates that source code can be effectively represented as a sequence of text tokens for NLP-based malware detection, enabling high-performance classification.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.