Vulnerabilities > CVE-2017-16666 - OS Command Injection vulnerability in Xplico

047910
CVSS 9.0 - CRITICAL
Attack vector
NETWORK
Attack complexity
LOW
Privileges required
SINGLE
Confidentiality impact
COMPLETE
Integrity impact
COMPLETE
Availability impact
COMPLETE
network
low complexity
xplico
CWE-78
critical
exploit available
metasploit

Summary

Xplico before 1.2.1 allows remote authenticated users to execute arbitrary commands via shell metacharacters in the name of an uploaded PCAP file. NOTE: this issue can be exploited without authentication by leveraging the user registration feature.

Vulnerable Configurations

Part Description Count
Application
Xplico
1

Common Attack Pattern Enumeration and Classification (CAPEC)

  • Command Line Execution through SQL Injection
    An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.
  • Command Delimiters
    An attack of this type exploits a programs' vulnerabilities that allows an attacker's commands to be concatenated onto a legitimate command with the intent of targeting other resources such as the file system or database. The system that uses a filter or a blacklist input validation, as opposed to whitelist validation is vulnerable to an attacker who predicts delimiters (or combinations of delimiters) not present in the filter or blacklist. As with other injection attacks, the attacker uses the command delimiter payload as an entry point to tunnel through the application and activate additional attacks through SQL queries, shell commands, network scanning, and so on.
  • Exploiting Multiple Input Interpretation Layers
    An attacker supplies the target software with input data that contains sequences of special characters designed to bypass input validation logic. This exploit relies on the target making multiples passes over the input data and processing a "layer" of special characters with each pass. In this manner, the attacker can disguise input that would otherwise be rejected as invalid by concealing it with layers of special/escape characters that are stripped off by subsequent processing steps. The goal is to first discover cases where the input validation layer executes before one or more parsing layers. That is, user input may go through the following logic in an application: In such cases, the attacker will need to provide input that will pass through the input validator, but after passing through parser2, will be converted into something that the input validator was supposed to stop.
  • Argument Injection
    An attacker changes the behavior or state of a targeted application through injecting data or command syntax through the targets use of non-validated and non-filtered arguments of exposed services or methods.
  • OS Command Injection
    In this type of an attack, an adversary injects operating system commands into existing application functions. An application that uses untrusted input to build command strings is vulnerable. An adversary can leverage OS command injection in an application to elevate privileges, execute arbitrary commands and compromise the underlying operating system.

Exploit-Db

descriptionXplico - Remote Code Execution (Metasploit). CVE-2017-16666. Remote exploit for Linux platform. Tags: Metasploit Framework (MSF)
fileexploits/linux/remote/43430.rb
idEDB-ID:43430
last seen2018-01-24
modified2018-01-04
platformlinux
port9876
published2018-01-04
reporterExploit-DB
sourcehttps://www.exploit-db.com/download/43430/
titleXplico - Remote Code Execution (Metasploit)
typeremote

Metasploit

descriptionThis module exploits command injection vulnerability. Unauthenticated users can register a new account and then execute a terminal command under the context of the root user. The specific flaw exists within the Xplico, which listens on TCP port 9876 by default. The goal of Xplico is extract from an internet traffic capture the applications data contained. There is a hidden end-point at inside of the Xplico that allow anyone to create a new user. Once the user created through /users/register endpoint, it must be activated via activation e-mail. After the registration Xplico try to send e-mail that contains activation code. Unfortunetly, this e-mail probably not gonna reach to the given e-mail address on most of installation. But it's possible to calculate exactly same token value because of insecure cryptographic random string generator function usage. One of the feature of Xplico is related to the parsing PCAP files. Once PCAP file uploaded, Xplico execute an operating system command in order to calculate checksum of the file. Name of the for this operation is direclty taken from user input and then used at inside of the command without proper input validation.
idMSF:EXPLOIT/LINUX/HTTP/XPLICO_EXEC
last seen2020-06-12
modified2017-11-14
published2017-11-14
references
reporterRapid7
sourcehttps://github.com/rapid7/metasploit-framework/blob/master//modules/exploits/linux/http/xplico_exec.rb
titleXplico Remote Code Execution

Packetstorm

data sourcehttps://packetstormsecurity.com/files/download/145639/xplico_exec.rb.txt
idPACKETSTORM:145639
last seen2018-01-04
published2018-01-04
reporterMehmet Ince
sourcehttps://packetstormsecurity.com/files/145639/Xplico-Remote-Code-Execution.html
titleXplico Remote Code Execution

Seebug

