arrow
Return

Machine Learning Models for SQL Injection Detection

delete2025-08-29
delete0
delete
OA
AI
C
Cosmina-Mihaela Roșca
A
Adrian Stancu *
C
Cătălin Popescu *
DOI:10.3390/electronics14173420delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Cyberattacks include Structured Query Language Injection (SQLi), which represents threats at the level of web applications that interact with the database. These attacks are carried out by executing SQL commands, which compromise the integrity and confidentiality of the data. In this paper, a machine learning (ML)-based model is proposed for identifying SQLi attacks. The authors propose a two-stage personalized software processing pipeline as a novel element. Although individual techniques are known, their structured combination and application in this context represent a novel approach to transforming raw SQL queries into input features for an ML model. In this research, a dataset consisting of 90,000 SQL queries was constructed, comprising 17,695 legitimate and 72,304 malicious queries. The dataset consists of synthetic data generated using the GPT-4o model and data from a publicly available dataset. These were processed within a pipeline proposed by the authors, consisting of two stages: syntactic normalization and the extraction of the eight semantic features for model training. Also, within the research, several ML models were analyzed using the Azure Machine Learning Studio platform. These models were paired with different sampling algorithms for selecting the training set and the validation set. Out of the 15 training-sampling algorithm combinations, the Voting Ensemble model achieved the best performance. It achieved an accuracy of 96.86%, a weighted AUC of 98.25%, a weighted F1-score of 96.77%, a weighted precision of 96.92%, and a Matthews correlation coefficient of 89.89%. These values demonstrate the model’s ability to classify queries as legitimate or malicious. The attack identification rate was only 15 malicious queries missed out of a total of 7200, and the number of false alarms was 211 cases. The results confirm the possibility of integrating this algorithm into an additional security layer within an existing web application architecture. In practice, the authors suggest adding an extra layer of security using synthetic data.
Keywords:
SQL injection
machine learning
web application security
synthetic data
intrusion detection

Journal

Electronics cover
Electronics
IF:
2.6
Papers:
1.0W
Citations:
4.7W

Organization

P
petroleum-gas university of ploiesti
Scholars:
340
Papers: 215
Citations: 0
Cited Papers

Cited Papers

Investigating rarity in web attacks with ensemble learners
err2021-05-20
err10
errOAAI
errZuech, Richard; Hancock, John; Khoshgoftaar, Taghi M.
errShare
errSave
Across the Spectrum In-Depth Review AI-Based Models for Phishing Detection
err2024-01-01
err0
errOAAI
errShakeel Ahmad; Muhammad Zaman; Ahmad Sami AL-Shamayleh; Tanzila Kehkashan; Rahiel Ahmad; Safi’ I Muhammad Abdulhamid; Ismail Ergen; Adnan Akhunzada
errShare
errSave
researcher View more