Skip to content

fix: check the sending frame for internal guest, window and reply IPCs - #53684

Merged
MarshallOfSound merged 3 commits into
mainfrom
fix/internal-ipc-sender-frame
Sep 7, 2026
Merged

MarshallOfSound merged 3 commits into
mainfrom
fix/internal-ipc-sender-frame

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Sep 7, 2026 •

Copy link
Copy Markdown
Member
  • Internal guest-view IPCs (attach/detach/call/property get/set) are honoured only from the frame that created the <webview>.
  • The internal window.close() IPC is honoured only from the top-level document; replies to webContents.executeJavaScript() / insertCSS() are accepted only from the frame they were sent to; webContents.sendToFrame() only addresses frames of that WebContents; process.getProcessMemoryInfo() is scoped to the caller's process.
  • Docs: the security.md sender-validation example checks senderFrame.origin; webview-tag.md points at the main-process ipc-message event for identifying the sending frame.

Notes: Internal <webview>, window.close() and executeJavaScript reply IPCs are validated against the sending frame.

* guest-view IPCs (attach/detach/call/property get/set) are honoured only
  from the frame that created the <webview>, not from any frame in the
  embedder WebContents
* window.close() via the internal IPC is honoured only from the top-level
  document, and the renderer override is installed for the main frame only
* replies to webContents.executeJavaScript()/insertCSS() and friends are
  accepted only from the main frame they were sent to
* webContents.sendToFrame() only addresses frames that belong to that
  WebContents
* the <webview> `ipc-message` event carries `frameOrigin` / `frameUrl` of the
  frame in the guest that sent it
* process.getProcessMemoryInfo() reports the calling frame's own process
* docs: validateSender example checks senderFrame.origin
@MarshallOfSound
MarshallOfSound requested a review from a team as a code owner September 7, 2026 15:59
@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 7, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Sep 7, 2026
@MarshallOfSound MarshallOfSound self-assigned this Sep 7, 2026
@MarshallOfSound
MarshallOfSound merged commit 8cc20cf into main Sep 7, 2026
133 of 135 checks passed
@release-clerk

release-clerk Bot commented Sep 7, 2026

Copy link
Copy Markdown

Release Notes Persisted

Internal &lt;webview&gt;, window.close() and executeJavaScript reply IPCs are validated against the sending frame.

@MarshallOfSound
MarshallOfSound deleted the fix/internal-ipc-sender-frame branch September 7, 2026 22:49
@github-actions github-actions Bot added the 46-x-y label Sep 7, 2026
@trop

trop Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "42-x-y" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "43-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/42-x-y needs-manual-bp/43-x-y and removed target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. labels Sep 7, 2026
@trop

trop Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #53723

@trop trop Bot added the in-flight/44-x-y label Sep 7, 2026
@trop

trop Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #53724

@trop trop Bot added in-flight/45-x-y and removed target/44-x-y PR should also be added to the "44-x-y" branch. labels Sep 7, 2026
@trop trop Bot removed the target/45-x-y PR should also be added to the "45-x-y" branch. label Sep 7, 2026
@trop

trop Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "43-x-y", please check out #53726

@trop

trop Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "42-x-y", please check out #53727

