diff --git a/src/main/core/ipc/IPCManager.ts b/src/main/core/ipc/IPCManager.ts index f23acbcd..95195b25 100644 --- a/src/main/core/ipc/IPCManager.ts +++ b/src/main/core/ipc/IPCManager.ts @@ -23,7 +23,13 @@ export class IPCManager { ...args: ExtractArgs[E] ) => void | Promise ): void { - this.listener.on(channel, listener) + this.listener.on(channel, (e, ...args) => { + if (!this.isTrustedSender(e.sender)) { + console.warn(`Blocked untrusted IPC event on channel: ${String(channel)}`) + return + } + return listener(e, ...args) + }) } handle>( @@ -35,7 +41,12 @@ export class IPCManager { | ReturnType[E]> | Promise[E]>> ): void { - this.listener.handle(channel, listener) + this.listener.handle(channel, async (e, ...args) => { + if (!this.isTrustedSender(e.sender)) { + throw new Error(`Unauthorized IPC sender for channel: ${String(channel)}`) + } + return listener(e, ...args) + }) } dispose(): void {