SQL Injection Detection Using Fine-Tuned CodeBERT
Open Access
- 6 October 2025
- journal article
- Published by Engineering, Technology & Applied Science Research in Engineering, Technology & Applied Science Research
- Vol. 15 (5) , 27852-27857
Abstract
SQL injection attacks continue to pose a serious threat to web application security, with millions of systems vulnerable worldwide despite ongoing research and mitigation efforts. This study addresses the limitations of current SQLi detection techniques, particularly their inability to adapt to evolving attack patterns and their tendency to high false positive rates. A systematic review of machine learning- and deep learning-based SQL injection detection studies, published between 2017 and 2023, examined performance metrics, methods, and common shortcomings. Building on these insights, this study proposes a novel transformer-based approach utilizing a fine-tuned CodeBERT model trained on 30,919 SQL queries. This method includes extensive preprocessing and rigorous evaluation to ensure robustness and applicability. The results show that while traditional machine learning approaches reach between 73.5% and 99% accuracy, and deep learning models achieve 85% to 98%, the proposed CodeBERT-based system significantly outperforms them, attaining 99.90% accuracy, 99.96% precision, 97.75% recall, and 99.86% F1-score. These findings underscore the effectiveness of transformer models trained on code for SQL injection detection, setting new benchmarks and offering a deployable solution to enhance web application security.Keywords
This publication has 13 references indexed in Scilit:
- Handling Imbalance Functional and Non-Functional Software Requirement Classification Based on Machine Learning Algorithms2025
- SQL Injection Detection Using RNN Deep Learning ModelJournal of Applied Engineering and Technological Science (JAETS), 2023
- Classification of SQL Injection Attacks using ensemble learning SVM and Naïve Bayes2023
- A Deep Learning Approach for The Detection of Structured Query Language Injection VulnerabilityInternational Journal of Advanced Trends in Computer Science and Engineering, 2022
- A Novel Approach Exploiting Machine Learning to Detect SQLi Attacks2022
- A CNN-BiLSTM based Approach for Detection of SQL Injection Attacks2021
- CodeBERT: A Pre-Trained Model for Programming and Natural Languages2020
- Detection of SQL Injection Attacks: A Machine Learning Approach2019
- A Machine Learning Based Approach to Identify SQL Injection Vulnerabilities2019
- Applied Machine Learning predictive analytics to SQL Injection Attack detection and prevention2017