# XSShield: Defending Against Stored XSS Attacks Using LLM-Based Semantic Understanding
## 3 XSShield Design
### Data Adaptor
#### 3.2.1 PDG Generator
Potential mitigation strategies include hybrid approaches combining traditional static analysis with LLM techniques, regular model updates to address emerging attack vectors, and implementing human verification mechanisms for high-risk scenarios. #### 5.5.2 Future Work

While XSShield demonstrates significant advantages in defending against stored XSS attacks, several promising research directions remain. Future work will focus on narrowing the performance gap between non-obfuscated and obfuscated attack detection through improved prompt-engineering and semantic representation techniques. To address latency concerns, we plan to explore on-device deployment of lightweight LLMs using model quantization and distillation methods. The framework could be enhanced with adaptive defense mechanisms that continuously learn from emerging attack patterns through efficient incremental prompt optimization. Integration with existing security standards like Content Security Policy would facilitate broader adoption across different platforms. Additionally, extending XSShield to provide explainable detection decisions would transform it into both a defensive tool and an educational resource for security professionals. A critical area for future research is improving the robustness of XSShield against adversarial attacks. This includes exploring adversarial training techniques to harden the LLM against manipulated inputs, developing hybrid detection systems that combine LLMs with traditional static and dynamic analysis methods, and implementing real-time monitoring to detect and respond to adversarial payloads. Furthermore, leveraging private, fine-tuned LLMs with domain-specific adversarial examples could enhance the framework's resilience to sophisticated attacks. These improvements would collectively strengthen XSShield's capabilities while maintaining its lightweight nature and practical deployability in real-world environments. ## 6 Related Work

### XSS Defense

XSS defense technology has evolved from static defense to dynamic tracking, and then to intelligent detection. Early research primarily focused on basic defense mechanisms, such as the browser-enforced embedded policies proposed by [PERSON] et al. [46] and the Noncespaces technique proposed by [PERSON] et al. [47], the latter preventing markup injection attacks through randomized namespace prefixes. As attack methods became more complex, research focus shifted toward more refined defense solutions. [PERSON] et al. [48] proposed precise client-side XSS filtering technology based on dynamic data flow tracking, while [PERSON] et al. [49] developed context-sensitive automatic sanitization technology. [PERSON] et al. [50] conducted systematic analysis of such XSS sanitization frameworks to improve their effectiveness. Recent research has begun introducing intelligent methods, such as [PERSON] et al. [51] applying machine learning techniques to XSS attack detection and defense, while [PERSON] et al. [52] explored client-side CSP implementation solutions. As [PERSON] et al. [7] pointed out in their survey, detecting complex XSS attack paths still faces significant challenges. Reviewing existing research, most XSS defense solutions primarily focus on detecting injection-type XSS vulnerabilities (i.e., defending against vulnerability detection based on simple attack vectors) rather than directly defending against attack vectors themselves, often struggling to effectively address real-world attack methods. ### Malicious JavaScript Detection

In the field of malicious JavaScript detection, researchers have proposed various detection methods. [PERSON] et al. [40] developed the Zozzle tool to identify potentially malicious scripts through static analysis of JavaScript ASTs. [PERSON] et al. [38] developed the CUJO system, combining static and dynamic analysis methods to detect drive-by download attacks. However, these early methods often struggled to address evasion techniques such as dynamic code generation and obfuscation.