journal article·2025-08-13Open access

XSS Attack Detection Method Based on CNN-BiLSTM-Attention

Zhiping Li, Fangzheng Liu, Zhaojun Gu, Yun Liu

Applied Sciences· Volume 15· Issue 16

Abstract

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.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Web Application Security Vulnerabilities · Network Security and Intrusion Detection · Advanced Malware Detection Techniques

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

Information Security Evaluation Center, Civil Aviation University of China, Tianjin 300300, China

College of Computer Science and Technology, Civil Aviation University of China, Tianjin 300300, China

Digital Government Affairs Office, Shandong Big Data Center, Jinan 250101, China

Funding

National Natural Science Foundation of China · Fundamental Research Business Funds for Central Universities of Civil Aviation University of China

References (26)

Show source-provided references
1. Detection of cross-site scripting (XSS) attacks using machine learning techniques: A review10.1007/s10462-023-10433-3 ↗
2. Hussainy, A.S., Khalifa, M.A., Elsayed, A., Hussien, A., and Razek, M.A. Deep learning toward preventing web attacks. Proceedings of the 2022 5th International conference on computing and informatics (ICCI), New Cairo, Egypt, 9–10 March 2022.10.1109/ICCI54321.2022.9756057 ↗
3. Web attack detection using deep learning models10.1016/j.matpr.2022.03.348 ↗
4. Nilavarasan, G., and Balachander, T. XSS attack detection using convolution neural network. Proceedings of the 2023 International Conference on Artificial Intelligence and Knowledge Discovery in Concurrent Engineering (ICECONF), Chennai, India, 5–7 January 2023.10.1109/ICECONF57129.2023.10083807 ↗
5. Joshi, I.S., and Kiratsata, H.J. Cross-Site Scripting Recognition Using LSTM Model. Proceedings of the International Conference on Intelligent Computing and Communication, Hyderabad, India, 18–19 November 2022.10.1007/978-981-99-1588-0_1 ↗
6. An LSTM based cross-site scripting attack detection scheme for Cloud Computing environments10.1186/s13677-023-00483-x ↗
7. Peng, B., Xiao, X., and Wang, J. Cross-site scripting attack detection method based on transformer. Proceedings of the 2022 IEEE 8th International Conference on Computer and Communications (ICCC), Chengdu, China, 9–12 December 2022.10.1109/ICCC56324.2022.10065892 ↗
8. Wan, S., Xian, B., Wang, Y., and Lu, J. Methods for Detecting XSS Attacks Based on BERT and BiLSTM. Proceedings of the 2024 8th International Conference on Management Engineering, Software Engineering and Service Sciences (ICMSS), Wuhan, China, 12–14 January 2024.10.1109/ICMSS61211.2024.00008 ↗
9. A Vulnerability Detection Method for Internet Cross-site Scripting Based on Relationship Diagram Convolutional Networks
10. Jovanovic, N., Kruegel, C., and Kirda, E. Pixy: A static analysis tool for detecting web application vulnerabilities. Proceedings of the 2006 IEEE Symposium on Security and Privacy (S&P’06), Berkeley/Oakland, CA, USA, 21–24 May 2006.10.1109/SP.2006.29 ↗
11. XSS-SAFE: A server-side approach to detect and mitigate cross-site scripting (XSS) attacks in JavaScript code10.1007/s13369-015-1891-7 ↗
12. Wang, R., Jia, X., Li, Q., and Zhang, S. Machine learning based cross-site scripting detection in online social network. Proceedings of the 2014 IEEE Intl Conf on High Performance Computing and Communications, 2014 IEEE 6th Intl Symp on Cyberspace Safety and Security, 2014 IEEE 11th Intl Conf on Embedded Software and Syst (HPCC, CSS, ICESS), Paris, France, 20–22 August 2014.10.1109/HPCC.2014.137 ↗
13. XSSClassifier: An efficient XSS attack detection approach based on machine learning classifier on SNSs
14. Current state of research on cross-site scripting (XSS)—A systematic literature review10.1016/j.infsof.2014.07.010 ↗
15. Multiple-path testing for cross site scripting using genetic algorithms10.1016/j.sysarc.2015.11.001 ↗
16. Fang, Y., Li, Y., Liu, L., and Huang, C. (2018, January 12–14). DeepXSS: Cross site scripting detection based on deep learning. Proceedings of the 2018 International Conference on Computing and Artificial Intelligence, Chengdu, China.10.1145/3194452.3194469 ↗
17. Lei, L., Chen, M., He, C., and Li, D. XSS detection technology based on LSTM-attention. Proceedings of the 2020 5th International Conference on Control, Robotics and Cybernetics (CRC), Wuhan, China, 16–18 October 2020.10.1109/CRC51253.2020.9253484 ↗
18. Yan, H., Feng, L., Yu, Y., Liao, W., Feng, L., Zhang, J., Liu, D., Zou, Y., Liu, C., and Qu, L. (2022). Cross-site scripting attack detection based on a modified convolution neural network. Front. Comput. Neurosci., 16.10.3389/fncom.2022.981739 ↗
19. Stiawan, D., Bardadi, A., Afifah, N., Melinda, L., Heryanto, A., Septian, T.W., Idris, M.Y., Subroto, I.M.I., and Budiarto, R. (2023). An Improved LSTM-PCA Ensemble Classifier for SQL Injection and XSS Attack Detection. Comput. Syst. Sci. Eng., 46.10.32604/csse.2023.034047 ↗
20. Farea, A.A., Wang, C., Farea, E., and Alawi, A.B. Cross-site scripting (XSS) and SQL injection attacks multi-classification using bidirectional LSTM recurrent neural network. Proceedings of the 2021 IEEE International Conference on Progress in Informatics and Computing (PIC), Shanghai, China, 17–19 December 2021.10.1109/PIC53636.2021.9687064 ↗
21. Bidirectional recurrent neural networks10.1109/78.650093 ↗
22. Mereani, F.A., and Howe, J.M. Detecting cross-site scripting attacks using machine learning. Proceedings of the International Conference on Advanced Machine Learning Technologies and Applications, Cairo, Egypt, 22–24 February 2018.10.1007/978-3-319-74690-6_20 ↗
23. What accuracy statistics really measure10.1049/ip-sen:20010506 ↗
24. The relationship between recall and precision10.1002/(SICI)1097-4571(199401)45:1<12::AID-ASI2>3.0.CO;2-L ↗
25. Yacouby, R., and Axman, D. (2020, January 20). Probabilistic extension of precision, recall, and f1 score for more thorough evaluation of classification models. Proceedings of the First Workshop on Evaluation and Comparison of NLP Systems, Online.10.18653/v1/2020.eval4nlp-1.9 ↗
26. Dropout: A simple way to prevent neural networks from overfitting