Skip to content

fix: verify sender origin of checkout and message hub messages - #292

Open
jakubjasinsky wants to merge 2 commits into
masterfrom
fix/verify-checkout-message-origin
Open

jakubjasinsky wants to merge 2 commits into
masterfrom
fix/verify-checkout-message-origin

Conversation

@jakubjasinsky

Copy link
Copy Markdown
Collaborator

Summary

  • ActionHandler.listenEvents now ignores processout.checkout messages unless event.origin is the checkout origin (endpoint("checkout", "")).
  • MessageHub now only accepts value / ready messages from its own iframe (event.source) on the hub origin (derived from the iframe src, so the DEBUG endpoint override keeps working).
  • MessageHub-relayed results go straight to the shared message processing, since MessageHub verifies the sender itself.
  • No event.source check on checkout results: the bridge page posts to opener/parent/top, so nested frames would not match.
  • Version bump to 1.9.22.

All checkout bridge pages are served from checkout.processout.com / checkout.processout.ninja, which matches endpoint("checkout", "") for each environment.

Test plan

  • yarn test: new tests for accepted/ignored origins in actionhandler.test.ts and new messagehub.test.ts. They fail against the previous implementation.
  • yarn lint, yarn build
  • Sandbox: APM redirect and 3DS challenge flows still complete

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings November 25, 2026 11:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The origin check uses raw URL authority instead of a normalized browser origin, rejecting legitimate iframe messages for valid DEBUG overrides with default ports, uppercase hostnames, or relative URLs.

1 open issue
What changed in this PR

This PR hardens payment-result messaging by validating senders before checkout callbacks or message-hub notifications are processed.

Changes:

  • Restricts direct checkout messages to the configured checkout origin and hub messages to the hub iframe and origin.
  • Shares result processing between direct checkout messages and validated hub relays.
  • Adds sender-validation tests and bumps the version to 1.9.22.
File Description
test/​support/​loadNamespace.ts Adds isolated messaging loaders and DOM shims.
test/​processout/​messagehub.test.ts Tests hub origin and source validation.
test/​processout/​actionhandler.test.ts Tests checkout origin filtering and hub-relayed results.
src/​processout/​messagehub.ts Validates the sender of readiness and value messages.
src/​processout/​actionhandler.ts Filters checkout origins and shares result processing.
package.json Bumps the version to 1.9.22.

Review effort: Balanced

Comment thread src/processout/messagehub.ts Resolved
Only accept processout.checkout results posted from the checkout origin,
and only accept message hub values from the hub iframe on its own origin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakubjasinsky
jakubjasinsky force-pushed the fix/verify-checkout-message-origin branch from 1067065 to 759f753 Compare November 25, 2026 11:39
Compare event.origin against the browser-serialised origin of the hub
iframe src, so DEBUG overrides with uppercase hosts, default ports or
relative URLs still match. An unparsable src rejects every message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Using new URL(...) without an IE11-compatible polyfill breaks MessageHub initialization on a supported browser, causing all hub messages to be rejected and preventing hub-relayed payment actions from completing.

1 open issue
1 resolved since last review

Review effort: Balanced

// an unparsable src leaves it empty, which rejects every message
MessageHub.origin = "";
try {
MessageHub.origin = new URL(src, window.location.href).origin;

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Payment-flow trust cannot be verified end to end because the hosted relay’s sender/write authorization is outside this repository, and sandbox APM/3DS validation of bridge origins remains pending.

1 open issue

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants