Abstract
Cloud Computing plays a pivotal role in facilitating the Internet of Things (IoT) and its diverse applications. However, the prevalence of Cross-Site Scripting (XSS) vulnerabilities poses a significant threat to data security in these environments. Traditional detection methods often rely on manual feature extraction, which is time-consuming and struggles with obfuscated code. This paper proposes CMABLSTM, a character-level bidirectional long short-term memory (Bi-LSTM) network integrated with a multi-head attention mechanism. By analyzing traffic at the character level and leveraging attention to focus on critical features, the model achieves an F1 score of 98.71%, demonstrating high effectiveness in identifying complex XSS attacks.
Introduction
Cross-Site Scripting (XSS) remains one of the most persistent and impactful web security vulnerabilities, consistently ranked in the OWASP Top Ten. In cloud environments, where users frequently interact with remote servers via web browsers, attackers exploit these vulnerabilities to inject malicious scripts.
Traditional security measures, such as rule-based filters, are often bypassed through "obfuscation"—techniques like encoding or rearranging code to evade detection. Furthermore, traditional machine learning models require manual feature engineering, which is labor-intensive and requires deep domain expertise. There is a clear need for an automated, deep-learning-based solution capable of understanding the underlying semantics of malicious scripts regardless of how they are disguised.
The CMABLSTM Model
The proposed CMABLSTM (Character-level Bidirectional LSTM with Multi-Head Attention) model is designed to automatically extract features and understand the context of script sequences through a layered approach.
The architecture consists of several specialized layers:
- Character-Level Embedding: By processing data at the character level rather than the word level, the model avoids being misled by non-standard syntax or "junk" characters used in obfuscation.
- Bi-LSTM Layer: This layer reads character sequences in both forward and backward directions, capturing the context of each character relative to its preceding and subsequent text.
- Multi-Head Attention Layer: This mechanism allows the model to focus on different feature subspaces simultaneously, effectively filtering out noise and highlighting patterns indicative of an attack.
- Global Average Pooling (GAP) & Dropout: These layers condense the extracted features and prevent overfitting, ensuring the model generalizes well to new, unseen attack variants.
Experimental Setup and Results
The study utilized a dataset of 105,470 samples, comprising 74,063 malicious XSS samples and 31,407 benign traffic samples. Data was collected via web crawlers and honeypot logs to reflect real-world conditions. After extensive cleaning to remove duplicates and domain-specific noise, the dataset was split into an 8:2 ratio for training and testing.
The CMABLSTM model demonstrated superior performance compared to both traditional machine learning (like XGBoost and SVM) and standard deep learning architectures. It achieved a Precision of 99.32%, a Recall of 98.11%, and an F1 Score of 98.71%.
Hyperparameter optimization revealed that the model performed optimally with a vector dimension of 128 and 4 attention heads. As shown in the results, the 128-dimension configuration consistently outperformed dimensions of 64 and 256 across all primary metrics. Additionally, the inclusion of the Global Average Pooling layer was found to be critical for maintaining high accuracy compared to configurations without it.
Conclusion
The CMABLSTM model provides a robust defense against XSS attacks in cloud computing environments. By utilizing character-level analysis and multi-head attention, it overcomes the limitations of manual feature engineering and the challenges posed by code obfuscation. Future work will focus on extending this architecture to detect other injection-based vulnerabilities, such as SQL injection and CSRF, and optimizing the model for real-time deployment in high-traffic cloud gateways.
Summary updated