Skip to main content

no-electron-unrestricted-navigation

Disallow Electron navigation handlers that allow unrestricted navigation or window creation.

Targeted pattern scopeโ€‹

Electron navigation/open handlers that allow unrestricted navigation behavior.

What this rule reportsโ€‹

setWindowOpenHandler returning allow, or will-navigate handlers that do not block by default.

Why this rule existsโ€‹

Unrestricted navigation can enable tabnabbing, phishing surfaces, and privilege-boundary bypasses.

โŒ Incorrectโ€‹

contents.setWindowOpenHandler(() => ({ action: "allow" }));

โœ… Correctโ€‹

contents.on("will-navigate", (event, url) => {
event.preventDefault();
if (url === "https://example.com") {
/* reviewed allowlist path */
}
});

ESLint flat config exampleโ€‹

import sdl from "eslint-plugin-sdl-2";

export default [
{
plugins: { sdl },

rules: {
"sdl/no-electron-unrestricted-navigation": "error",
},
},
];

When not to use itโ€‹

Disable only if navigation and window-opening are governed by a reviewed allowlist abstraction outside the immediate handler.

Package documentationโ€‹

Further readingโ€‹

Rule catalog ID: R037