Skip to content
RCE Write-up Advanced

Subverting Electron Apps via Insecure Preload

Insecure preload scripts in Electron apps exposed privileged Node.js APIs to untrusted renderer code, allowing an attacker with XSS to achieve arbitrary file write in WireApp and arbitrary IPC to execute binaries in Discord.

blog.doyensec.com

Published on blog.doyensec.com

We’re back from BlackHat Asia 2019 where we introduced a relatively unexplored class of vulnerabilities affecting Electron-based applications.

Luca Carettoni, on blog.doyensec.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the preload scripts exposed Node.js primitives and internal IPC channels to the renderer without proper isolation, letting untrusted code abuse them.

Impact

An attacker could write arbitrary files (WireApp) or execute arbitrary binaries (Discord) on all supported platforms, though on macOS the sandbox may require chaining with another bug to write outside app folders.

What the attacker needed

XSS in the renderer; Electron app with insecure preload

The fix

The issues were fixed by security patches released by both vendors.

How it was found

  1. Open the developer tools on the webview in the messages view.
  2. Override the winston logger transport to write to a chosen file.
  3. Trigger a log error to write the file.
  4. For Discord, send an IPC message to require child_process.
  5. Brute-force the reference ID and call exec with a command.

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 write-up has not been written yet. The Original tab links to the source.

Electron apps are built with web pages, and a preload script runs before the page loads to give it extra powers. If that script accidentally exposes powerful functions to the page, a cross-site scripting (XSS) bug in the page lets an attacker use those powers to run code on the computer.

What is RCE?

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

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.