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.
- Sequence Model: Represents the execution flow as a linear chronological list of function calls, similar to natural language sentences.
- 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.
- 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.
- 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