Skip to content

fix(security): extend IPC sender validation to ipcMain.on channels#2387

Merged
gregpriday merged 1 commit intodevelopfrom
feature/issue-2374-extend-ipc-sender-validation
Feb 27, 2026
Merged

fix(security): extend IPC sender validation to ipcMain.on channels#2387
gregpriday merged 1 commit intodevelopfrom
feature/issue-2374-extend-ipc-sender-validation

Conversation

@gregpriday
Copy link
Copy Markdown
Collaborator

Summary

Extends enforceIpcSenderValidation() in electron/main.ts to cover all ipcMain.on fire-and-forget channels, closing the security gap identified in #2374.

Closes #2374

Changes Made

  • Patch ipcMain.on to wrap every registered listener with a sender validation check against isTrustedRendererUrl; messages from untrusted origins are silently dropped with a console.warn (fire-and-forget channels have no error return path)
  • Maintain a Map<channel, Map<originalListener, wrappedListener>> so ipcMain.removeListener and ipcMain.off can resolve the correct wrapped function — preserving cleanup semantics across all handler files without requiring changes to callers
  • Patch ipcMain.removeListener to look up and remove the wrapped version from the EventEmitter when a mapped entry exists
  • Alias ipcMain.off to the patched removeListener
  • Patch ipcMain.removeAllListeners to clear map entries; uses explicit channel !== undefined guard so empty-string channel names are handled correctly

- Patch ipcMain.on to validate event.senderFrame.url against trusted
  origins before executing fire-and-forget handlers; untrusted messages
  are silently dropped with a console.warn
- Maintain a per-channel listener map so ipcMain.removeListener/off can
  resolve the wrapped function from the original listener reference,
  preserving cleanup semantics in all handler files
- Patch ipcMain.removeListener to look up and remove wrapped versions
- Alias ipcMain.off to the patched removeListener
- Patch ipcMain.removeAllListeners to clear map entries; use explicit
  undefined check so empty-string channel names are handled correctly

Closes #2374
@gregpriday gregpriday merged commit 9fd4dfb into develop Feb 27, 2026
@gregpriday gregpriday deleted the feature/issue-2374-extend-ipc-sender-validation branch February 27, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend IPC sender validation to cover ipcMain.on fire-and-forget channels

1 participant