Repository navigation
fix(silent-refresh): only accept messages from the iframe or popup the lib opened - #1516
Open
Dominik-O22 wants to merge 1 commit into
Open
Dominik-O22 wants to merge 1 commit into
Dominik-O22 wants to merge 1 commit into
Conversation
…e lib opened The silent refresh and popup login message listeners handled postMessage events from any window as auth responses, and checkOrigin only logged a mismatch. Check e.source against the silent refresh iframe or the login popup, and make checkOrigin return on mismatch. Fixes manfredsteyer#1354, fixes manfredsteyer#1409, fixes manfredsteyer#1448 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
The silent refresh and popup login listeners treat any
messageevent as an auth response. Any window that can post to the app gets its message parsed bytryLogin: an embedded iframe, a browser extension, the session check iframe, or the page that opened the app.checkOrigin: truedoesn't help, because it logs "wrong origin requested silent refresh!" and then carries on.This also explains #827. The silent refresh listener stays registered after a refresh and picks up the popup's reply too, so the same code gets exchanged twice and the second call fails with
invalid_grant.Both listeners now drop messages whose
e.sourceisn't the window the library opened:silentRefreshIFrameName.window.openreturned it or it came in throughoptions.windowRef.checkOrigin: truenow returns on an origin mismatch.silent-refresh.htmlposts throughwindow.parentorwindow.opener, soe.sourceis that iframe or popup and existing setups keep working. The localStorageauth_hashfallback is unchanged.Behaviour change: a custom redirect page that posts from a different window than the iframe or popup itself, for example
window.topfrom a nested frame, will stop working.Two tests cover the listeners. Both fail without the fix.
Fixes #1354, fixes #1409, fixes #1448
Reviewed with review-loop: 1 round with Claude Opus. Verdict: approved
Created with Claude Opus 5.5 in Claude Code.