fix: prevent cross-origin replay - #129
Conversation
| // the MessageChannel handshake (see event-handlers.js). | ||
| await TKHQ.initEphemeralEmbeddedKey(); | ||
| } | ||
|
|
There was a problem hiding this comment.
This event listener initialization ordering is technically a regression. Before, initEventHandlers() happened before initEmbeddedKey, but now it's happening after.
This is really an edge case though, would only cause a problem if a legacy parent sends a request during the async gap between the initEventHandlers/initEmbeddedKey.
But maybe it's worth just moving the initEvenHandlers to this line 34 to prevent that entirely.
|
This PR fixes Line 124 in 95c5c3b In |
Summary
Fixes INT-697 by preventing export bundles from being replayed across different embedding origins.
This change:
iframe-stamperversions below 2.1.0MessageChannelversus legacypostMessageusageCustomer Impact
For customers using
@turnkey/iframe-stamper >= 2.1.0, no API changes are required. On the first load after deployment, the previous global embedded key is replaced with a new key scoped to the customer’s origin.Bundles encrypted to the previous public key will no longer decrypt after this rotation. Any export operation in progress during deployment may need to be restarted.
Older iframe-stamper clients remain supported, but their embedded key is now tied to the lifetime of the iframe document. Reloading or recreating the iframe requires requesting a new export bundle.
Standalone use continues to persist an embedded key, scoped to the frame’s own origin.
Implementation Details
localStoragekeyconnect-src; the complete HTML-escaped endpoint is retained forsendBeacon.Testing
new test coverage:
postMessagetarget-origin behaviorMessagePortprecedence over legacy window messagingMessageChannelsource, origin, port, and race-condition testsmanually verified that two localhost parent origins receive different public keys and successfully complete their own export flows
validation completed: 67 Jest tests passing, ESLint passing, prettier check passing, production webpack build passing,
git diff --checkpassingRollout Notes
TURNKEY_TELEMETRY_ENDPOINTso we can track legacy client adoptionpostMessagecompatibility in a follow-up