# XSShield: Defending Against Stored XSS Attacks Using LLM-Based Semantic Understanding
## 3 XSShield Design
### Data Adaptor
#### 3.2.1 PDG Generator
However, experimental data show that the framework's average processing time is only 0.205 s (excluding model communication overhead), having minimal impact on typical webpage-loading times. More importantly, with advances in model-compression techniques and dedicated hardware accelerators, deploying small but high-performance models locally has become feasible. This local deployment approach will completely eliminate network communication overhead, reducing end-to

\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline  & **XSShield** & **Jelst** & **Les** & **Sys** & **Juge** & **Hippocampus** & **Juge** & **Hippocampus** & **Juge** & **Astronomy** & **Juge** \\ \hline \multirow{2}{*}{**BELF**} & **www-old** & 5.4223-4a & 18.350384448973066 & 4.24199524030706 & 8.04808000001111 & 4.411703000000444 & 5.301171703 & 4.726030 end processing time to only the core computation process, thereby significantly enhancing system performance. While XSshield's reliance on external LLM services introduces network latency, operational costs, and dependency risks, these challenges can be mitigated through strategic design choices. Local deployment of lightweight models using model-compression techniques eliminates network communication overhead and reduces costs. Hybrid detection mechanisms combining LLMs with traditional static analysis further reduce dependency on third-party services while enhancing system resilience. Additionally, efficient prompt optimization and batching inference requests can minimize operational expenses. These approaches collectively balance performance, cost, and security, making XSshield a practical and scalable solution for real-world XSS detection. ### How Does Current Large Language Model Performance Affect Offuscated Code Detection? Our research finds that this method achieves a 72.46% accuracy rate in detecting obfuscated JavaScript code, notably lower than the 90.66% accuracy rate for non-obfuscated code. This gap primarily stems from two aspects: first, current LLMs' limited capability in processing highly obfuscated code; second, inadequacies in existing code behavior-representation methods. Although this detection accuracy already surpasses traditional methods, it still indicates the need to develop more advanced code-analysis techniques. This performance limitation is expected to improve through two pathways: first, as more advanced language models develop, code-understanding capabilities will be enhanced; second, developing more effective code behavior-representation methods can more accurately capture semantic features of obfuscated code. Particularly noteworthy are recent advances in code-specific pre-training and multimodal learning domains, which provide promising research directions for improving obfuscated code-detection performance while maintaining the framework's high detection capability for regular samples. ### How Does Domain-Specific Optimization Impact Stored XSS Detection Performance? XSShield significantly outperforms general-purpose code analysis tools (achieving 93% accuracy compared to approximately 50%), demonstrating the effectiveness of security-domain optimizations. The framework's superior performance stems from domain-aware design choices: prompt optimization specifically engineered for XSS attack pattern recognition enables enhanced semantic understanding over traditional structure-based approaches. Moreover, the PDG adaptation mechanism, by preserving security-critical control flow relationships, yields an improvement of 14.1 percentage points in detection accuracy. Additionally, this domain-specific approach maintains robust detection capability against obfuscated samples (64.92% accuracy) where conventional detectors prove ineffective. These results demonstrate the substantial impact of security-domain optimization in enhancing foundation models' effectiveness. ### How Does UCB-R Handle Potential Dependencies Between Prompts? A fundamental assumption in traditional UCB algorithms is the independence of trials.