MarshallOfSound added a commit that referenced this pull request Sep 8, 2026
…s (42-x-y) (#53727)

fix: check the sending frame for internal guest, window and reply IPCs (#53684)

* fix: check the sending frame for internal guest, window and reply IPCs

* guest-view IPCs (attach/detach/call/property get/set) are honoured only
  from the frame that created the <webview>, not from any frame in the
  embedder WebContents
* window.close() via the internal IPC is honoured only from the top-level
  document, and the renderer override is installed for the main frame only
* replies to webContents.executeJavaScript()/insertCSS() and friends are
  accepted only from the main frame they were sent to
* webContents.sendToFrame() only addresses frames that belong to that
  WebContents
* the <webview> `ipc-message` event carries `frameOrigin` / `frameUrl` of the
  frame in the guest that sent it
* process.getProcessMemoryInfo() reports the calling frame's own process
* docs: validateSender example checks senderFrame.origin

* docs: add API history PR reference

* refactor: drop frameOrigin/frameUrl from the webview ipc-message event

(cherry picked from commit 8cc20cf)
@trop trop Bot added merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/42-x-y labels Sep 8, 2026
MarshallOfSound added a commit that referenced this pull request Sep 8, 2026
…s (43-x-y) (#53726)

fix: check the sending frame for internal guest, window and reply IPCs (#53684)

* fix: check the sending frame for internal guest, window and reply IPCs

* guest-view IPCs (attach/detach/call/property get/set) are honoured only
  from the frame that created the <webview>, not from any frame in the
  embedder WebContents
* window.close() via the internal IPC is honoured only from the top-level
  document, and the renderer override is installed for the main frame only
* replies to webContents.executeJavaScript()/insertCSS() and friends are
  accepted only from the main frame they were sent to
* webContents.sendToFrame() only addresses frames that belong to that
  WebContents
* the <webview> `ipc-message` event carries `frameOrigin` / `frameUrl` of the
  frame in the guest that sent it
* process.getProcessMemoryInfo() reports the calling frame's own process
* docs: validateSender example checks senderFrame.origin

* docs: add API history PR reference

* refactor: drop frameOrigin/frameUrl from the webview ipc-message event

(cherry picked from commit 8cc20cf)
@trop trop Bot added merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. and removed in-flight/43-x-y in-flight/44-x-y in-flight/45-x-y labels Sep 8, 2026
jkleinsc pushed a commit that referenced this pull request Sep 18, 2026
)

Removing a <webview> from the DOM tears down its internal iframe first,
which destroys the guest and drops it from guestInstances. The element's
disconnectedCallback then sends GUEST_VIEW_MANAGER_DETACH_GUEST for that
id. Since #53684 the handler validates the id with getGuestForFrame()
before detaching, so the already-gone guest made the sync IPC throw back
into disconnectedCallback. The uncaught error also skipped the element's
reset, so a removed <webview> that was re-inserted never got a new guest.

Treat a detach for an unknown guest as a no-op again (as detachGuest()
always did) and keep the sender-frame check for live guests.

Fixes #53989.
MarshallOfSound added a commit that referenced this pull request Sep 18, 2026
)

Removing a <webview> from the DOM tears down its internal iframe first,
which destroys the guest and drops it from guestInstances. The element's
disconnectedCallback then sends GUEST_VIEW_MANAGER_DETACH_GUEST for that
id. Since #53684 the handler validates the id with getGuestForFrame()
before detaching, so the already-gone guest made the sync IPC throw back
into disconnectedCallback. The uncaught error also skipped the element's
reset, so a removed <webview> that was re-inserted never got a new guest.

Treat a detach for an unknown guest as a no-op again (as detachGuest()
always did) and keep the sender-frame check for live guests.

Fixes #53989.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Sam Attard <[email protected]>
MarshallOfSound added a commit that referenced this pull request Sep 18, 2026
)

Removing a <webview> from the DOM tears down its internal iframe first,
which destroys the guest and drops it from guestInstances. The element's
disconnectedCallback then sends GUEST_VIEW_MANAGER_DETACH_GUEST for that
id. Since #53684 the handler validates the id with getGuestForFrame()
before detaching, so the already-gone guest made the sync IPC throw back
into disconnectedCallback. The uncaught error also skipped the element's
reset, so a removed <webview> that was re-inserted never got a new guest.

Treat a detach for an unknown guest as a no-op again (as detachGuest()
always did) and keep the sender-frame check for live guests.

Fixes #53989.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Sam Attard <[email protected]>
MarshallOfSound added a commit that referenced this pull request Sep 18, 2026
)

Removing a <webview> from the DOM tears down its internal iframe first,
which destroys the guest and drops it from guestInstances. The element's
disconnectedCallback then sends GUEST_VIEW_MANAGER_DETACH_GUEST for that
id. Since #53684 the handler validates the id with getGuestForFrame()
before detaching, so the already-gone guest made the sync IPC throw back
into disconnectedCallback. The uncaught error also skipped the element's
reset, so a removed <webview> that was re-inserted never got a new guest.

Treat a detach for an unknown guest as a no-op again (as detachGuest()
always did) and keep the sender-frame check for live guests.

Fixes #53989.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Sam Attard <[email protected]>
MarshallOfSound added a commit that referenced this pull request Sep 18, 2026
)

Removing a <webview> from the DOM tears down its internal iframe first,
which destroys the guest and drops it from guestInstances. The element's
disconnectedCallback then sends GUEST_VIEW_MANAGER_DETACH_GUEST for that
id. Since #53684 the handler validates the id with getGuestForFrame()
before detaching, so the already-gone guest made the sync IPC throw back
into disconnectedCallback. The uncaught error also skipped the element's
reset, so a removed <webview> that was re-inserted never got a new guest.

Treat a detach for an unknown guest as a no-op again (as detachGuest()
always did) and keep the sender-frame check for live guests.

Fixes #53989.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Sam Attard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. new-pr 🌱 PR opened recently semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants