Abstract
Recent research has suggested that there are clear differences in the language used in the Dark Web compared to that of the Surface Web. As studies on the Dark Web commonly require textual analysis of the domain, language models specific to the Dark Web may provide valuable insights to researchers. In this work, we introduce DarkBERT, a language model pretrained on Dark Web data. We describe the steps taken to filter and compile the text data used to train DarkBERT to combat the extreme lexical and structural diversity of the Dark Web that may be detrimental to building a proper representation of the domain. We evaluate DarkBERT and its vanilla counterpart along with other widely used language models to validate the benefits that a Dark Web domain specific model offers in various use cases. Our evaluations show that DarkBERT outperforms current language models and may serve as a valuable resource for future research on the Dark Web.
Introduction
The "Surface Web"—the part of the internet indexed by search engines—is where most AI models like BERT and GPT learn to communicate. However, the Dark Web is a fundamentally different environment. It is characterized by identity obscurity, specialized overlay networks like Tor, and a high prevalence of illegal activities ranging from drug sales to data leaks.
Existing Natural Language Processing (NLP) tools often struggle with Dark Web content because the language used there is unique, filled with specialized slang, technical jargon for illicit services, and highly unstructured text. Using a model trained on Wikipedia to analyze a Dark Web hacking forum is akin to using a Victorian etiquette manual to understand modern street slang—the context and vocabulary simply do not align. To bridge this gap, we present DarkBERT, a model specifically adapted for the linguistic nuances of the internet's underbelly.
Methodology
The development of DarkBERT followed a rigorous pipeline designed to handle the "extreme lexical and structural diversity" inherent in Dark Web data. This process ensures that the model learns meaningful semantic representations rather than getting bogged down by noise.
As illustrated in the pipeline above, the process involves five key stages:
- Data Collection: Crawling the Tor network to compile a massive text corpus of approximately 6.1 million pages.
- Data Filtering: Removing low-information pages (such as error messages) and deduplicating content to refine the training set from 20.79 GB down to 5.83 GB.
- Text Preprocessing: Applying Identifier Masking to replace sensitive information—like IP addresses, URLs, and cryptocurrency wallets—with special tokens. Additionally, "lengthy words" (over 38 characters), which are typically hashes or code snippets, are masked to prevent them from cluttering the vocabulary.
- DarkBERT Pretraining: Using the
roberta-basearchitecture as a starting point and continuing pretraining on the refined Dark Web corpus. This resulted in two versions: DarkBERT${raw}$ and DarkBERT${preproc}$. - Evaluation: Testing the model against real-world cybersecurity use cases.
Key Insights and Results
A primary finding of this research is that domain-specific preprocessing is paramount. Unlike general web data, Dark Web data is so noisy that aggressive masking of non-semantic strings (like IPs and hashes) actually improves performance.
As shown in the training loss curves, the preprocessed version of the model converges more effectively, indicating that the model can focus its "attention" on meaningful linguistic patterns once the noise is removed.
Empirical results across various tasks confirm DarkBERT's superiority:
- Activity Classification: DarkBERT achieved the highest performance on benchmarks like DUTA-10K, reaching an F1 score of 80.01 compared to RoBERTa’s 78.63.
- Ransomware Detection: In identifying sites where ransomware groups publish stolen data, DarkBERT$_{preproc}$ achieved an F1 score of 84.11, vastly outperforming vanilla RoBERTa (44.31 F1).
- Threat Detection: When identifying high-priority threads in hacking forums, DarkBERT reached a 54.17 F1 score, while general-purpose models like BERT hovered around 28-29. This highlights the model's ability to distinguish between idle "chatter" and actual threats.
Furthermore, in "fill-mask" semantic tests, DarkBERT correctly identified drug-related terms like "pills" and "oxy" in context, whereas general BERT suggested unrelated terms like "champion" or "singer."
Conclusion
DarkBERT demonstrates that the linguistic gap between the Surface and Dark Web is wide enough to necessitate domain-specific models for Cyber Threat Intelligence (CTI). While currently English-centric, future iterations aim to include multilingual support to address the global nature of cybercrime. To prevent misuse, the researchers are releasing the preprocessed model for academic and research purposes upon request.
Summary updated