Multiple vulnerabilities were found in the Quest KACE System Management
Virtual Appliance that would allow a remote attacker to gain command
execution as root. We present three vectors to achieve this, including
one that can be exploited as an unauthenticated user.

Additional web application vulnerabilities were found in the web console
that is bundled with the product. These vulnerabilities are detailed in
section 7.

Note: This advisory has limited details on the vulnerabilities because
during the attempted coordinated disclosure process, Quest advised us not
to distribute our original findings to the public or else they would
take legal action. Quest's definition of "responsible disclosure" can be
found at
https://support.quest.com/essentials/reporting-security-vulnerability.

CoreLabs has been publishing security advisories since 1997 and believes
in coordinated disclosure and good faith collaboration with software vendors
before disclosure to help ensure that a fix or workaround solution is ready
and available when the vulnerability details are publicized. We believe
that providing technical details about each finding is necessary to provide
users and organizations with enough information to understand the
implications
of the vulnerabilities against their environment and, most importantly, to
prioritize the remediation activities aiming at mitigating risk.

We regret Quest's posture on disclosure during the whole process (detailed
in the Report Timeline section) and the lack of a possibility of engaging
into a coordinated publication date, something we achieve (and have
achieved) with many vendors as part of our coordinated disclosure practices.

4. *Vulnerable Packages*

. Quest KACE System Management Appliance 8.0 (Build 8.0.318)
Other products and versions might be affected too, but they were not tested.

5. *Vendor Information, Solutions and Workarounds*

Quest reports that it has released the security vulnerability patch
SEC2018_20180410 to address the reported vulnerabilities.
Patch can be download at
https://support.quest.com/download-install-detail/6086148.

For more details, Quest published the following Security Note:
https://support.quest.com/kace-systems-management-appliance/kb/254193/se
curity-vulnerability-patch-sec2018_20180410-

6. *Credits*

These vulnerabilities were discovered and researched by Leandro Barragan
and Guido Leo from Core Security Consulting Services. The publication of
this advisory was coordinated by Leandro Cuozzo from Core Advisories Team.

7. *Technical Description / Proof of Concept Code*

Quest KACE SMA ships with a web console that provides administrators and
users with several features. Multiple vulnerabilities were found in the
context of this console, both from an authenticated and unauthenticated
perspective.

Section 7.1 describes how an unauthenticated attacker could gain command
execution on the system as the web server user.

Vulnerabilities described in 7.2 and 7.3 could also be abused to gain code
execution but would require the attacker to have a valid authentication
token.

In addition, issues found in the Sudo Server module presented in 7.4 and
7.5 would allow the attacker to elevate his privileges from the web server
user to root, effectively obtaining full control of the device.

Additional web application vulnerabilities were found in the console, such
as insufficient authorization for critical functions, which would allow an
anonymous attacker to reconfigure the appliance (7.6), SQL injection
vulnerabilities (7.7, 7,8), a cross-site scripting issue (7.9), and path
traversal vulnerabilities, which would allow an attacker to read, write and
delete arbitrary files (7.9, 7.10, 7.11).

7.1. *Unauthenticated command injection*

[CVE-2018-11138]
The '/common/download_agent_installer.php' script is accessible to anonymous
users in order to download an agent for a specific platform. This behavior
can be abused to execute arbitrary commands on the system.

The script receives the following parameters via the GET method:

. platform: Indicates the platform in which the agent is going to be
installed
. serv: SHA256 hash of a fixed value that depends of each appliance
. orgid: Organization ID
. version: Version number of the agent

The last two conditions are simple to meet. The Agent versions are publicly
available within the Quest KACE site, but even if they were not, we found
that the Organization ID parameter is vulnerable to a time based SQL
injection
(refer to issue 7.7).
This would make it possible to obtain the agent version by querying the
table 'CLIENT_DISTRIBUTION' and fetching the contents of the 'VERSION'
column. The Organization ID is 1 by default, but could be obtained in the
same way as the Agent version by querying the table 'ORGANIZATION' and
the column 'ID'.

As stated above, the application uses the Organization ID and Agent
version parameters to execute commands. This means we need to find a way
to append system commands within the Organization ID, without breaking the
SQL query. If we use the comment symbol (#), we can append anything we want
without affecting the result of the query.

[CVE-2018-11139]
The '/common/ajax_email_connection_test.php' script used to test the
configured
SMTP server is accessible by any authenticated user and can be abused to
execute arbitrary commands on the system. This script is vulnerable to
command injection via the unsanitized user input 'TEST_SERVER' sent to the
script via POST method.

[CVE-2018-11135]
An authenticated user could abuse a deserialization call on the script
'/adminui/error_details.php' to inject arbitrary PHP objects.

To exploit this issue, the parameter 'ERROR_MESSAGES' needs to be an array
and meet some specific conditions in order to successfully exploit the
issue.

7.4. *Privilege escalation via password change in Sudo Server*

[CVE-2018-11134]
In order to perform actions that requires higher privileges, the application
relies on a message queue managed that runs with root privileges and only
allows a set of commands.

One of the available commands allows to change any user's password
(including root).

Assuming we are able to run commands in the server, we could abuse this
feature by changing the password of the 'kace_support' account, which
comes disabled by default but has full sudo privileges.

7.5. *Privilege escalation via command injection in Sudo Server*

[CVE-2018-11132]
As mentioned in the issue [7.4], in order to perform actions that require
higher privileges, the application relies on a message queue that runs
daemonized with root privileges and only allows a set of commands to be
executed.

A command injection vulnerability exists within this message queue which
allows us to append arbitrary commands that will be run as root.

7.6. *Insufficient Authorization for critical function*

[CVE-2018-11142]
'systemui/settings_network.php' and 'systemui/settings_patching.php'
scripts are accessible only from localhost. This restriction can be bypassed
by modifying the 'Host' and 'X_Forwarded_For' HTTP headers.

The following proof of concept abuses this vulnerability to shutdown the
server as an anonymous user:

7.10. *Path traversal in download_attachment.php leading to arbitrary
file read*

[CVE-2018-11137]
The 'checksum' parameter of the '/common/download_attachment.php' script can
be abused to read arbitrary files with 'www' privileges. The following proof
of concept reads the '/etc/passwd' file. No administrator privileges are
needed to execute this script.

It is worth noting that there are several interesting files that can be
read with 'www' privileges, such as all the files located in
'/kbox/bin/koneas/keys/' and '/kbox/kboxwww/include/globals.inc',
which contain plaintext passwords.

7.11. *Path traversal in advisory.php leading to arbitrary file
creation/deletion*

[CVE-2018-11141]
The 'IMAGES_JSON' and 'attachments_to_remove[]' parameters of the
'/adminui/advisory.php' script can be abused to write and delete files
respectively. The following proof of concept creates a file located at
'/kbox/kboxwww/resources/TestWrite' with the content 'Sarasa' (base64
encoded).
Files can be at any location where the 'www' user has write permissions.

File deletion could be abused to delete
'/kbox/kboxwww/systemui/reports/setup_completed.log' file. This file's
existence defines if the appliance setup wizard is shown or not.

8. *Report Timeline*
2018-02-26: Core Security (Core) sent an initial notification to Quest
Software Inc. (Quest) via web form.
2018-03-05: Quest Support confirmed the receipt and requested additional
information.
2018-03-12: Core Security sent a draft advisory including a technical
description.
2018-03-16: Quest Support asked for the CVE-IDs.
2018-03-16: Core Security answered saying that the CVE-IDs are required
once the vendor verifies the vulnerabilities. Additionally, Core Security
requested a confirmation about the reported vulnerabilities and a tentative
timescale to fix them. Finally, Core Security requested that Quest use
Core's advisories-publication email address as the official communication
hannel also copying the researchers behind this discovery.
2018-03-16: Quest Support thanked Core's reply and stated it will be in
touch during the process.
2018-03-20: Quest Support informed that they had not yet received any
updates from the engineering team and had requested one.
2018-03-21: Quest Support requested information about the KACE version
used for reporting the issues and also Core's company name and information.
2018-03-21: Core replied with the affected version (that was included in
the original draft advisory) and a link to the Core company website and
the list of previous security advisories.
2018-03-21: Quest Support acknowledged the information provided.
2018-03-26: Quest's KACE product manager (PM) thanked Core for making it
aware of the security issues found and the level of thoroughness and details
provided. Quest specified it had fixes already in place for some of the
issues. Quest's KACE PM asked for a conference call in order to understand
more about Core's offerings for future engagements. Finally, Quest's KACE
PM notified the work done by Core is in breach of its license agreement,
and requested Core not to distribute the findings to the public, otherwise
uest would take legal action.
2018-04-13: Quest's KACE PM sent a follow up email and informed that it
made a hotfix to patch the reported vulnerabilities. Quest also requested
a call meeting to understand future opportunities based on the Core's
company capabilities. Finally, Quest asked for information about the
researcher that found the vulnerabilities and a link of Core's choosing
in order to be included in Quest's Acknowledgment page
(https://support.quest.com/essentials/vulnerability-reporting-acknowledg
ements).
2018-04-16: Core answered email from 2018-03-26 stating the company is
following standard practices with regards to coordinated vulnerability
disclosure, and also sent detailed technical information about our findings
at Quest's request. Core also mentioned Quest seems to be well versed in
the disclosure process and expects vendors to coordinate with it prior to
publication via Quest's vulnerability reporting process, and that Quest's
legal threat appears to be in direct contradiction to the disclosure
process that they encourage on their website. Finally, Core asked about
Quest's intention to work collaboratively to address these vulnerabilities
and to follow industry standard disclosure processes that involves
publication of the vulnerabilities.
2018-04-17: Quest's KACE PM replied saying it is willing to collaborate
and is looking forward to having a conversation over the phone in order to
continue the next steps in its vulnerability process (forwarded email from
2018-04-13).
2018-04-17: Core thanked the answer and stated the willingness of keeping
written communications between parties in order to better document the
process and communicated the next steps of the process including: 1. Testing
the fix (if vendor agrees), 2. Get CVE-IDs, 3. Get a Vendor's link to be
included in the advisory and finally 4. Send final advisory version to
vendor and coordinate publication date together. With regards to Quest's
requests, Core provided the researchers names and URL of the advisory when
it will be published. Finally, Core stated that the request for other Core
company services could be forwarded to the Core services team if needed
(and asked the right contact at Quest) but our intention is to keep that
services request separate from the coordinated disclosure process.
2018-04-18: Quest Support informed that they had publicly made available
patches for its customers and unilaterally closed the case.
2018-05-31: Advisory CORE-2018-0004 published.

9. *References*

[1] https://www.quest.com/products/kace-systems-management-appliance/

10. *About CoreLabs*

CoreLabs, the research center of Core Security, is charged with anticipating
the future needs and requirements for information security technologies.
We conduct our research in several important areas of computer security
including system vulnerabilities, cyber-attack planning and simulation,
source code auditing, and cryptography. Our results include problem
formalization, identification of vulnerabilities, novel solutions and
prototypes for new technologies. CoreLabs regularly publishes security
advisories, technical papers, project information and shared software
tools for public use at:
http://corelabs.coresecurity.com.

11. *About Core Security*

Core Security provides companies with the security insight they need to
know who, how, and what is vulnerable in their organization. The company's
threat-aware, identity amp; access, network security, and vulnerability
management solutions provide actionable insight and context needed to
manage security risks across the enterprise. This shared insight gives
customers a comprehensive view of their security posture to make better
security remediation decisions. Better insight allows organizations to
prioritize their efforts to protect critical assets, take action sooner
to mitigate access risk, and react faster if a breach does occur.

Core Security is headquartered in the USA with offices and operations in
South America, Europe, Middle East and Asia. To learn more, contact Core
Security at (678) 304-4500 or info (at) coresecurity (dot) com [email concealed]

12. *Disclaimer*

The contents of this advisory are copyright (c) 2018 Core Security and (c)
2018 CoreLabs, and are licensed under a Creative Commons Attribution
Non-Commercial Share-Alike 3.0 (United States) License:
http://creativecommons.org/licenses/by-nc-sa/3.0/us/

13. *PGP/GPG Keys*

This advisory has been signed with the GPG key of Core Security
advisories team, which is available for download at
http://www.coresecurity.com/files/attachments/core_security_advisories.a
sc.