Skip to content

Conversation

ptrgits
Copy link

@ptrgits ptrgits commented Aug 4, 2025

window.parent.postMessage(serialized, '*');

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 in packages/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:

  • In packages/shared/lib/broadcast/broadcast.ts, replace '*' with the trusted origin string in the window.parent.postMessage call.
  • If the trusted origin is not known, use a placeholder and add a comment to update it as needed.

References

Window.postMessage
Same-origin policy
CWE-201
CWE-359

sa-l10n-translation and others added 30 commits July 22, 2025 05:03
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
LisaBot and others added 17 commits July 29, 2025 10:23
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
@mmso mmso force-pushed the main branch 3 times, most recently from 40360c7 to 2eaeffc Compare August 5, 2025 14:51
@mmso mmso force-pushed the main branch 7 times, most recently from 6f16c41 to c5e6ffe Compare August 21, 2025 12:04
@mmso mmso force-pushed the main branch 2 times, most recently from 1e4ffe8 to 8c63f2f Compare August 29, 2025 16:10
@ptrgits ptrgits closed this by deleting the head repository Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.