CRAIApr 28, 2025

Leveraging LLM to Strengthen ML-Based Cross-Site Scripting Detection

arXiv:2504.21045v17 citationsh-index: 2Proceedings of the 2025 ACM Workshop on Wireless Security and Machine Learning
Originality Incremental advance
AI Analysis

This work addresses the challenge of improving machine learning-based security systems for web application vulnerabilities, specifically for detecting advanced XSS attacks, though it is incremental as it builds on existing ML methods with a new data generation approach.

The paper tackled the problem of detecting obfuscated Cross-Site Scripting (XSS) attacks by using a Large Language Model (LLM) to generate complex obfuscated training data, which improved a random forest model's accuracy from 81.9% to 99.5% on obfuscated samples and increased complexity by 28.1% compared to other tools.

According to the Open Web Application Security Project (OWASP), Cross-Site Scripting (XSS) is a critical security vulnerability. Despite decades of research, XSS remains among the top 10 security vulnerabilities. Researchers have proposed various techniques to protect systems from XSS attacks, with machine learning (ML) being one of the most widely used methods. An ML model is trained on a dataset to identify potential XSS threats, making its effectiveness highly dependent on the size and diversity of the training data. A variation of XSS is obfuscated XSS, where attackers apply obfuscation techniques to alter the code's structure, making it challenging for security systems to detect its malicious intent. Our study's random forest model was trained on traditional (non-obfuscated) XSS data achieved 99.8% accuracy. However, when tested against obfuscated XSS samples, accuracy dropped to 81.9%, underscoring the importance of training ML models with obfuscated data to improve their effectiveness in detecting XSS attacks. A significant challenge is to generate highly complex obfuscated code despite the availability of several public tools. These tools can only produce obfuscation up to certain levels of complexity. In our proposed system, we fine-tune a Large Language Model (LLM) to generate complex obfuscated XSS payloads automatically. By transforming original XSS samples into diverse obfuscated variants, we create challenging training data for ML model evaluation. Our approach achieved a 99.5% accuracy rate with the obfuscated dataset. We also found that the obfuscated samples generated by the LLMs were 28.1% more complex than those created by other tools, significantly improving the model's ability to handle advanced XSS attacks and making it more effective for real-world application security.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes