Fix iframe communication failure under Chrome strict-origin-isolation#901
Draft
Fix iframe communication failure under Chrome strict-origin-isolation#901
Conversation
When Chrome's strict-origin-isolation flag is enabled, three operations in the expensifyIframeify plugin throw SecurityError: 1. document.domain setter (blocked under origin isolation) 2. window.parent.location access (cross-origin property access denied) 3. contentWindow.location access (cross-origin property access denied) This causes the deposit-only bank account flow (and any other iframe communication between www.expensify.com and secure.expensify.com) to get stuck on a loading screen indefinitely. Changes: - Wrap document.domain setter in try/catch so it degrades gracefully - Add try/catch around window.parent.location access with fallback to inferring the parent origin from the allowedCommunications whitelist - Add try/catch around contentWindow.location access with fallback to extracting the origin from the iframe's src attribute Co-authored-by: Stephanie Elliott <stephanieelliott@users.noreply.github.com>
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
Replace the allowedCommunications lookup and iframe src parsing fallbacks with a simple '*' targetOrigin. This is safe because handleWindowMessage independently validates event.origin on the receiving side. Co-authored-by: Stephanie Elliott <stephanieelliott@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Chrome's
strict-origin-isolationflag is enabled (or whendocument.domainsetter is fully deprecated in future Chrome versions), theexpensifyIframeifyplugin fails silently because:document.domain = domainWithoutSubdomainthrows aSecurityErrorwindow.parent.location.protocol/.hostnamethrows aSecurityError(cross-origin property access denied)iframeElement[0].contentWindow.locationthrows the same errorThis causes any iframe communication between
www.expensify.comandsecure.expensify.com(e.g., the deposit-only bank account flow) to get stuck on a loading screen indefinitely, becausepostMessageis never called.Changes:
document.domainsetter in a try/catch so it degrades gracefully when blockedwindow.parent.locationaccess in a try/catch; on failure, fall back to'*'astargetOrigincontentWindow.locationaccess in a try/catch; on failure, fall back to'*'astargetOriginUsing
'*'as thetargetOriginfallback is safe because the receiving side'shandleWindowMessageindependently validatesevent.originagainst theallowedCommunicationswhitelist. ThetargetOriginparameter only controls whether the browser delivers the message — it does not affect the origin validation on the receiving end.In the normal case (no strict-origin-isolation), the try blocks succeed and behavior is identical to before. The fallbacks only activate when cross-origin access is blocked.
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/606093
Tests
npx eslint lib/jquery.expensifyIframify.js --quiet)npm test)jquery.expensifyIframify.js(browser-specific APIs likewindow.parent,document.domain, and iframes require a full browser environment)SecurityErroris thrown.QA
chrome://flags, enablestrict-origin-isolation, restart Chrome. Go to Settings > Account > Wallet > Add deposit-only Bank account. Verify the Plaid flow loads and completes successfully instead of getting stuck on a loading screen.www.expensify.comandsecure.expensify.com(bank account setup, payment card setup, Salesforce integration).