no-electron-insecure-certificate-error-handler
Disallow Electron certificate-error handlers that explicitly trust invalid certificates.
Targeted pattern scopeโ
This rule targets .on("certificate-error", handler) registrations where the
handler callback is called with true.
What this rule reportsโ
This rule reports certificate-error handlers that invoke the callback with
true, which accepts invalid certificates.
Why this rule existsโ
The certificate-error event should be handled conservatively. Calling the
callback with true bypasses certificate validation and can enable active
man-in-the-middle interception.
โ Incorrectโ
app.on(
"certificate-error",
(_event, _webContents, _url, _error, _certificate, callback) => {
callback(true);
}
);
โ Correctโ
app.on(
"certificate-error",
(_event, _webContents, _url, _error, _certificate, callback) => {
callback(false);
}
);
ESLint flat config exampleโ
import sdl from "eslint-plugin-sdl-2";
export default [
{
plugins: { sdl },
rules: {
"sdl/no-electron-insecure-certificate-error-handler": "error",
},
},
];
When not to use itโ
Disable only if your runtime deliberately implements certificate pinning or enterprise trust logic outside this callback path and has security sign-off.
Package documentationโ
Further readingโ
Rule catalog ID: R015