A Comparative Study of Machine Learning and Large Language Models for SQL and NoSQL Injection Vulnerability Detection

2025

Closed access Metadata (CSL-JSON)
DOI 10.1109/sist61657.2025.11139190
Data confidence 70 medium
How this score is calculated

It is built from checkable properties of the record itself: whether the article has a DOI, how many independent sources confirmed its data, whether the required fields are filled in, and how recent the latest confirmation is. Disagreement between sources and a missing identifier lower it. A value of 80 or above means the record was published without further checking; 60 to 79 means it is published at reduced confidence, with a manual check advisable. A record verified by an editor by hand is never pushed below 90 by a recalculation. This scores our data about the article, not the article itself.

Abstract

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.