BTC
ETH
SOL
BNB
GOLD
XRP
DOGE
ADA
Back to home
Security

[MEDIUM] Security Advisory: Electron: Named window.open targets not scoped to the opener’s browsing context (electron, electron, electron)

Electron just patched a vulnerability that lets one renderer process hijack a pop-up window opened by another.

Electron just patched a vulnerability that lets one renderer process hijack a pop-up window opened by another. If your app uses multiple top-level windows with different security levels and customizes child window permissions via setWindowOpenHandler, malicious code could navigate into a privileged child window using the same target name.

This flaw stems from Electron’s failure to scope named window lookups to the opener’s browsing context group. Normally, window.open() with a target like "_blank" or a custom name should only find windows in the same context. Here, unrelated renderers sharing a name could interfere. The second renderer then loads content into that window, inheriting any elevated webPreferences like privileged preload scripts.

Affected Apps and Real Risks

Not every Electron app faces danger. You need three conditions: multiple top-level windows at varying trust levels, setWindowOpenHandler granting child windows looser rules than parents, and untrusted content calling window.open(). Apps sticking to one window or equal privileges across the board dodge this entirely.

The worst case? If child windows get nodeIntegration: true or sandbox: false, attackers gain arbitrary code execution. Electron’s docs explicitly warn against this—it’s a red flag for sloppy security. Think Discord, Slack, VS Code: millions use these daily. A compromised renderer (say, via malicious extension or site) could escalate to full app control, stealing data or running malware.

Electron powers over 50 popular desktop apps as of 2024, per their site. Historical vulns like prototype pollution (CVE-2023-28121) and renderer escapes show Node.js integration creates attack surfaces. This bug reinforces that: devs chasing features often ignore context isolation, Chromium’s key defense. Stats from Electron’s security advisories: 20+ high-severity issues since 2020, mostly privilege escalations.

Patches and Workarounds

Update immediately. Fixed versions: 42.0.0-alpha.5, 41.1.0, 40.8.5, 39.8.5. Earlier branches like 31.x or 30.x? Backport soon or switch tracks. Check Electron’s release page for your branch.

Workarounds now: In setWindowOpenHandler, return { action: 'deny' } for untrusted renderers. Never give child windows laxer webPreferences than openers—match or tighten them. Audit your code: grep for window.open and setWindowOpenHandler.

app.on('web-contents-created', (event, contents) => {
  contents.setWindowOpenHandler(({ url }) => {
    if (untrustedOrigin(url)) {
      return { action: 'deny' };
    }
    return {
      action: 'allow',
      overrideBrowserWindowOptions: {
        webPreferences: { /* match opener's strict settings */ }
      }
    };
  });
});

Example above blocks pop-ups from shady sources and enforces consistent prefs.

Why This Matters for Devs and Users

Electron’s convenience—web tech for desktops—breeds insecure apps. This vuln exposes devs skimping on isolation. Users: update apps pronto; many auto-update via Squirrel or similar, but check manually for Discord (v1.0.9000+ uses Electron 31), VS Code (1.93+).

Broader lesson: treat renderers as hostile. Enable contextIsolation, preload scripts for APIs, sandbox everything. Electron’s security survey (2023) found 40% of apps enable Node in renderers—prime vuln fodder. Forward-thinking? Migrate sensitive ops to main process or Tauri/WebView alternatives with tighter sandboxes.

Email security@electronjs.org for details. Stay vigilant—desktop web apps won’t secure themselves.

April 7, 2026 · 3 min · 10 views · Source: GitHub Security

Related