On a recent penetration test, I had to opportunity to test the security of an open-source supervision appliance called EyesOfNetwork
. Multiple vulnerabilities have been found and will be reported in this post.
What is EyesOfNetwork?
From the official website:
EyesOfNetwork (“EON”) is the OpenSource solution combining a pragmatic usage of ITIL processes and a technological interface allowing their workaday application. EyesOfNetwork Supervision is the first brick of a range of products targeting to assist IT managment and gouvernance. EyesOfNetwork Supervision provides event management, availability, problems and capacity.
Basically, it is a French supervision solution combining Nagios, Cacti as well as other tools with some of them being hand-made to create a complete appliance to monitor your infrastructure. The solution offers a web interface called Eonweb
.
Preparation
For the next tests, we will download the latest iso available on https://www.eyesofnetwork.com/. The version downloaded was EyesOfNetwork 5.1
and represented the latest version available of the software.
Most of the vulnerabilities found during the assessments and presented in this post have been identified on lower versions as well.
After a default install, if we launch nmap to scan TCP ports, here is the list of ports we find:
Our goal being a quick way into the system, we’ll search for the low hanging fruit by searching for web vulnerabilities on Eonweb. SSH being difficult to attack due to the possibility of an administrator to change the user accounts passwords at the iso installation and MySQL blocking non-localhost connections.
Quick and dirty: Unauthenticated SQL injection
No authentication bypass has been found even if SQL errors could be generated by logging in using a backslash character at the end of the username. A SQL injection has been found, however, inside the logout.php file, at line 28.
Obviously, we can control the session_id
cookie because it is not set up inside a session and because of the fact the server doesn’t filter quotes by default.
The injection being inside a DELETE
statement, we have two options: either we exploit it using a blind-based technique by setting up arbitrary sessions and checking which session get deleted (useful for example in the case of a privilege escalation exploit if we have an unprivileged account) or we could exploit it using a time-based attack.
From the point of view of an attacker, we’ll take the second option as we do not have credentials on the application.
The function SLEEP
is not always usable in a DELETE FROM
statement, that’s why BENCHMARK
has been used in this example. SLEEP
is indeed usable only when a table is not empty, we’ll use SLEEP
for our proof of concept as we will need to try to recover the sessions table anyway, but in the final exploit, we’ll have to handle the two possibilities.
What’s particularly interesting is the sessions’ creation:
The monitoring solution is creating their sessions using only rand()
as the session_id, meaning that even if we are forced to do our exploitation via a time-based technique, the session_id could be found in under 11 or 12 seconds with a simple brute force character by character if we set-up a SLEEP
time of 1 second.
What to keep in mind:
DELETE
statements can’t do subqueries affecting their own table.- The target table doesn’t use a proper index column, this can lead to confusion when using substring with
LIMIT
, even whenORDER BY
is used.
Here is the exploitation scenario:
- Doing an initial request to get a value representing the lag between the target and our machine.
- Delete all the non-admin (user_id != 1) sessions.
- Getting the number of entries by doing
OR sleep(1)=1
. For each record, the server will sleep one second, by doing so we will able to either: delete<entries count> - 1
orsleep(1 / <entries count>)
to avoid entries confusion and get a faster exploitation. We will choose the first option; the second has been proven to be unstable after some tests. - Delete all sessions but one.
- Now that we have only one admin sessions in the table, it will be easy to recover it.
Proof of concept:
And here it is in action:
Using these cookies in a browser or with curl, we are correctly authenticated on Eonweb with the admin
account.
From there, we can access all the monitoring tools available in EON (Nagios, Cacti, Thrunk, …).
Go for the kill: Privilege escalation using snmp
Now that we have access to the web interface, we will try to elevate our privileges searching for an RCE. I found a particularly interesting way to perform a root-privileged remote code execution on the appliance using SNMP.
Let’s see the privileges of the process running snmpd and its configuration:
So, by default, anybody could edit the SNMP configuration, reload the server using sudo and the process will be run as root. Fortunately, we do not even need to find an RCE to perform these actions as they are available in the web interface Eonweb.
At /module/admin_process/
we are able to restart/reload the different processes in EyesOfNetwork:
And, even if I wasn’t able to find it in the interface, an administrator can edit directly the SNMP configuration file, going to /module/admin_files/?file=snmpconf
.
What’s so interesting about SNMP? It is possible to execute shell commands by setting a specific instruction inside it and call for the correct OID.
Now we have to access the SNMPd service either with snmpwalk
directly if 161/udp is open and do snmpwalk -v 1 <EON ip> -c <community> .1.3.6.1.4.1.2021.8
or we could, once again, use the tools available in Eonweb to trigger the command execution, for example if there is a firewall present between EON and our machine blocking SNMP requests.
At /module/tool_all/
, a snmpwalk tool is available, by default it is recovering all the MIB, but since the host is the last argument from the command line, we can set the host to <host> <OID>
and get our connect-back.
And in our connect-back shell we previously set-up:
Final privilege escalation scenario:
- Edit the snmpconf via
admin_files
and search for the correct community - Reload the service via
admin_process
- Call the correct snmp OID either if SNMP is accessible or using tools from Eonweb in
tool_all
Automating the attack
Now that we have all these elements, a complete scenario is possible:
- Exploiting the Unauthenticated SQL Injection to recover either: sessions or accounts (password are stored in simple md5).
- Authenticate on the application
- Recover the SNMP community
- Edit the snmpd config files to add a malicious command
- Execute the command using snmpwalk (either remotely or locally using the tools available in eonweb)
- We have our root-privileged execution :).
Timeline
- 01st February 2017 - Initial Discovery
- 14th March 2017 - Public disclosure of an authenticated SQL injection and an RCE in Eonweb by Sysdream
- 27th March 2017 - First contact with the vendor
- 28th March 2017 - Created the proof of concept for the exploit
- 28th March 2017 - CVE request to DWF
- 29th March 2017 - Acknowledgement of the vendor
- 07th May 2017 - Got assigned a CVE ID via DWF (CVE-2017-1000060)
Final Advisory
Title:
======
EyesOfNetwork (EON) 5.1 Unauthenticated SQL Injection in eonweb leading to remote root
Author:
=======
Dany Bach [@ddxhunter, rioru.github.io]
CVE-ID:
=======
CVE-2017-1000060
OVE-ID:
=======
OVE-20170328-0001
Risk Information:
=================
CVSS Base Score 10.0
CVSS Vector CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H/E:F/RL:U/RC:C
CVSS Temporal Score 9.7
Overall CVSS Score 9.7
Timeline:
=========
2017-02-01 - Initial Discovery
2017-03-14 - Public disclosure of an authenticated SQL injection and an RCE in Eonweb by Sysdream
2017-03-27 - First contact with the vendor
2017-03-28 - Created the proof of concept for the exploit
2017-03-28 - CVE request to DWF
2017-03-28 - Acknowledgement of the vendor
2017-05-03 - Got assigned a CVE ID via DWF (CVE-2017-1000060)
Status:
=======
Published
Affected Products:
==================
EyesOfNetwork ("EON") 5.1 and older
Vendor Homepage:
================
https://www.eyesofnetwork.com/?lang=en
Details:
========
By exploiting an unauthenticated SQL injection in Eonweb (logout.php), it is possible to gain remote root access to the server using a lack of proper permissions in SNMPd after an authentication using the sessions table.
Vulnerable file:
================
logout.php, Line 28
...
if(isset($_COOKIE["session_id"])) {
$sessid=$_COOKIE["session_id"];
sqlrequest($database_eonweb,"DELETE FROM sessions where session_id='$sessid'"); // Vulnerable
}
...
Proof of Concept:
=================
https://gist.github.com/rioru/105fb626b5ce046d8f050032da24ad2d
Fix:
====