# XSShield: Defending Against Stored XSS Attacks Using LLM-Based Semantic Understanding
## 3 XSShield Design
### Data Adaptor
#### 3.2.1 PDG Generator
These results verify our hypothesis that UCB-R can more effectively explore and exploit prompt space compared to fixed prompts or traditional UCB selection algorithms. UCB-R's excellent performance likely benefits from its improved balance between exploration and exploitation, enabling faster identification and adoption of high-performance prompts during optimization. Figure 3: Comparison of F1-scores between UCB and UCB-R selection algorithms across 12 rounds of evaluation on the validation set. The solid lines show the best-performing prompts per round, while the shaded areas represent the performance distribution of candidate prompts. Compared to the stable and gradual convergence of UCB (blue), UCB-R (orange) achieves superior peak performance after round 6, benefiting from its weighted random sampling strategy. **Effectiveness of the Data Adaptor. ** To evaluate the Data Adaptor module's impact on XSShield's performance, we conducted a second experiment. The experiment compared system effectiveness with and without this module enabled: Data Adaptor Enabled: utilizing code segmentation based on PDG and PDG partitioning techniques; and Data Adaptor Disabled: direct code splitting by fixed length without specialized processing. _Results._ Table 4 columns \"Non-adaptor\" (adaptor disabled) and \"Adaptor\" (adaptor enabled) display performance with and without the Data Adaptor module. **Effectiveness of Different pre-trained LLMs. ** To investigate how various pre-trained LLMs affect XSShield's performance, we conducted comprehensive comparative analysis using three widely applied LLMs as determination models: (a) GPT-3.5-turbo, (b) GPT-4, and (c) Gemini-Pro. These models were selected for their widespread application and diverse capabilities in natural language processing, aiming to analyze how model selection influences XSShield's overall effectiveness in detecting vectors implemented in stored XSS attacks. _Results._ As shown in Table 5, different pre-trained LLMs significantly impact XSShield's detection performance. In performance evaluation, GPT-4 achieved optimal performance with an F1 score of 0.9266; GPT-3.5-turbo followed with an F1 score of 0.9001; while Gemini-Pro performed relatively weaker with an F1 score of only 0.2112. This performance disparity highlights the significant influence of model selection on XSShield framework effectiveness. The notable performance gap between GPT series models and Gemini-Pro particularly emphasizes the necessity of careful model selection when deploying XSShield. Overall, experimental results indicate that while XSShield can achieve excellent performance when using appropriate LLMs, its effectiveness varies significantly based on model selection. This variability suggests that actual XSShield deployment requires not only comprehensive model evaluation and selection but also continued in-depth research to understand and narrow performance gaps between different language models. #### 4.2.4 Efficiency Evaluation

To evaluate XSShield's performance overhead, we conducted comparative analysis of its execution time. Since prompts are pre-trained and LLM decision time is primarily influenced by network bandwidth, we denote this time portion as \(\Delta\) in the results. Table 6 compares the efficiency performance of XSShield with other detection techniques across evaluation sets.