Repository navigation
fix: verify sender origin of checkout and message hub messages - #292
jakubjasinsky wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 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
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>
1067065 to
759f753
Compare
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>
There was a problem hiding this comment.
🟡 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; |
There was a problem hiding this comment.
🔵 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


Summary
ActionHandler.listenEventsnow ignoresprocessout.checkoutmessages unlessevent.originis the checkout origin (endpoint("checkout", "")).MessageHubnow only acceptsvalue/readymessages from its own iframe (event.source) on the hub origin (derived from the iframesrc, so the DEBUG endpoint override keeps working).event.sourcecheck on checkout results: the bridge page posts toopener/parent/top, so nested frames would not match.All checkout bridge pages are served from
checkout.processout.com/checkout.processout.ninja, which matchesendpoint("checkout", "")for each environment.Test plan
yarn test: new tests for accepted/ignored origins inactionhandler.test.tsand newmessagehub.test.ts. They fail against the previous implementation.yarn lint,yarn build🤖 Generated with Claude Code