Skip to main content

no-electron-unchecked-ipc-sender

Disallow privileged Electron IPC handlers that do not validate the sender.

Targeted pattern scopeโ€‹

ipcMain.on/ipcMain.handle callbacks without sender/frame trust validation.

What this rule reportsโ€‹

Privileged IPC handlers that process requests without checking sender origin/frame trust.

Why this rule existsโ€‹

Unvalidated IPC senders can let compromised renderers invoke privileged main-process operations.

โŒ Incorrectโ€‹

ipcMain.handle("read-file", async (event) => readFile("secret.txt"));

โœ… Correctโ€‹

ipcMain.handle("read-file", async (event) => {
if (!event.senderFrame?.url?.startsWith("https://example.com")) return null;
return "ok";
});

ESLint flat config exampleโ€‹

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

export default [
{
plugins: { sdl },

rules: {
"sdl/no-electron-unchecked-ipc-sender": "error",
},
},
];

When not to use itโ€‹

Disable only if IPC sender trust is enforced by a reviewed abstraction that this rule cannot currently observe.

Package documentationโ€‹

Further readingโ€‹

Rule catalog ID: R036