Skip to main content

no-electron-insecure-permission-request-handler

Disallow Electron permission request handlers that blanket-allow permissions.

Targeted pattern scopeโ€‹

Electron permission handlers that blanket-allow permission requests.

What this rule reportsโ€‹

setPermissionRequestHandler callbacks that unconditionally callback(true) or return true.

Why this rule existsโ€‹

Blindly granting permissions can expose camera, microphone, clipboard, and notification abuse vectors.

โŒ Incorrectโ€‹

session.defaultSession.setPermissionRequestHandler(
(wc, permission, callback) => {
callback(true);
}
);

โœ… Correctโ€‹

session.defaultSession.setPermissionRequestHandler(
(wc, permission, callback) => {
callback(permission === "notifications");
}
);

ESLint flat config exampleโ€‹

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

export default [
{
plugins: { sdl },

rules: {
"sdl/no-electron-insecure-permission-request-handler": "error",
},
},
];

When not to use itโ€‹

Disable only if the runtime has a reviewed permission policy that intentionally allows a constrained set of requests.

Package documentationโ€‹

Further readingโ€‹

Rule catalog ID: R035