dromara / dromara/ujcms

The file upload feature of UJCMS_v9.7.5 has a stored XSS vulnerability.

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
665
Forks
114
PR merge metrics
No merged PRs in 30d

Description

【Vulnerability Description】
There is a vulnerability in the file upload function of the ujcms_v9.7.5 backend. The content of uploaded HTML and PDF files is not filtered or checked. When users view maliciously crafted HTML or PDF files, the embedded malicious JavaScript code will be triggered, which may lead to the theft of sensitive tokens.

【Vulnerability Type】
CWE-79: Cross-site Scripting

【Product Vendor】
https://gitee.com/ujcms/ujcms
https://github.com/ujcms/ujcms
https://www.ujcms.com/

【Affected Product Code Repository】
ujcms_v9.7.5

【Vulnerability Proof】
Upload HTML and PDF files with XSS payload

![Image](https://github.com/user-attachments/assets/e31b74a7-d065-4458-a6a9-78191bf33a0a)

Clicking on "View" will trigger the XSS payload

![Image](https://github.com/user-attachments/assets/3c150d2c-a96f-448c-b52a-5ecd1efe3c44)

![Image](https://github.com/user-attachments/assets/0aa62d68-16ab-4d08-86c4-70943ed68b62)

【Code Location】
/main/java/com/ujcms/cms/ext/web/backendapi/WebFileUploadController.java#upload

【Code Analysis】

![Image](https://github.com/user-attachments/assets/0d560859-2688-4482-8e0e-732bdf575cbf)

When uploading, the checkName method is called to check the file name (does not include ../) and suffix (file suffix blacklist). If there is no problem, the store method is called to save the file. The content of the file is not checked.

![Image](https://github.com/user-attachments/assets/dc76ca28-4bf3-412c-a7e7-24f7b3ec66b3)

Check whether the file name contains ".", which prevents directory traversal using ../

![Image](https://github.com/user-attachments/assets/0e0cb58b-90a1-4fad-94ea-989f6afe9dd9)

File suffix blacklist

![Image](https://github.com/user-attachments/assets/523cd068-4b9d-493b-8eb1-542f0673c8d2)

![Image](https://github.com/user-attachments/assets/a96512c6-fbc5-4148-b503-251e73cb8c41)

【Repair Suggestions】
Implement whitelist restrictions on the types of files that can be uploaded
Implement validation and filtering of the content of uploaded files

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.