mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: strictly validate sender for internal IPC reply channels (#50160)
fix: strictly validate sender for internal IPC reply channels (#50118) The sender-mismatch check in invokeInWebContents and invokeInWebFrameMain used a negative condition (`type === 'frame' && sender !== expected`), which only rejected mismatched frame senders and accepted anything else. Invert to a positive check so only the exact expected frame can resolve the reply — matches the guard style used elsewhere in lib/browser/. Co-authored-by: Samuel Attard <sam@electronjs.org>
This commit is contained in:
@@ -19,8 +19,8 @@ export function invokeInWebContents<T> (sender: Electron.WebContents, command: s
|
||||
const requestId = ++nextId;
|
||||
const channel = `${command}_RESPONSE_${requestId}`;
|
||||
ipcMainInternal.on(channel, function handler (event, error: Error, result: any) {
|
||||
if (event.type === 'frame' && event.sender !== sender) {
|
||||
console.error(`Reply to ${command} sent by unexpected WebContents (${event.sender.id})`);
|
||||
if (event.type !== 'frame' || event.sender !== sender) {
|
||||
console.error(`Reply to ${command} sent by unexpected sender`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user