CyNER: A Python Library for Cybersecurity Named Entity Recognition

Md Tanvirul Alam, Dipkamal Bhusal, Youngja Park, Nidhi RastogiarXiv 2022 · DOI

Introduction

The rapid expansion of Open Cyber Threat Intelligence (OpenCTI)—encompassing security blogs, dark web forums, and official bulletins—presents a significant challenge for Security Operations Center (SOC) analysts. While this data contains critical insights, it is predominantly unstructured. Traditional Named Entity Recognition (NER) tools, such as generic models from spaCy or Flair, often lack the domain-specific knowledge required to identify entities like "Malware" or "System" accurately. Furthermore, while structured databases like MITRE ATT&CK exist, they struggle to extract entities from complex natural language narratives. CyNER is an open-source Python library designed to bridge this gap by providing a robust framework for extracting actionable intelligence from unstructured cybersecurity reports.

Methodology

CyNER utilizes a hybrid, modular architecture that integrates three distinct approaches to entity extraction: transformer-based models, heuristic-based detection, and generic NER tools.

CyNER System Architecture

The core of the system is a Priority Setting mechanism. This allows users to resolve overlaps between different extraction engines. By default, the library prioritizes Heuristic models (which use regular expressions for rigid formats like IPv4 addresses or CVE IDs), followed by fine-tuned Transformer models, and finally generic NLP models (Flair and spaCy) for standard entities like "Location" or "Person." This "HTFS" (Heuristic-Transformer-Flair-Spacy) logic ensures that high-fidelity indicators are preserved while leveraging the contextual understanding of deep learning models.

Dataset Development

To address the lack of specialized benchmarking data, the authors developed a new manually-labeled dataset. This corpus consists of approximately 60 high-quality threat reports sourced from the MITRE ATT&CK website (2018–2021). The dataset focuses on Android malware but employs a generic labeling schema covering five core classes: Malware, Indicator, System, Organization, and Vulnerability. Annotated using the BRAT tool, the final dataset contains 106,991 tokens and 4,530 tagged entities.

Experimental Results

The researchers benchmarked several transformer architectures to identify the optimal engine for CyNER. The evaluation included BERT, RoBERTa, and XLM-RoBERTa models.

Performance comparison of various transformer models

As shown in the results, XLM-RoBERTa-large emerged as the top performer, achieving an average F1-score of 76.66%. A notable finding was that multilingual models like XLM-RoBERTa significantly outperformed standard English-only models, likely due to their ability to capture the technical nuances of cybersecurity terminology. In contrast, standard RoBERTa models performed poorly, with F1-scores around 39%, underscoring the necessity of domain-specific fine-tuning.

Class-specific analysis revealed that the model was particularly effective at identifying Vulnerabilities (88.89% F1) and Indicators (82.27% F1). The Organization class proved the most challenging (64.98% F1), primarily due to the inherent ambiguity between threat actors, security firms, and victim organizations.

Conclusion and Future Work

CyNER demonstrates that a hybrid approach—combining the precision of heuristics with the contextual power of transformers—is essential for effective cybersecurity NER. While the current library provides a strong foundation, future work will focus on expanding the dataset beyond Android-centric reports to include a broader range of threats, such as cloud and IoT infrastructure attacks. Additionally, refining the distinction between different roles of organizations within threat narratives remains a priority for future development.

Summary updated

BibTeX
@misc{alam2022cyner,
  author = {Md Tanvirul Alam and Dipkamal Bhusal and Youngja Park and Nidhi Rastogi},
  title = {{CyNER: A Python Library for Cybersecurity Named Entity Recognition}},
  year = {2022},
  eprint = {2204.05754},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.05754},
}
Figure