PRWHA: RGB Image-Based Hybrid Attention for Cross-File SQLI/XSS Vulnerability Detection in PHP Web Applications
As the most widely used server-side programming language for web applications, PHP has a large number of SQL injection (SQLI) and cross-site scripting (XSS) vulnerabilities that are exploited maliciously, making the detection of such vulnerabilities increasingly critical. Existing source code detection methods suffer from issues such as uncleaned redundant information, limited representation dimensions and poor detection performance. To address these challenges, we propose a PHP vulnerability detection method based on RGB image representation and hybrid attention mechanisms — PHP ResNet with Hybrid Attention (PRWHA). First, PRWHA marks the input sources and sensitive functions, constructs data flow and control flow graphs between source and sink points and adds function call edges. This method uniquely identifies nodes in the graph using filenames and line numbers to enable inter-procedural and cross-file detection. Next, it leverages both the topological information (including data flow, control flow and function call relationships) and textual information of the code’s graph structure to generate RGB images. These images are then processed by a ResNet-50 model enhanced with a hybrid attention layer to detect SQLI and XSS vulnerabilities. To validate the effectiveness of PRWHA, we evaluated it on both publicly available datasets and real-world software datasets. The results demonstrate that PRWHA outperforms traditional methods as well as other machine learning, deep learning and Large Language Model (LLM)-based detection approaches. On the public dataset, PRWHA achieved an accuracy of 99.00% and an F1-score of 97.13% on the test set. On the real-world software dataset, it achieved an accuracy of 73% and a vulnerability detection rate of approximately 83.67%.
Authors
- Qingyu Song (ORCID: https://orcid.org/0000-0002-9330-0541)
- Guoyan Huang (ORCID: https://orcid.org/0000-0003-0655-4947)
- Bing Zhang (ORCID: https://orcid.org/0000-0002-9867-8439)
- Haitao He (ORCID: https://orcid.org/0000-0001-9338-5605)
- Rong Ren (ORCID: https://orcid.org/0009-0002-9320-9382)
- Qian Wang (ORCID: https://orcid.org/0009-0009-3745-9679)
Institutions
- Yanshan University (CN)
Publication Details
- Journal
- International Journal of Software Engineering and Knowledge Engineering
- Published
- 2025-10-08
- DOI
- https://doi.org/10.1142/s0218194025500743
- Primary Topic
- Web Application Security Vulnerabilities
- Type
- article
- Field-Weighted Citation Impact
- 0.00