-
Notifications
You must be signed in to change notification settings - Fork 627
fix(broadcast): cross-window communication with unrestricted target origin #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
i18n: Upgrade translations from crowdin (144cc025). See merge request web/clients!18260
Add the theme info data in root HTML See merge request web/clients!18261
Fix import See merge request web/clients!18272
Refactoring handleError to use an options object See merge request web/clients!18250
INWEB-198: Remove proton-pack config from storyboook See merge request web/clients!18215
INWEB-209 See merge request web/clients!18251
Account lumo user management See merge request web/clients!18255
…o 'main' [MSA-765] B2B Trials: remove direct debit support See merge request web/clients!18274
Ignore event type error See merge request web/clients!18277
INWEB-192: Remove proton-pack config from docs-editor See merge request web/clients!18209
Update Unleash See merge request web/clients!17981
INWEB-203: Add yarn:no-cache for storybook and visual tests See merge request web/clients!18381
[MSA-753] Disallow duplicate names in groups and sort them in natural order See merge request web/clients!18259
Update all non-major dependencies See merge request web/clients!18390
Retention UI [05]: Implement modal to add/edit retention policy See merge request web/clients!18148
[fix/DRVWEB-4834] fix create folder modal when moving files See merge request web/clients!18386
[Cleanup] Remove redundant code by removing MailboxRefactoring flag See merge request web/clients!18217
…to 'main' Prevent mail onboarding modal from being shown on the desktop app See merge request web/clients!18347
40360c7
to
2eaeffc
Compare
6f16c41
to
c5e6ffe
Compare
1e4ffe8
to
8c63f2f
Compare
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.
WebClients/packages/shared/lib/broadcast/broadcast.ts
Line 54 in a832ce2
The window.postMessage method allows different windows or iframes to communicate directly, even if they were loaded from different origins, circumventing the usual same-origin policy. The sender of the message can restrict the origin of the receiver by specifying a target origin. If the receiver window does not come from this origin, the message is not sent.
Alternatively, the sender can specify a target origin of '*', which means that any origin is acceptable and the message is always sent. This feature should not be used if the message being sent contains sensitive data such as user credentials: the target window may have been loaded from a malicious site, to which the data would then become available.
fix the problem, we need to restrict the target origin in the
window.parent.postMessage
call inpackages/shared/lib/broadcast/broadcast.ts
(line 54). Instead of using'*'
, we should specify the expected parent window's origin. The best way to do this is to pass the trusted origin as an argument to the broadcast function, or to determine it from configuration or environment variables. Since we can only edit the code shown, the simplest and safest fix is to replace'*'
with a hardcoded trusted origin (e.g.,'https://account.proton.me'
), assuming this is the only allowed embedding parent. If the parent origin can vary, the code should be updated to accept the origin as a parameter, but this would require changes outside the shown code.Required changes:
packages/shared/lib/broadcast/broadcast.ts
, replace'*'
with the trusted origin string in thewindow.parent.postMessage
call.References
Window.postMessage
Same-origin policy
CWE-201
CWE-359