no-electron-disable-web-security
Disallow disabling Electron webPreferences.webSecurity for renderer contexts.
Targeted pattern scopeโ
This rule targets Electron BrowserWindow and BrowserView constructor options
that set webPreferences.webSecurity to false.
What this rule reportsโ
This rule reports webPreferences.webSecurity: false in Electron renderer
configuration objects.
Why this rule existsโ
Turning off webSecurity removes browser-origin protections and expands the
attack surface for untrusted renderer content.
โ Incorrectโ
new BrowserWindow({
webPreferences: {
webSecurity: false,
},
});
โ Correctโ
new BrowserWindow({
webPreferences: {
webSecurity: true,
},
});
ESLint flat config exampleโ
import sdl from "eslint-plugin-sdl-2";
export default [
{
plugins: { sdl },
rules: {
"sdl/no-electron-disable-web-security": "error",
},
},
];
When not to use itโ
Disable only for tightly controlled offline renderer scenarios with explicit compensating controls and no untrusted content.
Package documentationโ
Further readingโ
Rule catalog ID: R013