Volume 28 ,Issue 2 ,November 2026 ,Pages 221-245
1 University of Sulaimani, Computer Department, Sulaimani, Iraq
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
© 2026 The Author(s)
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.