The increasing development and prevalence of web applications have contributed to a surge in web attacks, with injection vulnerabilities considered amongst the most pivotal, widespread, and severe. SQL injection attacks are a substantial type of attack that exploits flaws in web applications to carry out malicious SQL commands. This study aims to evaluate the effectiveness of machine-learning algorithms for detecting SQL injection attacks based on query patterns. The proposed approach involves data preprocessing, employing machine learning (ML) algorithms such as XGBoost, AdaBoost, SVM, and Light Gradient Boost, and comparing their performance, which was applied using a publicly available SQL injection dataset from Kaggle. This study used two datasets: one for training and testing the classifier and one for evaluating its performance. The dataset was preprocessed using TF-IDF for feature extraction, and the models were evaluated using standard performance metrics, such as accuracy, precision, recall, and F1-score. Based on the test results, SVM outperforms all other models across all metrics with an accuracy of 0.9847, precision of 0.9847, recall of 0.9847, and F1-score of 0.9874, closely followed by XGBoost. Light Gradient Boost and AdaBoost exhibit lower performance across all metrics, suggesting that SVM and XGBoost are more effective classifiers for the dataset. These findings highlight the effectiveness of machine learning methods, especially SVM, in recognizing SQL injection attacks and enhancing web application security.
Aldossary et al. (2026) studied this question.