A Comparative Study of Machine Learning and Large Language Models for SQL and NoSQL Injection Vulnerability Detection
The exponential growth of data in relational (SQL) and non-relational (NoSQL) databases has led to an increase in injection attacks, ranking them among the top cybersecurity threats. This study evaluates the effectiveness of machine learning (ML) models and large language models (LLMs) in detecting SQL and NoSQL injection vulnerabilities in source code. We train and compare various ML models—including Logistic Regression, Naïve Bayes, Decision Tree, K-Nearest Neighbors, Random Forest, Multilayer Perceptron (MLP), and Convolutional Neural Networks (CNN)—against a fine-tuned GPT-4o-mini-202407-18 model using both prompt engineering and supervised learning techniques. Our results demonstrate that the Random Forest model achieves 99% accuracy in detecting SQL injection vulnerabilities, while the fine-tuned LLM achieves 97% accuracy in detecting NoSQL injection vulnerabilities. These findings indicate that ML models and LLMs are not mutually exclusive; rather, they excel in different aspects of injection vulnerability detection. The research suggests a hybrid approach that leverages both ML and LLMs for more comprehensive security automation. By providing an open-source NoSQL injection dataset and benchmarking results, this study contributes to the automation of vulnerability detection in the software development lifecycle. The datasets used in this study are publicly available on GitHub.
Authors
- Didar Yedilkhan (ORCID: https://orcid.org/0000-0002-6343-5277)
- Assel Mukasheva (ORCID: https://orcid.org/0000-0001-9890-4910)
- Aidos Askhatuly
- A. V. Berdyshev (ORCID: https://orcid.org/0000-0002-0634-9321)
- B. M. Avinash
- Наргиз Малигаждарова
Institutions
- Kazakh-British Technical University (KZ)
- Al-Farabi Kazakh National University (KZ)
- Astana Medical University (KZ)
- International Information Technologies University (KZ)
Publication Details
- Published
- 2025-05-14
- DOI
- https://doi.org/10.1109/sist61657.2025.11139190
- Primary Topic
- Artificial Intelligence in Healthcare
- Type
- article
- Field-Weighted Citation Impact
- 0.00