Fine-Tuned CodeBERT for Web Threat Classification using Agentic Reasoning

Abstract SQL injection (SQLi) and cross-site scripting (XSS) are among the most serious vulnerabilities of web applications. Existing detection approaches often need considerable time and memory to reach high accuracy, and most treat the two attacks separately. We fine-tune CodeBERT, a transformer pre-trained on source code, to detect both attacks from raw payload text and compare it with BERT-base, RoBERTa-base and DistilBERT under one identical configuration. CodeBERT misclassified 7 of 6,259 test samples (error rate 0.11%), against 0.13% to 0.19% for the other models, and a shorter input of 64 tokens cut training time by 42% and latency by 46%. One model therefore covers both attacks at low cost, which suits lightweight web application firewalls; this binary (benign vs. malicious) study is the first step towards attack-type classification.

Authors

Institutions

Publication Details

Journal
Research Square
Published
2026-11-10
DOI
https://doi.org/10.21203/rs.3.rs-11660479/v1
Primary Topic
Web Application Security Vulnerabilities
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Fine-Tuned CodeBERT for Web Threat Classification using Agentic Reasoning

Zahid Hussain Qaisar, Oybek Zokirjonov
Research Square
Web Application Security Vulnerabilities
preprint

Fine-Tuned CodeBERT for Web Threat Classification using Agentic Reasoning

Zahid Hussain Qaisar, Oybek Zokirjonov
preprint en

Abstract

Abstract SQL injection (SQLi) and cross-site scripting (XSS) are among the most serious vulnerabilities of web applications. Existing detection approaches often need considerable time and memory to reach high accuracy, and most treat the two attacks separately. We fine-tune CodeBERT, a transformer pre-trained on source code, to detect both attacks from raw payload text and compare it with BERT-base, RoBERTa-base and DistilBERT under one identical configuration. CodeBERT misclassified 7 of 6,259 test samples (error rate 0.11%), against 0.13% to 0.19% for the other models, and a shorter input of 64 tokens cut training time by 42% and latency by 46%. One model therefore covers both attacks at low cost, which suits lightweight web application firewalls; this binary (benign vs. malicious) study is the first step towards attack-type classification.

Research Square
Westminster International University in Tashkent (UZ)
Web Application Security Vulnerabilities
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon