Beyond Detection: A Comprehensive Benchmark and Study on Representation Learning for Fine-Grained Webshell Family Classification

Feijiang HanarXiv 2025 · DOI · arXiv

Beyond Detection: A Comprehensive Benchmark and Study on Representation Learning for Fine-Grained Webshell Family Classification

Abstract

Webshells represent a critical threat to server security, often serving as the primary tool for maintaining persistent access. While binary detection of webshells has matured, fine-grained classification into specific malware families remains a challenge due to sophisticated obfuscation techniques. This paper presents a comprehensive benchmark for webshell family classification, leveraging dynamic function call traces and structural representation learning. Our findings indicate that structural abstractions—specifically graphs and trees—coupled with Graph Neural Networks (GNNs), significantly outperform traditional sequence-based models in identifying malware lineage.

Introduction: The Need for Fine-Grained Classification

Webshells are malicious scripts uploaded to web servers to provide attackers with remote control. Traditional security measures focus on binary detection: determining whether a file is a webshell or not. However, this "yes/no" approach is insufficient for modern incident response. Identifying the specific family or lineage of a webshell allows security teams to understand an adversary's tactics, techniques, and procedures (TTPs), enabling a more proactive and targeted defense.

The primary obstacles to accurate classification are code obfuscation and the scarcity of labeled datasets. Attackers frequently use encryption and dynamic code generation to hide malicious intent. Furthermore, the rapid evolution of malware makes it difficult to maintain up-to-date, large-scale datasets for training classification models.

Methodology: From Dynamic Traces to Structural Models

To overcome static obfuscation, the researchers employ dynamic tracing, executing webshells in a secure sandbox to record actual function calls. This behavioral log is then transformed into three distinct structural representations to capture different levels of program logic.

Comparison of Sequence, Graph, and Tree models for webshell representation.
  1. Sequence Model: Represents the execution flow as a linear chronological list of function calls, similar to natural language sentences.
  2. Graph Model (Function Call Graph - FCG): Provides an aggregate view of the relationships between functions, where nodes represent functions and edges represent call relationships, regardless of the order.
  3. Tree Model (Function Call Tree - FCT): A hierarchical structure that preserves both the execution path and the calling context, offering the most granular view of the program's behavior.

To address data scarcity, the study utilizes LLM-powered augmentation. Large Language Models are used to synthesize behaviorally consistent variants of known webshell families and simulate "zero-day" threats by blending characteristics from multiple lineages.

Experimental Setup and Datasets

The benchmark utilizes four datasets (DS1-DS4) of increasing complexity. DS1 contains 452 samples across 21 families, while DS4 scales to 1,617 samples across 81 families, including 28 outlier "zero-day" variants. These datasets provide a rigorous testing ground for both supervised classification and unsupervised clustering.

Key Results and Insights

The benchmarking results reveal a clear hierarchy in model performance. Structural representations (graphs and trees) consistently outperformed sequence-based methods.

Performance metrics for various representation methods on Dataset 4.
  • The Superiority of Structure: While advanced NLP models like BERT are effective for text, they struggle with the non-linear logic of malware. Structural models capture the control-flow topology that obfuscation cannot easily hide.
  • Context Matters: Tree-based models often surpassed graph-based ones because the Function Call Tree (FCT) preserves the specific context of a call. For instance, the function eval() may serve different purposes depending on its caller; a tree captures this distinction, whereas a graph merges them.
  • GNNs as the Premier Architecture: Graph Neural Networks, particularly Graph Attention Networks (GAT), emerged as the top performers. GATs can learn to prioritize diagnostically significant functions (e.g., system, base64_decode) while filtering out "noise" or junk code inserted by attackers.

As shown in the results table, structural methods like GNNs and Tree Kernels achieved F1-scores exceeding 0.9 on the most complex dataset (DS4), demonstrating high precision even in the presence of significant noise and family diversity.

Conclusion and Future Directions

This research demonstrates that shifting from syntax-based detection to structure-based representation learning is key to effective webshell family classification. By abstracting behavior into graphs and trees, models can bypass surface-level obfuscation to identify the underlying logic of malware.

Future work will focus on refining these structural abstractions, improving the efficiency of human-in-the-loop data verification, and extending these techniques to other malware domains beyond webshells.

Summary updated

Abstract

Malicious WebShells pose a significant and evolving threat by compromising critical digital infrastructures and endangering public services in sectors such as healthcare and finance. While the research community has made significant progress in WebShell detection (i.e., distinguishing malicious samples from benign ones), we argue that it is time to transition from passive detection to in-depth analysis and proactive defense. One promising direction is the automation of WebShell family classification, which involves identifying the specific malware lineage in order to understand an adversary's tactics and enable a precise, rapid response. This crucial task, however, remains a largely unexplored area that currently relies on slow, manual expert analysis. To address this gap, we present the first systematic study to automate WebShell family classification. Our method begins with extracting dynamic function call traces to capture inherent behaviors that are resistant to common encryption and obfuscation. To enhance the scale and diversity of our dataset for a more stable evaluation, we augment these real-world traces with new variants synthesized by Large Language Models. These augmented traces are then abstracted into sequences, graphs, and trees, providing a foundation to benchmark a comprehensive suite of representation methods. Our evaluation spans classic sequence-based embeddings (CBOW, GloVe), transformers (BERT, SimCSE), and a range of structure-aware algorithms, including Graph Kernels, Graph Edit Distance, Graph2Vec, and various Graph Neural Networks. Through extensive experiments on four real-world, family-annotated datasets under both supervised and unsupervised settings, we establish a robust baseline and provide practical insights into the most effective combinations of data abstractions, representation models, and learning paradigms for this challenge.
BibTeX
@misc{han2025beyond,
  author = {Feijiang Han},
  title = {{Beyond Detection: A Comprehensive Benchmark and Study on Representation Learning for Fine-Grained Webshell Family Classification}},
  year = {2025},
  eprint = {2512.05288},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.05288},
}
Figure