Skip to content

ElectroVolt: Pwning Popular Desktop Apps While Uncovering New Attack Surface on Electron

William BowlingMax GarrettAaditya Purani

ReconBlack Hat USA 202239 minAdvancedOpen on YouTube ↗

Explores electroVolt: Pwning Popular Desktop Apps While Uncovering New Attack Surface on Electron and evaluates key implications for security practitioners.

Summary

Overview: Aaditya Purani and Max Garrett present ElectroVolt, a comprehensive study of the attack surface within Electron-based desktop applications like Microsoft Teams, Discord, Slack, and Visual Studio Code. The researchers analyze how Electron merges Chromium rendering capabilities with Node.js operating system privileges, dissecting the security boundaries defined by webPreferences. The presentation demonstrates how an attacker can bypass modern Electron sandbox protections, pivoting from a heavily constrained Cross-Site Scripting (XSS) flaw in Visual Studio Code's Restricted Mode into full Remote Code Execution (RCE).

Key Topics: - Electron architecture: Main process, Renderer processes, and IPC mechanisms - Core security controls: nodeIntegration, contextIsolation, and sandbox - Visual Studio Code Restricted Mode security architecture - Multi-stage exploit chaining from restricted markdown preview to arbitrary command execution

Technical Details: The presentation details Electron's dual-process architecture comprising a single, highly privileged Main process (managing application lifecycles, native GUI elements, and IPC main listeners) and multiple Chromium-based Renderer processes. Security posture is governed by flags configured in the webPreferences dictionary: nodeIntegration, contextIsolation, and sandbox. In legacy or misconfigured deployments where nodeIntegration is true and contextIsolation is false, any XSS vulnerability directly yields Remote Code Execution because the web page has unrestricted access to Node.js APIs (e.g., executing system commands via require('child_process').exec). Modern applications mitigate this by isolating execution into separate JavaScript contexts via contextIsolation and exposing controlled functionality through preload.js scripts using contextBridge.

To evaluate security in hardened environments, the authors analyzed Microsoft Visual Studio Code (VS Code), which features a Restricted Mode designed to safely browse untrusted repositories by preventing automatic code execution. The researchers constructed a multi-stage exploit chain that completely compromised Restricted Mode starting from a basic markdown file (.md). Although the VS Code markdown previewer executes within a highly constrained sandbox governed by a strict Content Security Policy (CSP), the researchers bypassed the CSP by injecting a <meta http-equiv="refresh"> redirect tag, routing the iframe to an attacker-controlled external domain where arbitrary JavaScript could run.

From this external context, the exploit initiated cross-frame attacks across VS Code's internal window structure. First, the researchers leaked the target installation's unique, unguessable internal extension identifier. Next, they leveraged a cross-frame postMessage call to exploit an XSS vulnerability within a secondary internal frame (vscode-webview). Within this webview, they deployed a secondary payload invoking channel.doRead to exfiltrate the victim's local project directory path via the custom vscode-file: protocol—which, unlike standard file:// URIs, permits cross-origin invocations. Finally, the payload performed path traversal attacks (../) over the vscode-file: scheme to access privileged frames running with nodeIntegration: true, successfully executing arbitrary operating system commands on the host machine.

Key Takeaways: Desktop application developers using Electron cannot rely solely on partial sandboxing or restricted viewing modes while exposing custom internal URI schemes and permissive IPC communication bridges. Custom internal protocols like vscode-file: must enforce strict origin validation and path traversal protections to prevent cross-origin directory leaks and file access. Cross-frame postMessage handlers in multi-frame Electron architectures must strictly validate message origins and payload schemas to prevent cross-context privilege escalation.

(AI summary — Gemini Flash)

Related talks