Skip to content

fix(transport): ignore non-object postMessage data - #109

Open
omerbek wants to merge 1 commit into
MetaMask:mainfrom
omerbek:fix/window-postmessage-null-data-guard
Open

omerbek wants to merge 1 commit into
MetaMask:mainfrom
omerbek:fix/window-postmessage-null-data-guard

Conversation

@omerbek

@omerbek omerbek commented Aug 25, 2026 •

Copy link
Copy Markdown

Summary

  • Ignore non-object message payloads before destructuring event.data in windowPostMessageTransport
  • Add a regression test for unrelated postMessage events with null and primitive payloads

Fixes #108.

Testing

  • ./node_modules/.bin/vitest.cmd run src/transports/windowPostMessageTransport.test.ts
  • ./node_modules/.bin/biome.cmd check src/transports/windowPostMessageTransport.ts src/transports/windowPostMessageTransport.test.ts

Note

Low Risk
Narrow defensive guard on message filtering with a targeted unit test; no changes to request/response or auth flows.

Overview
Fixes crashes when unrelated window.postMessage traffic uses null or primitive event.data values. The listener in windowPostMessageTransport now returns early unless event.data is a non-null object, before destructuring target and data.

A regression test asserts that null and string payloads are ignored without throwing, matching behavior for wrong origin, target, or stream name.

Reviewed by Cursor Bugbot for commit 8a4e694. Bugbot is set up for automated code reviews on this repo. Configure here.

@omerbek
omerbek requested a review from a team as a code owner August 25, 2026 07:24

This branch has not been deployed

No deployments
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.

windowPostMessageTransport throws when an unrelated postMessage has null data

1 participant