bulletinFamilyexploit
descriptionThe goal of Xplico is extract from an internet traffic capture the applications data contained. For example, from a pcap file Xplico extracts each email (POP, IMAP, and SMTP protocols), all HTTP contents, each VoIP call (SIP), FTP, TFTP, and so on. Xplico isn’t a network protocol analyzer. Xplico is an open source Network Forensic Analysis Tool (NFAT). ### Advisory Informations Remotely Exploitable: Yes Authentication Required: NO Vendor URL: www.xplico.org CVSSv3 Score: 9.0 (CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H/E:H/RL:U) Date of found: 31 Oct 2017 ### Technical Details We identified three different vulnerability. Combination of these three vulnerability leadto unauthenticated remote root code execution vulnerability. #### Vulnerability #1 – Hidden User Registration Feature There is a hidden end-point at inside of the Xplico that allow anyone to create a new user. You can access this registration form by visiting following URL. `http://<ip_address>:9876/users/register` ![](https://images.seebug.org/1510725304013) #### Vulnerability #2 – Weak Randomization Algorithm used during Activation Code Generation Once the user created through /users/register endpoint. This user must be activated through activation e-mail. ``` if ($this->Group->save($this->request->data)) { $this->request->data['User']['password'] = md5($this->request->data['User']['password']); $this->request->data['User']['em_key'] = md5($this->request->data['User']['email'].$this->request->data['User']['password'].time()); $gid = $this->Group->getID(); $this->request->data['User']['group_id'] = $gid; $this->User->create(); if ($this->User->save($this->request->data)) { if (1) { // send email to confirm registration mail($this->request->data['User']['email'], "Xplico - Account Activation Request", "To confirm click the link below\n http://demo.xplico.org/users/registerConfirm/".$this->request->data['User']['em_key']."\n", "From: [email protected]"); $this->Session->setFlash(__('To complete registration wait the email')); } else { $this->Session->setFlash(__('Registration Completed')); $this->User->saveField('em_checked', 1); } $this->redirect('/users/index'); } else { $this->Group->delete($gid); $this->Session->setFlash(__('There was a problem saving this information')); } } ``` Activation code of the user stored at em_key field of the database. And then Xplico try to send e-mail that contains this code. Unfortunately, this e-mail probably not gonna reach to the given e-mail address on most of the installation. But there is an easy way to calculate exactly same value without having e-mail! ``` md5($this->request->data['User']['email'].$this->request->data['User']['password'].time()); ``` Look closer to the above code where you will see md5 function call for em_key generation. `$this->request->data['User']['email']:` It’s an user input. We know that value. `$this->request->data['User']['password']` :It’s another user input. We know that value too. `time()` : This function return current time as a unixtime format. But it does’nt contains miliseconds! So once we recieve a http response from server, we can look at the Date header and calculate exact value as long as execution finished within 1 second. Here is the http POST request to the user register endpoint. Red colored boxes Show email and password fields being used for em_key generation. ``` POST /users/register HTTP/1.1 Host: 12.0.0.41:9876 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36 Accept: text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Content-Length: 338 Upgrade-Insecure-Requests: 1 _method=POST&data[_Token][key]=a84ad2730fdd215f7795a2cf14feb8c2788c6ff5d2d1d8e839736cb4626ce48c1b63ee6c798cd1a6de15f88314dd39f2a1fdf10cbf412c37eda882dfb0120c97&data[User][email][email protected]&data[User][username]=hacker&data[User][password]=123456&data[_Token][fields]=57a700573f4839c45778a5dee8b04184f40c6481:&data[_Token][unlocked]= ``` Here is the http response from the end-point. It redirect us back to the login page. If that response-response cycle completed within 1 second, that Date value must be same with time() function call result during em_key generation. ``` HTTP/1.1 302 Found Date: Tue, 31 Oct 2017 08:33:01 GMT Server: Apache/2.4.7 (Ubuntu) X-Frame-Options: SAMEORIGIN Strict-Transport-Security: max-age=31536000; include Subdomains; X-Powered-By: PHP/5.5.9-1ubuntu4.22 Location: http://12.0.0.41:9876/users/index X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8 ``` Here is the small PoC code for em_key calculation without receving any e-mail. ``` <?php $email = "[email protected]"; $password = "123456"; $token = md5($email.md5($password).strtotime("Tue, 31 Oct 2017 08:33:01 GMT")); echo $token; ``` #### Vulnerability #3 – Authenticated Command Injection One of the feature of the Xplico is related to the parsing PCAP files. You can upload pcap file through following module. This module is password protected. ![](https://images.seebug.org/1510725442406) Once pcap file uploaded, following operating system command will be executed. ``` sh –c md5sum “/opt/xplico/pol_1/sol_1/new/[NAME_OF_PCAP_FILE]” > /tmp/dema_hash.txt ``` So file name (which is directly taken from user input) will be used at inside of above command. By using $() or “ trick for filename, we can execute our own operating system commands. ### Metasploit Module Here is the metasploit module that automates all steps together. https://github.com/rapid7/metasploit-framework/pull/9206 ### Mitigation Timeline We’ve found these vulnerabilities during security review of SecurityOnion product. For that reason, we did get in touch with them. * 29 October 2017 22:31 – Finding 0day and metasploit module implmenetation. * 30 October 2017 11:12 – All the details are shared with members of GPACT/USTA platforms. * 8 November 2017 10:31 – First contact with SecurityOnion via [email protected] * 8 November 2017 14:30 – Reply from Doug Burks, CEO of Security Onion Solutions, LLC. * 8 November 2017 14:39 – Doug Burks helped us to get in touch with Xplico maintainer, Gianluca Costa. * 8 November 2017 14:53 – Doug Burks wanted to take extra action while waiting full fix from Xplico team. They decided to remove Xplico dependency from their project and disable user registrations feature of Xplico. * 8 November 2017 15:13 – We provided root cause analysis of the issue as well as how to fix them. * 8 November 2017 16:30 – Doug Burks took the actions we provided and released a new version for Xplico for testing purpose. * 8 November 2017 20:30 – CVE-2017-16666 number assigned. * 8 November 2017 20:33 – Received reply from Gianluca Costa. He shared his own actions plans with us. * 8 November 2017 21:47 – We also provided source code that fix these three vulnerability. * 13 November 2017 00:53 – Thanks to Gianluca Costa. He mitigated command injection issue on the weekend. * 13 November 2017 15:02 – Doug Burks released a new testing version of Xplico for SecurityOnion and shared with us in order to make sure all issues patched properly. * 13 November 2017 21:09 – Xplico released version 1.2.1 * 13 November 2017 22:30 – SecurityOnion released new build
idSSV:96864
last seen2017-11-19
modified2017-11-15
published2017-11-15
reporterRoot
sourcehttps://www.seebug.org/vuldb/ssvid-96864
titleXplico Unauthenticated Remote Code Execution(CVE-2017-16666)