Accuracy–Efficiency Trade-offs of Machine Learning Algorithms for SQL Injection and XSS Detection: Execution Time and Training-Set Augmentation

Volume 28 ,Issue 2 ,November 2026 ,Pages 221-245

Authors

Danial Muhammed 1

1 University of Sulaimani, Computer Department, Sulaimani, Iraq

DOI logo 10.17656/sujpas.1243

Keywords

Abstract


Web applications are susceptible to script-based attacks such as SQL injection (SQLi) and cross-site scripting (XSS). However, the tradeoff between computational complexity and detection accuracy is still not well understood. We compare K-Nearest Neighbors (KNN), Naïve Bayes, Logistic Regression, Support Vector Machine (SVM), and XGBoost in training, prediction and classification stages. We introduce the Script Attack Classification Dataset (SACD), a cleaned and merged version of two publicly available Kaggle datasets, comprising 82,432 labeled scripts (31,334 malicious, 51,098 benign). We encoded scripts using TF-IDF (1,000 features), selected hyperparameters via 5-fold cross-validation, and tested each model over 30 stratified 80/20 splits, with and without augmenting the training split only (synonym replacement, noise injection, word shuffling; 65,945 → 263,780 samples), so that no augmented variant entered the test data. Differences were evaluated using the Nadeau-Bengio corrected paired t-test, Bonferroni correction and Cohen’s d_z. XGBoost without augmentation produced the highest F1-score (99.12%), slightly but significantly higher than SVM (98.99%) and Logistic Regression (99.00%). KNN (98.48% in 29 of 30 runs) and Naïve Bayes (97.45%) followed. Augmentation increased training time up to 6.7 times and KNN prediction time from 21.9 seconds to 98.7 seconds but changed F1 by at most 0.23 percentage points, with no significant change after correction. Logistic Regression offers the best accuracy-efficiency trade-off for real-time deployment, XGBoost suits cases where maximum accuracy is worth the increased training time, and text-oriented augmentation adds computational overhead without improving detection. Although XGBoost took ~12 times longer to train than Logistic Regression (4.41 s vs. 0.37

References


  1. Alahmadi, M., Alkhraan, N., & BinSaeedan, W., (2022): MPSAutodetect: A malicious PowerShell script detection model based on stacked denoising auto-encoder. Computers & Security, 116, 102658. https://doi.org/10.1016/j.cose.2022.102658
  2. Alghawazi, M., Alghazzawi, D., & Alarifi, S., (2022): Detection of SQL injection attack using machine learning techniques: A systematic literature review. Journal of Cybersecurity and Privacy, 2(4), 764–777. https://doi.org/10.3390/jcp2040039
  3. Alhamyani, R., & Alshammari, M., (2024): Machine learning-driven detection of cross-site scripting attacks. Information, 15(7), 420. https://doi.org/10.3390/info15070420
  4. Cantone, M., Marrocco, C., & Bria, A., (2024): Machine learning in network intrusion detection: A cross-dataset generalization study. IEEE Access, 12. https://doi.org/10.1109/ACCESS.2024.3472907
  5. Chen, T., & Guestrin, C., (2016): XGBoost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD '16), San Francisco, CA, USA, pp. 785-794. https://doi.org/10.1145/2939672.2939785
  6. Dhanushkodi, K., & Thejas, S., (2024): AI enabled threat detection: Leveraging artificial intelligence for advanced security and cyber threat mitigation. IEEE Access, 12, 173127-173136. https://doi.org/10.1109/ACCESS.2024.3493957
  7. Fang, Y., Li, Y., Liu, L., & Huang, C., (2018): DeepXSS: Cross site scripting detection based on deep learning. In Proceedings of the 2018 International Conference on Computing and Artificial Intelligence (ICCAI ’18), pp. 47–51. https://doi.org/10.1145/3194452.3194469
  8. Halbouni, A., Gunawan, T. S., Habaebi, M. H., Halbouni, M., Kartiwi, M., & Ahmad, R., (2022): Machine learning and deep learning approaches for cybersecurity: A review. IEEE Access, 10, 19572-19585. https://doi.org/10.1109/ACCESS.2022.3151248
  9. Hamzah, K. H., Osman, M. Z., Anthony, T., Ismail, M. A., Abdullah, Z., & Alanda, A., (2024): Comparative analysis of machine learning algorithms for cross-site scripting (XSS) attack detection. JOIV: International Journal on Informatics Visualization, 8(3-2), 1678-1685. https://doi.org/10.62527/joiv.8.3-2.3451
  10. Kaur, J., Garg, U., & Bathla, G., (2023): Detection of cross-site scripting (XSS) attacks using machine learning techniques: A review. Artificial Intelligence Review, 56, 12725–12769. https://doi.org/10.1007/s10462-023-10433-3
  11. Ma, M., Han, L., & Zhou, C., (2024): Research and application of artificial intelligence based webshell detection model: A literature review. arXiv preprint arXiv:2405.00066.
  12. https://doi.org/10.48550/arXiv.2405.00066
  13. Morgan, S., (2020): Cybercrime to cost the world $10.5 trillion annually by 2025. Cybercrime Magazine, Cybersecurity Ventures. https://cybersecurityventures.com/annual-cybercrime-report-2020/
  14. Nadeau, C., & Bengio, Y., (2003): Inference for the generalization error. Machine Learning, 52(3), 239-281. https://doi.org/10.1023/A:1024068626366
  15. OWASP Foundation, (2025): A05:2025 – Injection. OWASP Top 10:2025. https://owasp.org/Top10/2025/A05_2025-Injection/
  16. Prajapati, A. K., Pilli, E. S., Battula, R. B., Varadharajan, V., Verma, A., & Joshi, R. C., (2025): A comprehensive survey on RPL routing-based attacks, defences and future directions in Internet of Things. Computers and Electrical Engineering, 123, 110071. https://doi.org/10.1016/j.compeleceng.2025.110071
  17. Rahman, M. W., Lin, Y. Z., Weeks, C., Ruddell, D., Gabriellini, J., Hayes, B., Hariri, S., Satam, P., & Ziegler Jr, E. V., (2026): AI/ML based detection and categorization of covert communication in IPv6 network. Cybersecurity, 9, 33. https://doi.org/10.1186/s42400-025-00485-z
  18. Samaana, H., Costa, D. E., Shihab, E., & Abdellatif, A., (2025): A machine learning-based approach for detecting malicious PyPI packages. In Proceedings of the 40th ACM/SIGAPP Symposium on Applied Computing (SAC ’25), pp. 1617–1626.
  19. https://doi.org/10.1145/3672608.3707756
  20. Sharma, N., Batra, I., & Malik, A., (2024): A comparative study of malware detection using hybrid deep learning techniques. In Proceedings of the 2024 ASU International Conference in Emerging Technologies for Sustainability and Intelligent Systems (ICETSIS), Manama, Bahrain, pp. 1260-1266. https://doi.org/10.1109/ICETSIS61505.2024.10459638
  21. Singh, P., Hasija, T., & Ramkumar, K., (2024): Malware classification to strengthen digital resilience: Comparing SVM kernel and logistic regression. In Proceedings of the 2024 3rd International Conference on Applied Artificial Intelligence and Computing (ICAAIC), Salem, India, pp. 1461-1466. https://doi.org/10.1109/ICAAIC60222.2024.10575736
  22. Thajeel, I. K., Samsudin, K., Hashim, S. J., & Hashim, F., (2023): Machine and deep learning-based XSS detection approaches: A systematic literature review. Journal of King Saud University – Computer and Information Sciences, 35(7), 101628. https://doi.org/10.1016/j.jksuci.2023.101628
  23. Tripathy, S. S., & Behera, B., (2023): Performance evaluation of machine learning algorithms for intrusion detection system. Preprint. https://doi.org/10.17605/OSF.IO/WX6CS
  24. Veini, T., (2023): Detection techniques of common malware features: A systematic review. Master’s thesis, Faculty of Information Technology, University of Jyväskylä, Finland.
  25. https://jyx.jyu.fi/handle/123456789/87338
  26. Wei, J., & Zou, K., (2019): EDA: Easy data augmentation techniques for boosting performance on text classification tasks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), Hong Kong, China, pp. 6382–6388. https://doi.org/10.18653/v1/D19-1670
Statistics
  • Article view113
  • Downloads103
  • First online22 November 2026
  • Published at22 November 2026

  • RIS
  • BibTeX
  • EndNote
  • Mendeley
  • APA (7th edition)
  • MLA (9th edition)
  • Chicago
  • Harvard
  • IEEE
  • Vancouver

© 2026 The Author(s)

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.