Structured query language injection (SQL injection/SQLi) remains a critical threat to web application security, particularly because it can bypass traditional detection systems through obfuscation. Existing approaches, including rule-based systems and classical machine learning (ML) models, often fail to capture the contextual semantics of com0plex SQL queries. This study proposes a lightweight and context-aware SQLi detection model by fine-tuning the large language model Meta artificial intelligence (LLaMA) 3.2–1B large language model using low-rank adaptation (LoRA). The model was trained using the SQL-Injection-Extend dataset obtained from Kaggle, consisting of 57,310 malicious SQLi samples and 52,208 benign user-input samples. The benign data comprise general user-generated text commonly submitted through web application interfaces. Experimental results demonstrate that the proposed model achieves an accuracy of 99.91%, precision of 99.96%, recall of 99.86%, and an F1-score of 99.91%, outperforming baseline models including convolutional neural network (CNN), long short-term memory (LSTM), and non-fine-tuned large language models (LLMs). These findings indicate that LoRA-based fine-tuning substantially enhances detection performance while maintaining computational efficiency, making the approach suitable for real-time deployment in modern web security systems. Furthermore, the integration of context-aware digital forensic reporting supports post-incident investigation and improves the interpretability of detection outcomes.
Copyrights © 2026