Abstract Web applications are essential in the digital age, but their security vulnerabilities expose sensitive data and organizational integrity to sophisticated attacks. Among the most prevalent and damaging vulnerabilities in web applications are cross-site scripting (XSS) and SQL injection attacks. In this paper, we introduce UniEmbed, a unified approach for detecting XSS and SQL injection attacks using machine learning classifiers. This novel approach leverages natural language processing techniques, combining features from Word2Vec, the Universal Sentence Encoder (USE), and FastText to extract meaningful data from web applications. Extensive experiments were conducted using various machine learning classifiers on three benchmark datasets to evaluate the performance of the unified detection approach, demonstrating exceptional results. Experimental results demonstrate the superior performance of the MLP classifier. For the XSS attack dataset, the MLP classifier achieved an accuracy of 0.9982 and an F1-score of 0.9983, with minimal false positives and false negatives. Similarly, the hard voting classifier yielded the same outstanding results. For SQL injection attacks, the MLP classifier maintained exceptional performance, achieving an F1-score of 0.9980 and accuracy rates exceeding 0.9980 across two datasets. The classifier effectively minimized false positives and false negatives. The ROC curves further corroborate the effectiveness of the proposed method, indicating high true positive rates and low false positive rates. Furthermore, comparative analysis showed that the UniEmbed method consistently outperformed individual feature extraction methods across all classifiers. These findings indicate that the proposed UniEmbed method, particularly when combined with the MLP classifier, is highly effective in detecting both XSS and SQL injection attacks, making it a promising approach for enhancing web application security.
Read full abstract