XSS Attack Detection Method Based on CNN-BiLSTM-Attention
LI Zhi-ping, Fangzheng Liu, Zhaojun Gu, Yun Liu · Applied Sciences · 2025
Cross-site scripting (XSS) is one of the most common security threats to web applications, posing a serious challenge to network information security. Targetting the limitations of traditional detection methods in identifying complex XSS attacks, this paper proposes a hybrid deep learning model that integrates convolutional neural network (CNN), bidirectional long short-term memory network (BiLSTM), and attention mechanism. The model captures local attack feature patterns through the CNN layer, learns contextual long-term dependencies through the BiLSTM layer, and introduces a multi-head attention mechanism to enhance the focus on key attack vectors. In the preprocessing stage, an improved regular word segmentation algorithm is used to construct semantic feature vectors, which effectively solves the problem of text feature representation of XSS attacks. Experimental results show that compared with the baseline method, the proposed method achieves an accuracy of 0.9938, a precision of 0.9936, a recall of 0.9936, and an F1-score of 0.9937 on real datasets. This shows that by integrating CNN and BiLSTM features and combining the attention mechanism, the model can effectively deal with complex XSS attacks.