overlay.windows.createWindow or overlay.windows.createInGameWindow is automatically
hardened against malicious navigation — most notably ad creatives that attempt to take over the window or open
unwanted sites. There is nothing to enable; this page describes the default policy and how to customize it.
Default Policy
Main-frame navigation
Top-frame navigation (will-navigate and main-frame redirects) is only permitted within allowed origins:
- Your application’s own origin (the site URL configured in the Overlayed Dashboard)
- The origin currently loaded in the window — so local dev servers and custom URLs keep working
- Any hosts you list in
allowedHosts
Sub-frame navigations are intentionally untouched, so ad iframes keep loading cross-origin creatives normally.
loadURL with a URL that redirects
(for example, a loading page handing off to your site) is trusted and unaffected.
New windows
window.open and target="_blank" links are handled per-URL:
Opening unknown web URLs in the system browser preserves legitimate ad clickthroughs (advertiser domains are
unpredictable) while making an in-app takeover impossible. Windows opened in-app are guarded by the same policy (plus
the origin they were opened with), so the page that opened one can’t redirect or navigate it somewhere else.
User activation
Electron has no popup blocker. Unlike a browser, it lets any frame callwindow.open at any time, whether or not the
user clicked anything, which is exactly what malvertising does to force a redirect. The guard makes up for it: an
unknown web URL only opens in the system browser if the window received a click or key press in the last 5 seconds
(Chromium’s own user activation lifespan), and each click opens at most one popup.
Once something in the window tries to open a popup without user activation, clicks made during the next 10 seconds don’t
open popups, even after those 10 seconds are up. That way the offending frame can’t ride the user’s next click
somewhere else in the window.
Clicks inside cross-origin iframes (where most ad creatives render) are only visible to the guard on Electron 37 and
later. On older versions, clicking such an ad does not open its landing page.
Tracking
Every blocked navigation and external open is logged with its URL and tracked via Cortex (navigation_blocked,
window_open_external, window_open_denied), so a malicious creative can be identified and reported to the ad
provider. window_open_denied includes a reason: no_user_activation and popup_cooldown point to a creative
opening popups on its own.
Customizing the Policy
Configure the guard via thenavigationGuard option of the overlayed function.
allowedHosts
Hosts the main frame may navigate to in addition to the defaults. Use this for legitimate top-frame cross-origin flows such as OAuth redirects. Matched againstURL.host (hostname + port).
windowOpenHandler
Overrides the defaultwindow.open policy per-URL. Return "allow" (open in-app), "external" (open in the system
browser, without requiring user activation), "deny" (block entirely), or undefined to fall back to the default
policy.
As a safety net,
"external" is only honored for http/https URLs — the guard never hands other schemes to the
operating system, since that would launch whatever protocol handler is registered for them.
