Manuscript Offprint

arXiv:2608.28882

Enhancing Web Application Firewalls with BERT-GNN for SQL Injection Detection

Lilliane Linnet Musoke, Atta Badii, Ahmed Ashlam

Abstract

Detecting sophisticated SQL Injection (SQLi) attacks remains among the most critical challenges in web applications security. This research study has resulted in an optimised hybrid BERT-GNN pipeline with improved detection accuracy and robustness while reducing false-positive and false-negative rates. SQL queries are tokenised and encoded into contextual BERT embeddings, which then initialise the node features of a Graph Neural Network (GNN) trained to classify each query, with the architecture tuned by Optuna over accuracy, precision, recall, and F1-score. The proposed model achieved 99.67% accuracy, with 99.71% precision, 99.39% recall, and 99.55% F1-score on the attack class. A sensitivity analysis, performed by perturbing graph inputs, further assessed the model robustness and yielded a low mean sensitivity score of 0.0037, indicating stable predictions under such perturbations. The results have demonstrated the potential of a novel hybrid model that couples BERT contextual understanding with the GNN structural modelling to detect sophisticated SQLi attack vectors. For open validation, the dataset, test sets and models are made available at https://github.com/mlily2024/Final-project-SQL-injection-pipeline.

1. Introduction and Motivation

Web applications remain the most targeted software systems, with SQL Injection (SQLi) consistently ranked among the OWASP Top 10 threats (OWASP, 2021). In an SQLi attack, an adversary injects malicious SQL code into a web application database query, which can lead to unauthorised access, data corruption, malware distribution, business disruption, intellectual property and identity theft, economic loss, cyber espionage, and full system compromise. The primary cause of SQLi, which enables adversaries to inject malicious code into user-input queries, is inadequate validation of user input (Halfond & Orso, 2005).

There is a crucial need for reliable systems to detect and prevent SQLi attacks (Trinh et al., 2023). Deployed as the first line of defence, conventional Web Application Firewalls (WAFs) rely on rule-based and signature-based approaches. While effective against known threats, they require constant updates and maintenance, which is costly and time-consuming. According to Román-Gallego et al. (2023), they also suffer high false-positive and false-negative rates and struggle to identify complex attacks. Because they depend on network administrators continually updating signatures to counter new threats, WAFs remain vulnerable to zero-day attacks; their performance relies heavily on regular maintenance and expert configuration, leaving them exposed to human error. Figure 1 illustrates the SQLi attack process and its associated security risks.

Figure

Figure 1: Process and risks of SQLi attacks (Liu & Dai, 2024)

Novelty and contribution. This paper proposes a novel hybrid model that combines Bidirectional Encoder Representations from Transformers (BERT) with Graph Neural Networks (GNN) to strengthen the security of modern web applications against evolving SQLi attacks. The hybrid pairs the deep contextual embeddings of BERT with the ability of the GNN to model graph-structured relationships between query tokens, addressing the limitations of traditional WAFs with a dynamic, adaptive, and highly accurate detection method. Crucially, and in contrast to much prior work, the model is evaluated not on accuracy alone but also on latency and on a sensitivity analysis of its robustness to perturbed inputs, the practical metrics that determine real-world deployability.

References (9)

  • and Uddin, M.N (opens the publisher in a new tab)
  • and Stahl, F. (2022) 'A Novel Approach Exploiting Machine Learning to Detect SQLi Attacks,' 2022 5th International Conference on Advanced Systems and Emergent Technologies (IC_ASET)
  • and Alouneh, S. (2023) 'Detection of Malicious Requests to Protect Web Applications and DNS Servers Against SQL Injection Using Machine Learning,' 2023 International Conference on Intelligent Computing, Communication, Networking and Services (ICCNS)
  • and Orso, A. (2005) 'AMNESIA,' ASE '05: Proceedings of the 20th IEEE/ACM International Conference on Automated Software Engineering, pp
  • Semi-Supervised Classification with Graph Convolutional Networks
  • and Singh, V. (2022) 'Detecting SQL Injection Attack using Natural Language Processing,' 2022 IEEE 9th Uttar Pradesh Section International Conference on Electrical, Electronics and Computer Engineering (UPCON)
  • and Dai, Y. (2024) 'Deep Learning in Cybersecurity: A Hybrid BERT–LSTM Network for SQL Injection Attack Detection,' IET Information Security, 2024, pp
  • and Liu, L. (2023) 'A Semantic Learning-Based SQL Injection Attack Detection Technology,' Electronics, 12(6), p. 1344
  • and Rani, P. (2022) 'SQL Injection Attack Detection by Machine Learning Classifier,' 2022 International Conference on Applied Artificial Intelligence and Computing (ICAAIC)