Skip to content

Conversation

@NDevTK
Copy link
Owner

@NDevTK NDevTK commented May 31, 2025

This commit addresses an issue where postMessage calls involving window.top might not be reliably intercepted and event.source could be misidentified.

Key changes in WindowScript.js:

  • Implemented a global proxy for Window.prototype.postMessage to ensure broader interception coverage.
  • Added specific logic to attempt to apply this proxy directly to window.top.postMessage if it hasn't been covered by the prototype chain modification, with error handling for potential cross-origin restrictions.
  • Introduced a Symbol (Symbol.for('postLoggerHandled')) for deduplication to prevent logging the same message multiple times if it passes through various hooks.
  • Refined how postMessage is hooked in the handle function and for MessagePort.prototype.postMessage to incorporate the deduplication logic.

Updated security.md:

  • Documented the enhanced postMessage interception capabilities, including the focus on window.top.
  • Added notes on the deduplication mechanism.
  • Included considerations regarding browser security limitations when interacting with a cross-origin window.top.

These changes aim to make the extension more robust in capturing and correctly identifying the source of postMessage events, especially in complex frame hierarchies involving window.top.

This commit addresses an issue where `postMessage` calls involving `window.top` might not be reliably intercepted and `event.source` could be misidentified.

Key changes in `WindowScript.js`:
- Implemented a global proxy for `Window.prototype.postMessage` to ensure broader interception coverage.
- Added specific logic to attempt to apply this proxy directly to `window.top.postMessage` if it hasn't been covered by the prototype chain modification, with error handling for potential cross-origin restrictions.
- Introduced a Symbol (`Symbol.for('postLoggerHandled')`) for deduplication to prevent logging the same message multiple times if it passes through various hooks.
- Refined how `postMessage` is hooked in the `handle` function and for `MessagePort.prototype.postMessage` to incorporate the deduplication logic.

Updated `security.md`:
- Documented the enhanced `postMessage` interception capabilities, including the focus on `window.top`.
- Added notes on the deduplication mechanism.
- Included considerations regarding browser security limitations when interacting with a cross-origin `window.top`.

These changes aim to make the extension more robust in capturing and correctly identifying the source of `postMessage` events, especially in complex frame hierarchies involving `window.top`.
@NDevTK NDevTK merged commit a253676 into main May 31, 2025
1 check passed
@NDevTK NDevTK deleted the fix-window-top-proxy branch May 31, 2025 13:45
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.

2 participants