Web applications remain critically vulnerable to injection attacks, including SQL Injection (SQLi), OS Command Injection, and Cross-Site Scripting (XSS) among others, which exploit the semantic gap between user-supplied input and executable code. Traditional Web Application Firewalls (WAFs) rely on signature-based pattern matching, rendering them susceptible to evasion through payload obfuscation. While Transformer-based language models excel at capturing long-range contextual dependencies and have demonstrated promise in detecting malicious intent, they alone may not fully exploit the fine-grained character-level patterns that distinguish obfuscated attack payloads. This paper proposes a Dual-Stream Hybrid Architecture that combines the contextual reasoning capabilities of Modern Bidirectional Encoder Representations from Transformers (ModernBERT), a state-of-the-art encoder supporting 8192 token sequences, with a Character-Level 1D Convolutional Neural Network (CNN) optimized for morphological pattern recognition. The semantic stream captures high-level payload intent, while the syntactic stream detects low-level structural signatures of obfuscation techniques (e.g., URL encoding, hexadecimal evasion, comment injection). Experiments on a composite dataset of ~93,500 HTTP requests, aggregated from public payload repositories, synthetic attack campaigns generated with SQLMap and XSStrike on vulnerable web applications, live honeypot traffic captured via T-Pot (SNARE/Tanner), and benign browsing sessions simulated with Playwright, demonstrate that our hybrid approach achieves 98.7% accuracy and 98.3% F1-score, outperforming standalone ModernBERT and CNN baselines by 2.4% and 8.6% respectively.
References
[1]
OWASP Foundation (2025) Introduction-OWASP Top 10. https://owasp.org/Top10/2025/0x00_2025-Introduction
[2]
Demetrio, L., Valenza, A., Costa, G. and Lagorio, G. (2020) WAF-A-MoLE: Evading Web Application Firewalls through Adversarial Machine Learning. Proceedings of the 35th Annual ACM Symposium on Applied Computing, Brno, 30 March-3 April 2020, 1745-1752. https://doi.org/10.1145/3341105.3373962
[3]
Seyyar, Y.E., Yavuz, A.G. and Unver, H.M. (2022) An Attack Detection Framework Based on BERT and Deep Learning. IEEEAccess, 10, 68633-68644. https://doi.org/10.1109/access.2022.3185748
[4]
Thakur, J. and Rane, K. (2023) Using Deep Learning to Perform Payload Classification. In: Saini, H.S., Sayal, R., Govardhan, A. and Buyya, R., Eds., Innovations in Computer Science and Engineering, Springer, 183-199. https://doi.org/10.1007/978-981-19-7455-7_14
[5]
Schuster, M. and Nakajima, K. (2012) Japanese and Korean Voice Search. 2012 IEEEInternationalConferenceonAcoustics, SpeechandSignalProcessing (ICASSP), Kyoto, 25-30 March 2012, 5149-5152. https://doi.org/10.1109/icassp.2012.6289079
[6]
Sennrich, R., Haddow, B. and Birch, A. (2016) Neural Machine Translation of Rare Words with Subword Units. Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Berlin, 7-12 August 2016, 1715-1725. https://doi.org/10.18653/v1/p16-1162
[7]
Warner, B., Chaffin, A., Clavié, B., Weller, O., Hallstr?m, O., Taghadouini, S., et al. (2025) Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference. Proceedingsofthe 63rdAnnualMeetingoftheAssociationforComputationalLinguistics (Volume 1: LongPapers), Vienna, 27 July-1 August 2025, 2526–2547. https://doi.org/10.18653/v1/2025.acl-long.127
[8]
Guimaraes, B.D.C. and Stampar, M. (2026) Sqlmap. https://sqlmap.org/
[9]
Bijjou, K. (2026) WAFNinja. https://github.com/khalilbijjou/WAFNinja
[10]
Saleem Raja, A., Vinodini, R. and Kavitha, A. (2021) Lexical Features Based Malicious URL Detection Using Machine Learning Techniques. MaterialsToday: Proceedings, 47, 163-166. https://doi.org/10.1016/j.matpr.2021.04.041
[11]
Sahoo, D., Liu, C. and Hoi, S.C.H. (2017) Malicious URL Detection Using Machine Learning: A Survey. arXiv: 1701.07179. https://arxiv.org/abs/1701.07179
[12]
Liu, Y. and Dai, Y. (2024) Deep Learning in Cybersecurity: A Hybrid BERT-LSTM Network for SQL Injection Attack Detection. IETInformationSecurity, 2024, Article ID: 5565950. https://doi.org/10.1049/2024/5565950
[13]
Liu, T., Qi, Y., Shi, L. and Yan, J. (2019) Locate-Then-Detect: Real-Time Web Attack Detection via Attention-Based Deep Neural Networks. ProceedingsoftheTwenty-EighthInternationalJointConferenceonArtificialIntelligence, Macao, 10-16 August 2019, 4725-4731. https://doi.org/10.24963/ijcai.2019/656
[14]
Devlin, J., Chang, M., Lee, K. and Toutanova, K. (2019) BERT: Pre-Training of Deep Bidirectional Transformers for Language Understanding. Proceedingsofthe 2019 ConferenceoftheNorth, Minneapolis, June 2019, 4171-4186. https://doi.org/10.18653/v1/n19-1423
[15]
Rahali, A. and Akhloufi, M.A. (2023) End-To-End Transformer-Based Models in Textual-Based NLP. AI, 4, 54-110. https://doi.org/10.3390/ai4010004
[16]
Dao, T., Ermon, S., Fu, D., Ré, C. and Rudra, A. (2022) FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness. Advances in Neural Information Processing Systems 35, New Orleans, 28 November-9 December 2022, 16344-16359. https://doi.org/10.52202/068431-1189
[17]
Su, J., Ahmed, M., Lu, Y., Pan, S., Bo, W. and Liu, Y. (2024) Roformer: Enhanced Transformer with Rotary Position Embedding. Neurocomputing, 568, Article ID: 127063. https://doi.org/10.1016/j.neucom.2023.127063
[18]
Saxe, J. and Berlin, K. (2015) Deep Neural Network Based Malware Detection Using Two Dimensional Binary Program Features. 2015 10thInternationalConferenceonMaliciousandUnwantedSoftware (MALWARE), Fajardo, 20-22 October 2015, 11-20. https://doi.org/10.1109/malware.2015.7413680
[19]
Kim, H., Lee, J., Yeo, N.Y., Astrid, M., Lee, S. and Kim, Y. (2018) CNN Based Sentence Classification with Semantic Features Using Word Clustering. 2018 InternationalConferenceonInformationandCommunicationTechnologyConvergence (ICTC), Jeju, 17-19 October 2018, 484-488. https://doi.org/10.1109/ictc.2018.8539546
Telekom Security (2026) T-Pot: The All in One Multi Honeypot Platform. GitHub. https://github.com/telekom-security/tpotce
[27]
MushMush Foundation (2025) SNARE. GitHub. https://github.com/mushorg/snare
[28]
MushMush Foundation (2025) Tanner. GitHub. https://github.com/mushorg/tanner
[29]
Microsoft (2026) Playwright. https://playwright.dev
[30]
De Lange, M., van de Ven, G. and Tuytelaars, T. (2022) Continual Evaluation for Lifelong Learning: Identifying the Stability Gap. arXiv: 2205.13452. https://arxiv.org/abs/2205.13452