# XSShield: Defending Against Stored XSS Attacks Using LLM-Based Semantic Understanding
## 3 XSShield Design
### Data Adaptor
#### 3.2.1 PDG Generator
All attack samples were derived from JavaScript engine-execution traces, forming the malicious evaluation set. These attacks can be categorized into information reconnaissance, unauthorized resource access, cross-platform mobile application attacks, social engineering-driven persistent threats, auxiliary operation support, and cross-protocol attack paths. Each category is detailed in Appendix A. To establish a balanced evaluation methodology, 305 low-redundancy benign samples were selected from the JS150k dataset based on Jaccard similarity. The selection process identified and chose the 305 samples with the lowest Jaccard similarity scores to ensure maximum diversity and minimal redundancy in the benign dataset. For experimental consistency, GPT-turbo-3.5 was utilized for prompt optimization and testing, with standardized LLM parameters (top_k = 1, temperature = 0). A consistent system prompt was maintained across all experiments, with complete details provided in Figure 11a. **Experiment Platform Setup. ** Prompt training was conducted on a Windows Server 2016 server configured with an Intel(R) Xeon(R) Gold 6248R processor (Intel, Santa Clara, CA, USA) at 3.00 GHz and 384 GB memory. Attack experiments were executed on a Linux server running Ubuntu 22.04.4 LTS, serving as both attack platform and target machine. This Linux server was equipped with an AMD(R) Ryzen 7 7800X3D 8-core processor (AMD, Santa Clara, CA, USA) and 16 GB memory. ### Evaluation

This section presents a comprehensive experimental evaluation of the XSShield framework, focusing on three key research questions:

* **RQ1--Comparativeness:** What advantages does the XSShield framework offer compared to existing mainstream malware-detection tools? We evaluate the framework's defense effectiveness against various attack vectors and compare it with other SOAT open source malware detectors to identify its advantages. * **RQ2--Effectiveness:** Are all components of XSShield performing their intended functions? This question is addressed by analyzing each module's contribution to the framework's overall accuracy and defense capabilities. * **RQ3--Efficiency:** How much runtime overhead does the code-transformation process introduce? We quantify the framework's time consumption through detailed performance analysis. To systematically address these research questions, we designed and conducted a series of experiments. First, we used BeEF attack samples and benign code samples as an evaluation set to comparatively analyze the performance differences between our framework and existing open-source malware-detection tools. Second, we individually tested the effectiveness of each XSShield module. Finally, we evaluated the framework's performance overhead and resource utilization through rigorous test suites to verify its feasibility in practical application environments. #### 4.2.1 Experimental Setup

**Development Set. ** To support the training of prompts and malware detectors, this research employed multiple annotated and authoritative datasets, as shown in Table 1. Initially, we introduced a dataset containing 150,000 benign JavaScript samples [33] sourced from GitHub repositories, which has been widely used in JavaScript malware detection. Notably, 305 low-redundancy samples were excluded from the development set to ensure data independence and reliability. Additionally, the malicious samples used in the development set came from three datasets: VirusTotal [34], Hynek Petrak's JavaScript Malware Collection [35], and GeeksOnSecurity's JavaScript Malicious Code Dataset [36]. These datasets contain diverse JavaScript malicious code, including multi-source detection results, specially maintained malicious code collections, and samples from actual network attacks. The comprehensive utilization of these datasets effectively enhanced malware detector performance. **Malware Detectors. ** We selected four mainstream JavaScript malware detectors based on static analysis and machine learning to evaluate the effectiveness of obfuscation techniques.