Modern Alchemy: Turning XSS into RCE
Electron's BrowserWindowProxy allowed a child window to be manipulated across origins, and a privileged chrome-devtools URL could be opened to override the nodeIntegration setting. An attacker who could run JavaScript in a page (for example via XSS) could then execute native commands on the host.
blog.doyensec.com
Published on blog.doyensec.com
At the recent Black Hat Briefings 2017, Doyensec’s co-founder Luca Carettoni presented a new research on Electron security. After a quick overview of Electron’s security model, we disclosed design weaknesses and implementation bugs that can be leveraged to compromise any Electron-based application.
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 BrowserWindowProxy object let a parent window evaluate code in a child window regardless of origin, and a privileged chrome-devtools URL was reachable from untrusted content, allowing nodeIntegration to be re-enabled.
Impact
Any Electron app rendering untrusted content could be fully compromised, turning an XSS into native code execution, and all versions before 1.6.8 were affected.
What the attacker needed
Ability to run JavaScript in rendered content; Electron before 1.6.8; nodeIntegration disabled but not sandboxed
The fix
The privileged URL was restricted and the issue was fixed in Electron 1.6.8; the post also recommends updating Electron, secure coding, defence in depth and enabling the sandbox.
How it was found
- Open a new window to an attacker-controlled or untrusted page.
- Use the returned window proxy to run script in that child window.
- Open the privileged chrome-devtools URL in the child window.
- Evaluate code that requires Electron's shell module and launches a local application.
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 is a framework that lets desktop apps be built with web technology. Normally a web page is not allowed to touch another site's page, but Electron's window-opening feature broke that rule. By opening a special internal page, the attacker's script could turn on Node.js access and run programs 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.