Abstract
This study investigates the applicability of Transformer architectures to raw information security data, specifically URLs and Portable Executable (PE) files. By bypassing traditional manual feature engineering, the authors evaluate whether "end-to-end" learning can match specialized models. The findings reveal that standard NLP pre-training strategies are insufficient for security tasks. However, a novel Balanced Mixed Objective approach—combining classification with auxiliary next-character prediction—enables Transformers to achieve state-of-the-art performance on URL detection.
Introduction
In machine learning for information security (InfoSec), practitioners traditionally rely on expert-driven feature engineering. Extracting specific strings, header information, or byte histograms from malware samples is effective but requires constant maintenance by Subject Matter Experts (SMEs) to counter evolving threats. While Natural Language Processing (NLP) has successfully transitioned to "end-to-end" learning from raw data, InfoSec data presents unique challenges: it lacks the inherent structure of human language and often contains extremely long-range dependencies. This paper assesses the feasibility of using Transformers to bridge this gap, specifically examining the "pre-train then fine-tune" paradigm.
Methodology
The research evaluates Transformers across two distinct data formats:
URL Detection (Short Sequences)
The authors implemented a character-level Transformer utilizing a Balanced Mixed Objective. Unlike standard classification models, this architecture forces the model to simultaneously predict the next character in a URL while determining its maliciousness. An adaptive balancing scheme ensures that neither the classification loss nor the prediction loss dominates the gradients during training.
PE File Analysis (Long Sequences)
To address the massive length of binary files, the study employs an Adaptive Attention Span Transformer. This mechanism allows the model to attend to varying context lengths across different layers, mitigating the quadratic memory overhead typically associated with Transformers and enabling the processing of longer byte sequences.
Datasets
The study utilized two primary datasets:
- URL Dataset: A proprietary Mandiant dataset containing approximately 1 million labeled URLs (180k malicious) and an additional 20-million unlabeled URL corpus for pre-training.
- PE Dataset: The industry-standard EMBER 2018 dataset. For comparison with raw-byte models, files were truncated to the first 4096 bytes, covering the typical PE header.
Key Insights
A critical finding was that the standard NLP "pre-train and fine-tune" strategy failed for URLs. Pre-training on 20 million unlabeled URLs actually hindered performance, suggesting that the "grammar" of a URL does not correlate with its maliciousness as directly as language structure correlates with sentiment.
However, using next-character prediction as an auxiliary loss during the main training phase provided a significant performance boost. This approach encourages the model to fuse sequential context with class information within its hidden states, effectively serving as the "secret sauce" for high-accuracy detection.
Results
The Mixed Objective Transformer demonstrated strong performance across tasks:
- URL Detection: Achieved an AUC of 0.956, matching 1D-CNNs (0.959) and significantly outperforming Random Forests (0.925).
- Malware Detection: On truncated EMBER data, the Byte Transformer reached an AUC of 0.971, comparable to MalConv (0.972) but slightly behind more complex architectures like MG-CNN (0.982).
Conclusion and Future Work
While Transformers can match specialized models without manual feature engineering, scalability remains a primary hurdle. The quadratic scaling of attention mechanisms makes them more compute-intensive than CNNs for large binary files. Future research should explore bi-directional models (e.g., BERT-style masking), sparse attention mechanisms (e.g., Longformer) to handle larger file segments, and the application of these techniques to other InfoSec telemetry like network logs.
Summary updated