SecEncoder: Logs are All You Need in Security

Muhammed Fatih Bulut, Yingqi Liu, Naveed Ahmad, Maximilian Turner, Sami Ait Ouahmane, Cameron Andrews, Lloyd G. GreenwaldarXiv 2024 · DOI

Abstract

SecEncoder is a specialized language model (SLM) pretrained from scratch on a massive 1-terabyte corpus of security logs. Unlike general-purpose models trained on natural language, SecEncoder learns the unique structural and semantic patterns of system telemetry. This paper demonstrates that by treating logs as a native language, SecEncoder consistently outperforms state-of-the-art models like BERT and OpenAI’s embeddings on critical security tasks, including anomaly detection, incident prioritization, and log search.

Introduction

General-purpose Large Language Models (LLMs) are typically trained on human-centric data such as Wikipedia and literature. While proficient in natural language processing, these models often struggle with the "alien" syntax of security logs—data characterized by IP addresses, hex codes, and nested JSON structures. Standard tokenizers frequently fragment these specialized terms into meaningless sub-words, stripping away the context required for effective cyber-threat detection. Furthermore, fine-tuning general models on security data often results in "catastrophic forgetting." To address these challenges, we introduce SecEncoder, a model designed to speak "Log" as its native tongue.

Methods and Architecture

SecEncoder utilizes the DeBERTa-v2 encoder-only architecture, optimized for generating high-quality mathematical representations (embeddings) rather than generative text.

Custom Tokenization

A primary innovation is the Byte-Pair Encoding (BPE) tokenizer trained on 100GB of raw logs. This allows the model to recognize security-specific tokens (e.g., TTY, USER, or IP segments) as single units, preserving the semantic integrity of the log entries.

Table 1: Tokenization comparison showing how SecEncoder preserves the semantic integrity of security log keywords compared to general-purpose LLMs.

Content-Aware Training

The model employs a customized Masked Language Modeling (MLM) loss function. By ignoring structural delimiters (e.g., braces, quotes) and focusing on actual content tokens, the training process achieves significantly higher efficiency and embedding quality. The model was scaled across four sizes, ranging from "Base" (110M parameters) to "xxLarge" (1.1B parameters), using 64 NVIDIA A100 GPUs.

Datasets and Evaluation

The pretraining corpus consisted of 1TB of raw data, deduplicated to 270GB (77 billion tokens), encompassing private Microsoft telemetry (Windows, Linux, Cloud) and public datasets like LogHub. Evaluation was conducted against industry-standard logs (HDFS, BGL, Thunderbird) and real-world incident data.

Key Results

SecEncoder demonstrated superior performance across multiple benchmarks compared to natural language baselines:

  • Anomaly Detection: Achieved a 20% improvement in F1 score (0.36 vs 0.30) over natural-language models in unsupervised settings.
  • Incident Classification: Reduced manual analyst workload by 53.6% in real-world tests while maintaining zero mis-suppression of true positive alerts.
  • Log Search: Showed a marked ability to identify similar logs across disparate systems, a critical capability for tracing lateral movement.
Table 2: Comparative performance of SecEncoder variants against natural language (NL) baselines in log similarity and search benchmarks.

Discussion and Future Work

The success of SecEncoder suggests that security logs possess a logical structure that can be modeled as effectively as natural language. Interestingly, the model also outperformed NL-based models in retrieving natural language threat intelligence, indicating the development of a deep "security logic." Future research will focus on increasing data diversity, exploring model distillation for real-time deployment, and further scaling parameters to investigate emergent properties in security telemetry.

Summary updated

BibTeX
@misc{bulut2024secencoder,
  author = {Muhammed Fatih Bulut and Yingqi Liu and Naveed Ahmad and Maximilian Turner and Sami Ait Ouahmane and Cameron Andrews and Lloyd G. Greenwald},
  title = {{SecEncoder: Logs are All You Need in Security}},
  year = {2024},
  eprint = {2411.07528},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.07528},
}
Figure