CodeBERT Detection Pipeline for SQL Injection Detection: A Comparison with other ML Models - Motta, Leonardo Antonetti da; Valejo, Alan Demétrius Baria; Garcés, Lina (Anais do Simpósio Brasileiro de Cibersegurança (SBSeg); 2026: Anais do XXVI Simpósio Brasileiro de Cibersegurança, 2026)
SQL injection (SQLi) remains a prevalent web application vulnerability, while existing detection approaches often struggle to generalise across obfuscated and long SQL payloads. This paper presents CodeBERT-SQLi, a CodeBERT-based detection pipeline that adapts transformer models to arbitrary-length queries through sliding-window tokenisation and majority-vote aggregation. We compile and standardise a large-scale SQLi corpus from ten public sources to produce a unified dataset of 12.7 million labelled queries. We then conduct a comparative evaluation involving CodeBERT-SQLi, untuned BERT and CodeBERT, and traditional ML baselines (Logistic Regression, Random Forest, Linear SVM). Experiments on the complete 1.9-million-query test partition show that CodeBERT-SQLi achieves MCC = 0.947 and AUC = 0.971, outperforming all compared methods. The results further reveal that code-domain pre-training (∆MCC = 0.059) contributes more to performance gains than task-specific fine-tuning (∆MCC = 0.026), highlighting representation quality as the key factor in SQLi detection.