# XSShield: Defending Against Stored XSS Attacks Using LLM-Based Semantic Understanding
## 3 XSShield Design
### Data Adaptor
#### 3.2.1 PDG Generator
Although lower than for non-obfuscated samples, these results still significantly outperform existing methods in handling obfuscated attacks. Notably, the framework demonstrates robust performance in detecting obfuscated persistence attacks (71.88%) and vulnerability-based attacks (69.03%). Another outstanding advantage of XSShield is its low false positive rate, reflected in its high accuracy in identifying benign samples (97.05% for non-obfuscated and 80.00% for obfuscated samples). This characteristic is crucial for practical deployment, as high false positive rates often prevent security systems from being effectively applied in production environments. The framework's overall performance with comprehensive MCC of 0.7055 and F1 score of 0.8005 confirms XSShield's excellent performance in both attack detection and benign traffic recognition. \begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline  & **Modulo Category** & **XSShield** & **Cipo** & **Zands** & **Juge Huggemann** & **Juge (Higvalues)** & **Juge (Augonian)** & **Juge (Alexions)** \\ \hline \multirow{4}{*}{**BeF**} & Information & none-old & 72.80\%(01/107) & 07\%(01/107) & 1.874\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) \\  & Griffin & opt & 89.38\%(1/407/107) & 07\%(01/107) & 72.90\%(01/107) & 07\%(01/107) & 03\%(01/107) & 05\%(01/107) & 05\%(01/107) \\  & & sum & 89.45\%(1/407/107) & 07.01\%(01/107) & 03.89\%(01/107) & 03.35\%(01/107) & 05\%(01/107) & 05\%(01/107) \\  & & sum & 88.45\%(02/114/107) & 07.02\%(01/107) & 07.38\%(01/107) & 07\%(01/107) & 04.45\%(01/107) & 05\%(01/107) \\  & & non-old & 89.25\%(08/113) & 07.01\%(113) & 07.01\%(113) & 07.01\%(113) & 07\%(01/113) & 07\%(01/113) \\  & & sum & 89.75\%(02/123) & 07.02\%(02/1029) & 48.05\%(01/1029) & 17.45\%(01/129) & 07\%(02/129) & 3.08\%(02/129) \\ \hline \multirow{4}{*}{**BeF**} & Audio-and & none-old & 81.25\%(01/108) & 07.01\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) \\  & Cone-Frieder & sum & 86.75\%(02/108) & 07.01\%(01/107) & 07.01\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) \\  & & sum & 68.75\%(02/108) & 07.02\%(02/1029) & 28.05\%(01/1029) & 17.45\%(01/107) & 07\%(01/107) & 07\%(01/107) \\ \hline \multirow{4}{*}{**BeF**} & Preston-and & none-old & 81.25\%(01/108) & 07.01\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) \\  & social Engineering & sum & 82.55\%(01/108) & 07.01\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) \\ \hline \multirow{4}{*}{**BeF**} & Preston-and & none-old & 81.25\%(01/108) & 07.01\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) & 07\%(01/107) \\  & sum & 81.25\%(01/108) & 07.01\%(01/107 Comparison with Other Malware Detectors.To evaluate XSShield's relative advantages, we conducted comparative analysis with other advanced malware detectors. Notably, due to JavaScript's inherent limitations and potential complexities in code-transformation processes, certain code samples may not be correctly parsed by detectors. These samples were excluded from training data, potentially causing deviations between actual and ideal model performance for different detectors. To ensure evaluation reliability, we conducted tests on the test set, with results recorded in Table 3.

Our comparative analysis focuses exclusively on detection methods that can operate when server integrity is compromised, as XSShield is specifically designed for this threat model. Conventional XSS defenses were excluded from our comparison because they fundamentally rely on trusted server environments, which contradicts our core research assumption of defending against attacks after server compromise has occurred. Table 2 presents the recall rate comparison between XSShield and other detectors when processing attack vector scripts and benign scripts (detectors listed in columns, attacks and benign scripts in rows). After categorizing BeEF-based attack vectors, we tested each detector's detection effectiveness on both original code and obfuscated code, calculating corresponding MCC and F1 scores.